jueves, febrero 28, 2013

Reducir el tamaño de letra del UI en Eclipse bajo Linux


Si ejecutas Eclipse bajo Linux y lo haces (como yo) en un portátil con pantalla de 15", probablemente te encontrarás con el que tamaño de letra usado en el GUI es demasiado grande y se pierde espacio de todas las ventanas de trabajo (código, layout, propiedades, árbol de proyecto...).

No existe opción específica en Eclipse para cambiar de golpe el tipo o tamaño de letra utilizado, pero buscando información sobre ello he encontrado lo siguiente.

1.- Crea el fichero .gtkrc-eclipse en el directorio home de tu usuario, con este contenido:


style "eclipse" {
        font_name = "Sans Condensed 8"
}
class "GtkWidget" style "eclipse"



2.- Lanza eclipse con el siguiente comando:


GTK2_RC_FILES=/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:/home/usuario/.gtkrc-eclipse /opt/android/adt-bundle-linux/eclipse/eclipse


Si lo estás lanzando desde un "launcher" de gestor de ventanas, añade "env" delante:


env GTK2_RC_FILES=/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:/home/usuario/.gtkrc-eclipse /opt/android/adt-bundle-linux/eclipse/eclipse


De esta forma, se aplicará todo el estilo Clearlooks y tras él se aplicará el pequeño cambio de estilo definido en el fichero .gtkrc-eclipse.


Fuente: http://techtavern.wordpress.com/2008/09/24/smaller-font-sizes-for-eclipse-on-linux/


EDIT: He llegado a probar el tamaño "Sans Condensed 7" con éxito; todavía es legible y se gana algo más de espacio ... así que todavía podéis apurar un poco más si os lo permite la vista :-)


miércoles, febrero 27, 2013

bash tip: sleep until a given date/time and then execute a command



Imagine that you want to launch a "console" command or script in a terminal at 03:00AM, and being able to check the output at any time. But you don't want to use cron or at, because you need to control both stdin and stdout in any moment.

Yes, it seems a strange situation but it happens :P

Instead of waiting to 03:00AM to launch the command, you can use "sleep N && your-command", like this:


Add the following to your .bashrc file:


function sleep_until {
  NSECONDS=$(( $(date -d "$1" +%s) - $(date +%s) ))
    if [ $NSECONDS -lt 0 ];
    then
        NSECONDS=$(( $(date -d "tomorrow $1" +%s) - $(date +%s) ))
    fi
  echo "Sleeping for $NSECONDS seconds..."
  sleep $NSECONDS
}


Reload it (source .bashrc) and then you can write:


sromero@compiler ~ $ sleep_until 12:16 && echo "TEST"
Sleeping for 16 seconds...
TEST

sromero@compiler ~ $ sleep_until "tomorrow 12:16" && echo "TEST"
Sleeping for 86369 seconds...
(...)

sromero@compiler ~ $ sleep_until "tomorrow 03:00" && ./your_script.py
Sleeping for 52777 seconds...


If you don't specify a date (only hour) and given(hour:minute) < current(hour:minute), the script will use the date for the next day:



sromero@compiler ~ $ date
mié feb 27 12:28:11 CET 2013

sromero@compiler ~ $ sleep_until 12:25
Sleeping for 86207 seconds...



Now you can leave the computer on and go to sleep.

Wake up at 04:00AM, check that everything's went fine and that you don't need to relaunch the command, and go again to sleep :-).

For remote systems, don't forget to run this under screen or tmux :)


PD: Adapted from http://superuser.com/questions/222301/unix-sleep-until-the-specified-time .