Added ability to have applications start in the scratchpad.

This commit is contained in:
Storm Dragon
2025-04-15 18:31:32 -04:00
parent 7ce6e3d10b
commit 09e21e297c
2 changed files with 38 additions and 1 deletions

32
scripts/bind_to_scratchpad.sh Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Find out if we're using i3
if ! [[ -n "${WAYLAND_DISPLAY}" ]]; then
cmd="i3-msg"
scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/i3"
else
cmd="swaymsg"
scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/sway"
fi
scratchConfig+="/scratchpad"
touch "${scratchConfig}"
# Get the focused window ID
windowId=$(xdotool getactivewindow)
# Get the class name of the window
class=$(xprop -id "$windowId" WM_CLASS | awk -F '"' '{print $4}')
if [[ -z "$class" ]]; then
notify-send "Unable to move to scratchpad."
exit 1
fi
# Check if it's already in the config
if ! grep -q "class=\"$class\"" "$scratchConfig"; then
echo "for_window [class=\"$class\"] move to scratchpad" >> "$scratchConfig"
notify-send "Added window class $class to scratchpad"
fi
# Move the window to scratchpad now
$cmd "[class=\"$class\"] move to scratchpad"