Last active
August 29, 2015 14:14
-
-
Save aauren/c8a5513ba1cc5d734994 to your computer and use it in GitHub Desktop.
Linux Desktop Window Switching
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
#!/usr/bin/env bash | |
# Creates a dialog using Zenity that lists all of your open windows and then switches to whatever window matches your input | |
# Requires Zenity, wmctrl, and xdotool packages | |
WINDOW_TITLES=$(wmctrl -l | grep -v "\-1" | sed -r 's/([^ ]+ +){3}(.*)/\2/g') | |
WINDOW_SELECTION=$(zenity --entry --title="Choose a Window" --text="${WINDOW_TITLES}") | |
DESKTOP_NUMBER=$(wmctrl -l | grep -v "\-1" |grep -m 1 ${WINDOW_SELECTION} | sed -r 's/^[^ ]+ +([^ ]+) .*/\1/g') | |
echo "Selection: ${WINDOW_SELECTION} Desktop: ${DESKTOP_NUMBER}" | |
xdotool search --desktop ${DESKTOP_NUMBER} --name ${WINDOW_SELECTION} windowactivate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment