Summary Files Commits Branches @commit @diff @stats
path: root / openbox_de / bin / lock
blob: 37fd08f503a3f2ffa66874f19c3cae703822e64e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/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