Last active
October 7, 2015 13:03
-
-
Save truetamtam/38b33dda3a09a5d04bdc to your computer and use it in GitHub Desktop.
Switch to last window of the application. Search by name in title. Uses wmctrl & xprop. Origin: http://askubuntu.com/a/562191
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 | |
| # Origin: http://askubuntu.com/a/562191 | |
| # required: wmctrl | |
| app=$1 | |
| workspace=$(wmctrl -d | grep '\*' | cut -d ' ' -f1) | |
| win_list=$(wmctrl -lx | grep $app | grep " $workspace " | awk '{print $1}') | |
| IDs=$(xprop -root|grep "^_NET_CLIENT_LIST_STACKING" | tr "," " ") | |
| IDs=(${IDs##*#}) | |
| for (( idx=${#IDs[@]}-1 ; idx>=0 ; idx-- )) ; do | |
| for i in $win_list; do | |
| if [ $((i)) = $((IDs[idx])) ]; then | |
| wmctrl -ia $i | |
| exit 0 | |
| fi | |
| done | |
| done | |
| exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment