Last active
February 22, 2022 22:33
-
-
Save tokland/834f9d5dd261bb2d1b3725df705619cd to your computer and use it in GitHub Desktop.
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 | |
# Start a UI app and move its window to a specific Xfce workspace. | |
# | |
# Example: Move app xoscope to workspace number 2 (starts at 1). | |
# | |
# $ run-in-workspace 2 xoscope | |
run_in_workspace() { | |
local workspace=$1 | |
local pid winh | |
shift 1 | |
"$@" & | |
pid=$! | |
echo "pid: $pid" | |
while true; do | |
winh="$(wmctrl -l -p | awk "\$3 == $pid" | awk '{print $1}')" | |
echo "Winh0: $winh" | |
if test -z "$winh"; then | |
sleep 0.1 | |
else | |
wmctrl -i -r "$winh" -t "$((workspace - 1))" | |
break | |
fi | |
done | |
} | |
run_in_workspace "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice idea. To allow for multiple windows, consider: