#!/bin/sh
lock() {

    # Pausing notification daemon to prevent flicker during lock.
    killall -SIGUSR1 dunst

    i3lock --nofork

    # Resuming notifications once out of lock screen.
    killall -SIGUSR2 dunst

}

case "$1" in
    lock)
        $HOME/.config/i3/lock.sh
        ;;
    logout)
        i3-msg exit
        ;;
    suspend)
        systemctl suspend && lock
        ;;
    reboot)
        reboot
        ;;
    shutdown)
        systemctl poweroff
        ;;
    *)
        echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
        exit 2
esac

exit 0
