Created
September 21, 2015 15:48
-
-
Save rjmcguire/83f5c5610fd36c850af1 to your computer and use it in GitHub Desktop.
switch between windows of current application
This file contains 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 | |
# from: https://lars.st0ne.at/blog/switch%20between%20windows%20within%20the%20same%20application | |
# 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 window manager class of current window | |
win_class=$(wmctrl -x -l | grep $active_win_id | awk '{print $3}' ) | |
# get list of all windows matching with the class above | |
win_list=$(wmctrl -x -l | grep $win_class | awk '{print $1}' ) | |
# get next window to focus on | |
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