Skip to content

Instantly share code, notes, and snippets.

@mubeeniqbal
Last active August 29, 2015 14:10
Show Gist options
  • Save mubeeniqbal/3a17e7086d0fb039a818 to your computer and use it in GitHub Desktop.
Save mubeeniqbal/3a17e7086d0fb039a818 to your computer and use it in GitHub Desktop.
Runs exiting commands (e.g. shutdown, lock, reboot, etc.) for i3 window manager using polkit.
#!/usr/bin/env bash
#
# Runs exiting commands (e.g. shutdown, lock, reboot, etc.) for i3 window
# manager using polkit.
# This script is intended to be used with i3wm hotkey combinations.
# Usage: i3exit {lock|logout|suspend|hibernate|reboot|shutdown}
#######################################
# Lock screen in i3wm.
# Globals:
# None
# Arguments:
# None
# Returns:
# None
#######################################
lock() {
i3lock --image="/var/lib/AccountsService/icons/mubeen.png"
}
main() {
case "$1" in
lock) lock ;;
logout) i3-msg exit ;;
suspend) lock && systemctl suspend ;;
hibernate) lock && systemctl hibernate ;;
reboot) systemctl reboot ;;
shutdown) systemctl poweroff ;;
*)
echo 'Usage: i3exit {lock|logout|suspend|hibernate|reboot|shutdown}'
exit 2
esac
exit 0
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment