Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. action=$(yad --width 300 --entry --title "System Logout" \
  4. --image=gnome-shutdown \
  5. --button="Switch User:2" \
  6. --button="gtk-ok:0" --button="gtk-close:1" \
  7. --text "Choose action:" \
  8. --entry-text \
  9. "Power Off" "Reboot" "Suspend" "Logout")
  10. ret=$?
  11.  
  12. [[ $ret -eq 1 ]] && exit 0
  13.  
  14. if [[ $ret -eq 2 ]]; then
  15. gdmflexiserver --startnew &
  16. exit 0
  17. fi
  18.  
  19. case $action in
  20. Power*) cmd="sudo /sbin/poweroff" ;;
  21. Reboot*) cmd="sudo /sbin/reboot" ;;
  22. Suspend*) cmd="sudo /bin/sh -c 'echo disk > /sys/power/state'" ;;
  23. Logout*)
  24. case $(wmctrl -m | grep Name) in
  25. *Openbox) cmd="openbox --exit" ;;
  26. *FVWM) cmd="FvwmCommand Quit" ;;
  27. *Metacity) cmd="gnome-save-session --kill" ;;
  28. *) exit 1 ;;
  29. esac
  30. ;;
  31. *) exit 1 ;;
  32. esac
  33.  
  34. eval exec $cmd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement