2023-01-07 21:45:05 +01:00
|
|
|
#!/bin/sh -x
|
|
|
|
|
|
|
|
# set the following quirk in .config/spectrwm/spectrwm.conf
|
|
|
|
# quirk[scratchpad] = FLOAT + ANYWHERE + FOCUSPREV
|
|
|
|
|
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
|
|
|
|
st -c scratchpad -g 128x38+250+150 &
|
|
|
|
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-08 09:17:11 +01:00
|
|
|
# get current workspace ID
|
|
|
|
CWID=$(wmctrl -d | awk '{ if ($2 == "*") print $1 }')
|
|
|
|
# move window to current workspace
|
|
|
|
wmctrl -i -r $WID -t $CWID
|
|
|
|
# remove hidden flag
|
|
|
|
wmctrl -i -r $WID -b remove,hidden
|
|
|
|
# activate (give focus)
|
2023-01-07 21:45:05 +01:00
|
|
|
wmctrl -i -R $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
|