Added ability to have applications start in the scratchpad.
This commit is contained in:
32
scripts/bind_to_scratchpad.sh
Executable file
32
scripts/bind_to_scratchpad.sh
Executable 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"
|
Reference in New Issue
Block a user