Friday, 29 June 2012

Shutting down at 6:30 AM?

We're having cooling maintenance carried out on Monday morning at 7:30 (yes AM!). As nobody likes getting up so friggin' early in the morning, here's how I'm going to shut down the servers nicely at 6:30. The command is simply called 'at'.

You envoke it by 'at <time>', e.g.:

# at 6:30
> shutdown -hP [Ctrl-D]

Here is where write the command being carried out .. when you're done, simply exit with a [Ctrl-D]. You wil be greeted by a message like

job 3 at 2012-06-29 6:30

The integer is the job id. You can also be more specific:

# at 6:30 monday

Jobs are executed only once. List your current at jobs with atq:

# atq
3    2012-06-29 6:30 a root

And cancel your at jobs with atrm (using the job id):

# atrm 3

Back to the problem at hand. We have a bunch of compute nodes, named *unray (i.e. bunray, gunray, funray, zunray, punray, wunray, runray,). Since I don't want to manually SSH into every node, I use SSH-keys and a for loop. All nodes mount the same /opt/folder. I put a file containing the command "shutdown -hP now" in /opt/scripts/shutdown.txt. at reads commands from a file via the -f switch. Now it is very easy to make all nodes receive the at command:


for i in b f g z p r w
do
ssh root@$i\unray at -f /opt/scripts/shutdown.txt 6:30am monday
done


Happy at'ing!

Saturday, 9 June 2012

Linux alternative to spotlight and windows startmenu

I really like the work flow of "run command" alt+f2 in most of the linux distros, but i would like to extend the functionality from just running a command to search etc.

I really dig the spotlight functionality on Mac OS X, and the startmenu functionality of windows.

windows 7 - start menu

OS X - Spotlight


I tried alternatives like The Synapse Launcher, Gnome Do and Google Desktop Search, but they seemed slow and very slow (and everyone working with unity will tell you how much of a pain alt+f2 is when it is slow).

I finally found Kupfer, which is really cool. Check it out in this video for an longer introduction of kupfer:




Personally I use Kupfer under LXDE which works great.


Light alternative to compiz grid effect


Implementing the

  • unity - window placement half-screen (ctrl+alt+numpad 4/5)
  • compiz - grid
  • windows 7 - window half screen (Super + Left/RightArrow)

effect on a 'naked system', without install heavy window management tools like Compiz.

Problem:
Okay, So I like being efficient with my working environment, especially with my window management, as I don't like wasting space on my 13" laptop screen.

I'm running LXDE with OpenBox and Anders is running gnome2 with Metacity.


PyWO - Python Window Organizer

The solution is too use the small python script provided by PyWo which can be downloaded from http://code.google.com/p/pywo/ written by http://kosciak.blox.pl/html.
In writing I'm using the 0.2 version.

Implementation (really easy!):

  1. Download version 0.2 from google code, and put in a folder. I put it in ~/settings/pywo-2.0/
  2. Run the downloaded script (/home/charnley/settings/pywo-2.0/pywo.py) 
  3. DONE


Default keyboard shortcuts:



Alt-Ctrl-Shift-Q    - exit PyWO
Alt-Ctrl-Shift-R    - reload configuration fileAlt-Ctrl-Shift-I    - print debug information about window manager and current window
Alt-KP_Divide       - switch windows (change position of the window)
Alt-Shift-KP_Divide - cycle windows (change contents of the window)
Alt-KP_1-9          - move window in a direction (KP_1-9 - numpad keys)
Shift-KP_1-9        - expand window in a direction (5 works as maximumize compiz plugin)
Alt-Shift-KP_1-9    - shrink windowAlt-Ctrl-KP_1-9     - put window to predefined positionCtrl_KP_1-9         - put and resize (grid), and cycle widthsCtrl-Shift_KP_1-9   - put and resize (grid), and cycle heights

Note, the default configuration is to use the numpad as the control, but being a laptop user this is not an option. So my setup is:

Laptop configuration:

Create ~/.pyworc and fill in:


[SETTINGS]
; 1/on/yes/true - work only when NumLock is on
; ignore - ignore NumLock state (works when on and off)
; 0/off/no/false - work only when NumLock is off
numlock = ignore

; invert window gravity if it needs resizing (eg terminals with incremental
; size change), works only for grid
invert_on_resize = yes

; if true try expandig in vertical axis first
vertical_first = yes

; grid_2x2, grid_3x2, grid_3x3, custom
layout = grid_2x2

;ignore_actions = grid_height

[KEYS]
; section/point-name =  key
top-left = KP_7
top = KP_8
top-right = KP_9
left = Left
middle = Up
right = Right
bottom-right = KP_3
bottom = KP_2
bottom-left = KP_1

switch = Alt-KP_Divide
cycle = Alt-Shift-KP_Divide

; key modifiers (Alt, Shift, Ctrl, Super) for actions
float = Alt-Shift
expand = Alt-Shift
shrink = Alt-Shift
put = Super-Ctrl
; cycle widths
grid_width = Super
; cycle heights
grid_height = Ctrl-Shift

; exit PyWo
exit = Ctrl-Shift-Alt-Q
; reload configuration file
reload = Ctrl-Shift-Alt-R
; print info for current window
debug = Ctrl-Shift-Alt-I


I changed the configuration so it works almost like the windows alternative, with arrow and super key.

Grid: 2x2

Shortcuts:
Super+Left Arrow  = fill left half of screen
Super+Right Arrow = fill right half of screen
Super+Arrow Up = fill full screen


For list of shortcut/keys available check:
http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/trunk/Xlib/keysymdef/miscellany.py?revision=151&view=markup&pathrev=151
http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/trunk/Xlib/keysymdef/latin1.py?revision=151&view=markup&pathrev=151



Autostart the script:

LXDE:

To autostart a script in LXDE you create a .desktop file in ~/.config/autostart/.
If you are a awesome LXDE user, create ~/.config/autostart/pywo.desktop and fill in the following:


[Desktop Entry]
Encoding=UTF-8
Name=PyWo
Comment=Python Window Organizer
Exec=/home/charnley/settings/pywo-0.2/pywo.py
X-GNOME-Autostart-enabled=true

Where you substitute the Exec with the path to where you downloaded pywo too.



And that is it! Happy windowing!