Advertisement
Guest User

Untitled

a guest
Jan 26th, 2021
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.74 KB | None | 0 0
  1. #!/bin/bash
  2. # /usr/bin/i3exit
  3.  
  4. lock(){
  5.     xflock4
  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.         $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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement