e_launchOrMoveApp.sh

Purpose: This script was written to be bound to the extra keys on my Logitech Cordless Desktop Deluxe wireless keyboard. This way, I can click on f.i. the E-Mail button to either launch my mail program, or transfer the application to the current desktop.

Requirements: Enlightenment window manager

#!/bin/bash

# This script gets the current desktop and area
# and checks if the prog $1 (identifier) is running
# and moves a running $1 to current desktop/area
# or starts $2 (command)
# e.g. $1 = Evolution and $2 = evolution

eesh -ewait "goto_desktop ?"| \
cut -f2 -d: |\
while read desktop; do
	eesh -ewait "goto_area ?"| \
	cut -f2 -d: |\
	while read area; do
		if eesh -ewait "window_list" | grep $1 
		then
			eesh -ewait "window_list" | \
                        grep $1| \
			cut -f1 -d: |\
			while read win_id; do 
				eesh -e "win_op ${win_id} move 80 0"; 
				eesh -e "win_op ${win_id} desk ${desktop}";
				eesh -e "win_op ${win_id} area ${area}";
			done 
		else 
			$2 &
		fi
	done
done

and in ~/.enlightenment/keybindings.cfg:
__NEXT_ACTION
    __KEY logitech_mail
    __EVENT __KEY_PRESS
    __ACTION __A_EXEC ~/scripts/e_launchOrMoveApp.sh Evolution evolution