Facebook
From Putrid Mockingjay, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 219
  1. #!/bin/bash
  2. # /usr/bin/i3exit
  3.  
  4. lock(){
  5.         blurlock
  6.  
  7. }
  8.  
  9.  
  10. # with openrc use loginctl
  11. [[ $(cat /proc/1/comm) == "systemd" ]] && logind=systemctl || logind=loginctl
  12.  
  13.  
  14.  
  15.  
  16.  
  17. case "$1" in
  18.     lock)
  19.         lock
  20.         ;;
  21.     logout)
  22.         i3-msg exit
  23.         ;;
  24.     switch_user)
  25.         dm-tool switch-to-greeter
  26.         ;;
  27.     suspend)
  28.         lock && $logind suspend
  29.         ;;
  30.     hibernate)
  31.         lock && $logind hibernate
  32.         ;;
  33.     reboot)
  34.         $logind reboot
  35.         ;;
  36.     shutdown)
  37.         $logind poweroff
  38.         ;;
  39.     *)
  40.         echo "== ! i3exit: missing or invalid argument ! =="
  41.         echo "Try again with: lock | logout | switch_user | suspend | hibernate | reboot | shutdown"
  42.         exit 2
  43. esac
  44.  
  45. exit 0