Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # add to sway config:
  4. # bindsym Mod1+q exec ~/kill.sh
  5.  
  6. # this script kills the window UNLESS the name matches. If the name matches the SIGTERM signal is send to the target process
  7. # in case of wayland, the attribute 'app_id' is used while X11 windows use 'class'
  8.  
  9.  
  10. current_window=$(swaymsg -t get_tree | grep -A 45 '"focused": true' | egrep 'app_id|class' | cut -d \" -f 4 | grep .)
  11.  
  12. if [[ "$current_window" =~ ^(MYPROCESS|ALTERNATIVENAME)$ ]]; then
  13. swaymsg exec 'pkill --signal SIGTERM -f /usr/bin/MYPROCESS'
  14. else
  15. swaymsg kill
  16. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement