#!/bin/bash # Suspend is managed by elogind # Refer to ~/.b/etc/elogind/logind.conf # ~/.b/etc/elogind/system-sleep/run-lock.sh # ++=================================++ # || Actions before and after unlock || # ++=================================++ before_locking () { # Disables dunst, my notification daemon, so I don't see notification on lock screen # https://github.com/dunst-project/dunst/issues/697 # https://wiki.archlinux.org/title/Dunst#Disable_dunst_temporarily dunstctl set-paused true touch ~/.tmp/locksh-locked } before_suspend () { # Keep track of time when machine is suspended, as well as how long it has been up for echo "$(date) $(uptime)" >> ~/bin/suspend-history } when_unlocked () { dunstctl set-paused false # Enables my notification daemon # Resets programs, in case resolution changes ~/.fehbg # wallpaper rm ~/.tmp/locksh-locked } # ++============================++ # || Lock if not locked already || # ++============================++ if [ ! -f ~/.tmp/locksh-locked ]; then [ "$1" == 'suspend' ] && before_suspend # The first line of i3lock arguments uses standard arguments, while the rest of the lines are i3lock-color ones # If you want to use i3lock, remove those lines (and the \ at the end) # But I highly advise you to use i3lock-color, it's amazing: https://github.com/Raymo111/i3lock-color before_locking && \ i3lock -f -c d49408 -i ~/bin/lockscreen.png -n \ -k --indicator --keylayout 1 --radius 95 --pass-volume-keys \ --date-str='%d.%m.%Y' --verif-text='Verifying…' --wrong-text='Wrong!' --noinput-text='No Input!' \ --insidever-color d47408cc --ringver-color d47408 --insidewrong-color c35b5bcc --ringwrong-color c35b5b \ --layout-color ffeede --time-color ffeede --date-color ffeede --greeter-color ffeede --verif-color ffeede --wrong-color ffeede \ ; when_unlocked else echo "Not locking, lockfile exists!" fi