Timout action trigger on TrackPoint movement
tukusejssirs opened this issue · 2 comments
I have the following in my Sway config:
exec swayidle -w timeout 5 '
if pgrep -x swaylock; then
swaymsg "output * dpms off"
brightnessctl -d "tpacpi::kbd_backlight" g > /dev/shm/kbbl_prev
brightnessctl -qd "tpacpi::kbd_backlight" s 0; fi
' resume '
if [ -f /dev/shm/kbbl_prev ]; then
swaymsg "output * dpms on"
brightnessctl -qd "tpacpi::kbd_backlight" s "$(< /dev/shm/kbbl_prev)
rm -f /dev/shm/kbbl_prev"
fi
'
What it does is when swaylock
is running, after timeout of 5 seconds turn off the screen and the keyboard backlight.
Everything behaves as expected, but when swaylock
is not running and I let the system be idle for at least 5 seconds, then move my TrackPoint, the keyboard backlight is turned off.
The culprit is the /dev/shm/kbbl_prev
file. If it contains 0
(which turns the keyboard backlight off), but also I think there is an issue in swayidle
, because it should:
- never the
true
branch ofif
intimout
whenswaylock
is not running; - in
resume
, it should remove/dev/shm/kbbl_prev
, but it fails to do so.
Anyway, if someone knows of a better way to let the resume
part know what was the previous state of the keyboard backlight (in my case, it can be one of 0
, 1
or 2
), I’d be very, very greatful.
This issue is related to #42, which might describe the same issue, but a bit different use case.
It seems like I’ve made a mistake in the code of the issues description. I misquoted $(< /dev/shm/kbbl_prev); rm -f /dev/shm/kbbl_prev
instead of only $(< /dev/shm/kbbl_prev)
.
The following is a working code:
exec swayidle -w timeout 5 '
if pgrep -x swaylock; then
swaymsg "output * dpms off"
brightnessctl -d "tpacpi::kbd_backlight" g > /dev/shm/kbbl_prev
brightnessctl -qd "tpacpi::kbd_backlight" s 0; fi
' resume '
if [ -f /dev/shm/kbbl_prev ]; then
swaymsg "output * dpms on"
brightnessctl -qd "tpacpi::kbd_backlight" s "$(< /dev/shm/kbbl_prev)"
rm -f /dev/shm/kbbl_prev
fi
'