feat: switch to xidlehook

This commit is contained in:
ineanto 2025-07-18 10:24:42 +02:00
parent 00cef52dcf
commit d96a5583ad
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84
2 changed files with 24 additions and 2 deletions

View file

@ -19,8 +19,8 @@ set $mod Mod4
# Display setup # Display setup
exec --no-startup-id xrandr --auto exec --no-startup-id xrandr --auto
# Transfer X11 lock to i3lock (locks computer before going to sleep) # Autolock script
exec xss-lock --transfer-sleep-lock -- i3lock --nofork exec "$HOME/.config/i3/scripts/autolock.sh"
# Polybar # Polybar
exec_always --no-startup-id $HOME/.config/i3/scripts/polybar.sh exec_always --no-startup-id $HOME/.config/i3/scripts/polybar.sh

View file

@ -0,0 +1,22 @@
#!/usr/bin/sh
# Only exported variables can be used within the timer's command.
export PRIMARY_DISPLAY="$(xrandr | awk '/ primary/{print $1}')"
# Run xidlehook
xidlehook \
`# Don't lock when there's a fullscreen application` \
--not-when-fullscreen \
`# Don't lock when there's audio playing` \
--not-when-audio \
`# Dim the screen after 1 minute and 20 seconds, undim if user becomes active` \
--timer 80 \
'xrandr --output "$PRIMARY_DISPLAY" --brightness .1' \
'xrandr --output "$PRIMARY_DISPLAY" --brightness 1' \
`# Undim & lock after 10 more seconds` \
--timer 10 \
'xrandr --output "$PRIMARY_DISPLAY" --brightness 1; i3lock' \
'' \
`# Finally, suspend an hour after it locks` \
--timer 3600 \
'systemctl suspend' \
''