Reputation: 16
I have tried to make a script that takes a screenshot of current screen, blur it and set it as background of i3 lock screen.In addition I want to activate a timeout of 10 seconds to power down the locked screen.I linked this script with keybinding for i3 lock but the 10 seconds timeout feature is running without i3 lock as well, my screen's power goes down after every 10 seconds of inactivity.
Here is my script:
#!/bin/bash
img='ss.png'
scrot "$img"
convert $img -blur 2,5 $img
i3lock -i $img
rm $img
xset dpms 0 0 10 ```
Upvotes: 0
Views: 650
Reputation: 973
Maybe instead of that xset
line, you can write something like
#!/usr/bin/env bash
img='ss.png'
scrot "$img"
convert "$img" -blur 2,5 "$img"
i3lock -i "$img"
rm -f -- "$img"
has_set_dpms=false
while :; do
if pgrep i3lock >/dev/null; then
if [ "$has_set_dpms" != true ]; then
xset dpms 0 0 10
fi
has_set_dpms=true
else
# Once the process i3lock cannot be found, we turn off DPMS, or
# you can reset it to what it was before
xset -dpms
exit
fi
sleep 5
done
Essentially, it just loops, checking if i3lock is on. If it is (we just launched it), then we do the xset
(and use the has_set_dpms
variable to make sure we only call xset
once in the while loop).
Once the i3lock process does not exist, then we reset the dpms
with xset and exit.
Also I thought that i3lock -i "$img"
would need to have an &
at the end of the line, but I suppose not...
Upvotes: 0