dotfiles/.bin/sp

29 lines
794 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
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 }')
# remove hidden flag
wmctrl -i -r $WID -b remove,hidden
2023-01-08 17:34:37 +01:00
# move window to current workspace
wmctrl -i -r $WID -t $CWID
2023-01-08 09:17:11 +01:00
# 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