Created
February 28, 2019 13:04
-
-
Save unhammer/645c02a7bc32dfbb54e1d07b1691ef8f to your computer and use it in GitHub Desktop.
Run a program with focus_new set to on, then turn focus_new off again
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 | |
# Usage: | |
# chmod +x with-focus | |
# ./with-focus CMD ARG1 ARG2 | |
# e.g. | |
# ./with-focus xfce4-terminal | |
# ./with-focus mousepad file.txt | |
# When this script exits, turn focus_new back to false | |
trap 'xfconf-query -c xfwm4 -p /general/focus_new -s false' EXIT | |
curwindow=$(xprop -root _NET_ACTIVE_WINDOW) | |
# Temporarily set focus_new true: | |
xfconf-query -c xfwm4 -p /general/focus_new -s true | |
# Run whatever program was given, in the background so we can exit and it will | |
# keep going: | |
"$@" & disown | |
# Keep this script running until the current window id changes (new window has | |
# focus). | |
while [[ "${curwindow}" = "$(xprop -root _NET_ACTIVE_WINDOW)" ]]; do | |
sleep 0.3 | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment