Skip to content

Instantly share code, notes, and snippets.

@SidharthArya
Last active July 5, 2022 01:07
Show Gist options
  • Save SidharthArya/64c30275c1189e956be6bdc8dc67c777 to your computer and use it in GitHub Desktop.
Save SidharthArya/64c30275c1189e956be6bdc8dc67c777 to your computer and use it in GitHub Desktop.
A simple script for bspwm to creating scratchpads
super + Return
~/.local/scripts/Scratchpad.sh title terminal-scratchpad st -n terminal-scratchpad -g 160x50 -e tmux
#!/usr/bin/env bash
all_args=("$@")
arg1=$1
arg2=$2
arg3="${all_args[@]:2}"
case $arg1 in
"title")
id=$(xdo id -n $arg2)
;;
"class")
id=$(xdo id -N $arg2)
;;
*)
echo "Wrong Option!"
;;
esac
echo $id
echo $arg3
if [ "$id" == "" ]
then
exec $arg3;
else
if [ "$(printf '%s' "$GDMSESSION" | grep bspwm | wc -l)" == "1" ]
then
bspc node $(printf $id) -g hidden -d focused -f
else
state=$(xprop -id "$id" WM_STATE | grep 'window state' | awk '{print $3}')
if [ "$state" == "Withdrawn" ]
then
xdo show $id
else
xdo hide $id
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment