dotfiles/.bin/sp

27 lines
746 B
Plaintext
Raw Normal View History

2023-01-08 17:34:37 +01:00
#!/bin/sh
2023-01-07 21:45:05 +01:00
# set the following quirk in .config/spectrwm/spectrwm.conf
2023-01-08 17:34:37 +01:00
# quirk[scratchpad] = FLOAT + ANYWHERE
2023-01-07 21:45:05 +01:00
2023-01-08 09:17:11 +01:00
# get scratchpad window id
2023-01-07 21:45:05 +01:00
WID=$(wmctrl -x -l scratchpad | fgrep '.scratchpad' | cut -d" " -f1)
if [ -z "$WID" ]
then
2023-01-10 08:20:01 +01:00
sterm -c scratchpad -g 156x42+240+140 &
2023-01-07 21:45:05 +01:00
else
2023-01-08 09:17:11 +01:00
# check if window is iconfified or on another WS (or both)
if xwininfo -id $WID | fgrep -q IsUnMapped
2023-01-07 21:45:05 +01:00
then
2023-01-10 08:20:01 +01:00
# move window to current workspace
wmctrl -i -r $WID -t $(xprop -root _NET_CURRENT_DESKTOP | cut -d'=' -f2)
2023-01-08 09:17:11 +01:00
# remove hidden flag
wmctrl -i -r $WID -b remove,hidden
# activate (give focus)
2023-01-10 08:20:01 +01:00
wmctrl -i -a $WID
2023-01-08 09:17:11 +01:00
else
# window is visible => hide
wmctrl -i -r $WID -b add,hidden
2023-01-07 21:45:05 +01:00
fi
fi