Created
August 21, 2013 16:37
-
-
Save patbl/6296851 to your computer and use it in GitHub Desktop.
Window switcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
win_class='emacs.Emacs' | |
# get list of all windows matching with the class above | |
win_list=$(wmctrl -x -l | grep -i $win_class | awk '{print $1}' ) | |
# get id of the focused window | |
active_win_id=$(xprop -root | grep '^_NET_ACTIVE_W' | awk -F'# 0x' '{print $2}') | |
if [ "$active_win_id" == "0" ]; then | |
active_win_id="" | |
fi | |
# get next window to focus on, removing id active | |
switch_to=$(echo $win_list | sed s/.*$active_win_id// | awk '{print $1}') | |
# if the current window is the last in the list ... take the first one | |
if [ "$switch_to" == '' ];then | |
switch_to=$(echo $win_list | awk '{print $1}') | |
fi | |
# switch to window | |
wmctrl -i -a $switch_to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment