dotfiles/local-bin/.local/bin/niri-scratchpad.sh

18 lines
673 B
Bash
Executable file

#!/run/current-system/sw/bin/bash
# Check if scratchpad terminal is already running
if pgrep -f "kitty.*scratchpad" > /dev/null; then
# Get the window ID of the scratchpad terminal
WINDOW_ID=$(niri msg windows | grep -A 10 'app-id="scratchpad"' | head -1 | grep 'Window ID' | cut -d' ' -f3 | cut -d: -f1)
if [ -n "$WINDOW_ID" ]; then
# Focus the existing scratchpad window
niri msg action focus-window "$WINDOW_ID"
else
# If we can't find the window ID, spawn a new one
kitty --class scratchpad --title scratchpad &
fi
else
# Spawn a new scratchpad terminal
kitty --class scratchpad --title scratchpad &
fi