diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-07-01 12:42:01 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-07-01 12:44:17 +0300 |
| commit | 329f5a6de3be9d790b1a6788bcb9267809382f36 (patch) | |
| tree | 362c3b2f52967b8132f44f559d96425831ecf474 | |
| parent | 211a13c697e2cb34d276095c8a11a9d98cc46fbb (diff) | |
| download | dotfiles-329f5a6de3be9d790b1a6788bcb9267809382f36.tar dotfiles-329f5a6de3be9d790b1a6788bcb9267809382f36.tar.gz dotfiles-329f5a6de3be9d790b1a6788bcb9267809382f36.zip | |
Implemented lock script suspend waiting for lockscreen to be active and brought back lock screen not locking when playing audio without arguments given
| -rwxr-xr-x | .i3lock/lock.sh | 14 |
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: # |
