niri-scratchpad.sh 673 B

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