Created
November 9, 2024 12:30
-
-
Save kesor/124a84c16270c36504959a071c62a571 to your computer and use it in GitHub Desktop.
wm scratchpad script
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/sh | |
name=$1 | |
case "$name" in | |
speedcrunch) | |
win_ids=$(xdotool search --classname "SpeedCrunch") | |
visible_win="" | |
hidden_win="" | |
# Iterate over all found window IDs | |
for win_id in $win_ids; do | |
if xwininfo -id "$win_id" | grep -q "Map State: IsViewable"; then | |
visible_win=$win_id | |
else | |
hidden_win=$win_id | |
fi | |
done | |
# Toggle visibility based on the current state | |
if [ -n "$visible_win" ]; then | |
xdotool windowunmap "$visible_win" | |
elif [ -n "$hidden_win" ]; then | |
xdotool windowmap "$hidden_win" | |
else | |
speedcrunch & | |
fi | |
;; | |
terminal) | |
win_ids=$(xdotool search --name "scratchterm") | |
visible_win="" | |
hidden_win="" | |
# Iterate over all found window IDs | |
for win_id in $win_ids; do | |
if xwininfo -id "$win_id" | grep -q "Map State: IsViewable"; then | |
visible_win=$win_id | |
else | |
hidden_win=$win_id | |
fi | |
done | |
# Toggle visibility based on the current state | |
if [ -n "$visible_win" ]; then | |
xdotool windowunmap "$visible_win" | |
elif [ -n "$hidden_win" ]; then | |
xdotool windowmap "$hidden_win" | |
else | |
kitty --detach -T scratchterm | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment