summaryrefslogtreecommitdiff
path: root/.i3lock/lock.sh
blob: 52323d9526d79411dfcb1f4c72df53fb9f63c6e4 (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
#!/bin/bash

if [ $(grep -r "RUNNING" /proc/asound | wc -l) -eq 0 ] || [[ $# -ne 0  ]]; then
	# 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

	if [[ "$1" == "suspend" ]]; then
		# Usually suspending should be done with "systemctl suspend", but I've had issues with that so I directly tell the kernel to sleep the system
		# For that I have a script in /usr/loca/sbin that just continains:
		#
		# #!/bin/bash
		# echo -n mem>/sys/power/state
		#
		# And I've added the following to /etc/sudoers (where kamen is my username), so I don't need to put in my password:
		#
		# kamen ALL = (root) NOPASSWD: /usr/local/sbin/sleep.sh
		sudo -u root /usr/local/sbin/sleep.sh

		# Audio could get messed up if something is playing while trying to suspend
		# By restarting pulseaudio, all playback gets "stopped", which should prevent any audio issues post-suspend
		pulseaudio -k
	fi

	i3lock -f -c d49408 -i /home/kamen/.i3lock/lockscreen.png -n

	dunstctl set-paused false # Enables my notification daemon
	killall lwa-hot-corners; lwa-hot-corners ~/.lwarc &
	killall tint2; nohup tint2 2>&1 &
	disown
	picom --experimental-backends & # Sometimes my compositor crashes or smth, so I try to launch it, just in case it stopped working
fi