dotfiles/.bin/sp

48 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
RES=$(xrandr | grep "*+" | awk '{print $1}')
RESH=${RES%x*}
RESV=${RES#*x}
GAP=150
H=$(( RESH - 2 * GAP ))
V=$(( RESV - 2 * GAP ))
# set the following quirk in .config/spectrwm/spectrwm.conf
# quirk[scratchpad] = FLOAT + ANYWHERE
# get scratchpad window id
WID=$(wmctrl -x -l scratchpad | fgrep '.scratchpad' | cut -d" " -f1)
if [ -z "$WID" ]
then
sterm -c scratchpad -g 160x42+130+80 &
WID=$(wmctrl -x -l scratchpad | fgrep '.scratchpad' | cut -d" " -f1)
else
# check if window is iconfified or on another WS (or both)
if xwininfo -id $WID | fgrep -q IsUnMapped
then
# move window to current workspace
#wmctrl -i -r $WID -t $(xprop -root _NET_CURRENT_DESKTOP | cut -d'=' -f2)
wmctrl -i -r $WID -t $_SWM_WS
# remove hidden flag
wmctrl -i -r $WID -b remove,hidden,sicky
# activate (give focus)
wmctrl -i -a $WID
else
# window is visible => hide
wmctrl -i -r $WID -b add,hidden
fi
# wmctrl -i -r $WID -e 0,200,200,1420,680
wmctrl -i -r $WID -e 0,$GAP,$GAP,$H,$V
fi
c=0
while [ -z $WID ] && [ $c -lt 10 ]
do
WID=$(wmctrl -x -l scratchpad | fgrep '.scratchpad' | cut -d" " -f1)
c=$(( $c + 1 ))
sleep 0.1
done
wmctrl -i -r $WID -e 0,$GAP,$GAP,$H,$V