summaryrefslogtreecommitdiff
path: root/.i3lock/lock.sh
diff options
context:
space:
mode:
Diffstat (limited to '.i3lock/lock.sh')
-rwxr-xr-x.i3lock/lock.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/.i3lock/lock.sh b/.i3lock/lock.sh
index 57c3feb..7d6409e 100755
--- a/.i3lock/lock.sh
+++ b/.i3lock/lock.sh
@@ -15,6 +15,13 @@ when_unlocked_after_suspend () {
gtk-launch picom # sometimes my compositor stops working after suspend, this makes sure it's running
}
+# This makes sure to not lock the screen if audio is playing and there are no arguments given
+# It's mainly for preventing automatic screen locking while a video/music is playing
+# If you still want to lock, just give it some argument, doesn't matter what
+if [ $(grep -r "RUNNING" /proc/asound | wc -l) -ne 0 ] && [[ $# -ne 0 ]]; then
+ exit
+fi
+
# Show an error message if user is trying to suspend, while audio is playing, because that can mess up sound servers
# It tries to send a message via zenity, xmessage or notify-send, depending on which is installed
# but it always sends a text message to stdout. In the end, scrit execution is stopped.
@@ -52,6 +59,13 @@ if [[ "$1" == "suspend" ]]; then
# script should run when_unlocked_after_suspend function
touch /tmp/slept
+ # Wait for the lock screen to appear, before suspending
+ # Without this, sometimes you could awaken the computer and see the desktop for a second, before the lockscreen loads.
+ # During that time, your input is processed by the desktop, giving you control of it, which is a big no-no (even if it's for a second)
+ while [ $(xdotool search --onlyvisible --classname i3lock | wc -l) -eq 0 ]; do
+ sleep 0.2
+ done
+
# 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:
#