2023-01-08 17:34:37 +01:00
|
|
|
#!/bin/sh
|
2023-01-07 21:45:05 +01:00
|
|
|
|
2023-11-02 22:00:22 +01:00
|
|
|
RES=$(xrandr | grep "*+" | awk '{print $1}')
|
|
|
|
RESH=${RES%x*}
|
|
|
|
RESV=${RES#*x}
|
|
|
|
|
|
|
|
GAP=150
|
|
|
|
|
|
|
|
H=$(( RESH - 2 * GAP ))
|
|
|
|
V=$(( RESV - 2 * GAP ))
|
|
|
|
|
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-11-02 22:16:28 +01:00
|
|
|
sterm -c scratchpad -g 161x38+$GAP+$GAP &
|
2023-11-02 22:00:22 +01:00
|
|
|
WID=$(wmctrl -x -l scratchpad | fgrep '.scratchpad' | cut -d" " -f1)
|
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
|
2023-04-10 13:00:38 +02:00
|
|
|
#wmctrl -i -r $WID -t $(xprop -root _NET_CURRENT_DESKTOP | cut -d'=' -f2)
|
2023-10-24 22:24:28 +02:00
|
|
|
wmctrl -i -r $WID -t $_SWM_WS
|
2023-01-08 09:17:11 +01:00
|
|
|
# remove hidden flag
|
2023-10-24 22:24:28 +02:00
|
|
|
wmctrl -i -r $WID -b remove,hidden,sicky
|
2023-01-08 09:17:11 +01:00
|
|
|
# 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-11-02 22:16:28 +01:00
|
|
|
# correct size while hidden
|
|
|
|
wmctrl -i -r $WID -e 0,$GAP,$GAP,$H,$V
|
2023-01-07 21:45:05 +01:00
|
|
|
fi
|
|
|
|
fi
|