feat(hyprlua): tighten lid-lock, idle timer, and add caffeine eww widget

- caffeine: inhibit only `idle`, not `sleep`, so lid close still locks
- binds: lid-close unconditionally calls hyprlock; lid-open does dpms on
- hypridle: reduce lock timeout from 3 min to 2.5 min (150 s)
- eww (all 3 variants): add caffeine toggle button (/󰅺) with tooltip

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
Amir Alexander Abdelbaki 2026-06-19 11:15:23 +02:00
parent 88f3b72343
commit 49ece6a238
7 changed files with 39 additions and 5 deletions

View File

@ -38,6 +38,7 @@
:value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)}
:onchange ""
:onclick ""))
(caffeine)
(clock)
(systray :class "music" :orientation "h" :spacing 2 :space-evenly true)
))
@ -112,3 +113,12 @@
(defpoll disks :interval "600s"
"~/Dotfiles/desktopenvs/hyprland/scripts/dysk-phydisks.sh")
(defpoll caffeine-active :interval "2s"
"~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine-status.sh")
(defwidget caffeine []
(button :class "music"
:onclick "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine.sh"
:tooltip {caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"}
{caffeine-active == "true" ? "☕" : "󰅺"}))

View File

@ -37,6 +37,7 @@
(defwidget sidestuff []
(box :class "sidestuff" :orientation "h" :space-evenly false :halign "end"
(caffeine)
(clock)
(systray :class "music" :orientation "h" :spacing 2 :space-evenly true)
))
@ -159,3 +160,13 @@
(defpoll calender :interval "600s"
"~/Dotfiles/desktopenvs/hyprland/scripts/calender-fix.sh")
(defpoll caffeine-active :interval "2s"
"~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine-status.sh")
(defwidget caffeine []
(button :class "music"
:onclick "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine.sh"
:tooltip {caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"}
{caffeine-active == "true" ? "☕" : "󰅺"}))

View File

@ -44,6 +44,7 @@
:onchange ""
:onclick ""))
(caffeine)
(clock)
(systray :class "music" :orientation "h" :spacing 2 :space-evenly true)
))
@ -117,3 +118,12 @@
(defpoll disks :interval "600s"
"~/Dotfiles/desktopenvs/hyprland/scripts/dysk-phydisks.sh")
(defpoll caffeine-active :interval "2s"
"~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine-status.sh")
(defwidget caffeine []
(button :class "music"
:onclick "~/Dotfiles/desktopenvs/hyprlua/scripts/caffeine.sh"
:tooltip {caffeine-active == "true" ? "Caffeine: ON" : "Caffeine: OFF"}
{caffeine-active == "true" ? "☕" : "󰅺"}))

View File

@ -9,7 +9,7 @@ general {
# Presence detection resets the idle timer every 2 minutes while you're visible,
# so these timeouts only run when you've actually stepped away.
listener {
timeout = 180 # 3 min — lock screen
timeout = 150 # 2.5 min — lock screen
on-timeout = loginctl lock-session
}

View File

@ -12,8 +12,8 @@ local winswitch = "" -- TODO: define your window switcher command
---- LID SWITCH ----
--------------------
hl.bind("switch:on:Lid Switch", hl.dsp.exec_cmd("bash -c 'pidof hypridle > /dev/null && hyprlock'"), { locked = true })
hl.bind("switch:off:Lid Switch", hl.dsp.exec_cmd("hyprctl dispatch exec hyprlock"), { locked = true })
hl.bind("switch:on:Lid Switch", hl.dsp.exec_cmd("hyprlock"), { locked = true })
hl.bind("switch:off:Lid Switch", hl.dsp.exec_cmd("hyprctl dispatch dpms on"), { locked = true })
--------------------
---- GESTURES ------

View File

@ -0,0 +1,3 @@
#!/bin/bash
PID_FILE="/tmp/caffeine-inhibit.pid"
[[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null && echo "true" || echo "false"

View File

@ -7,7 +7,7 @@ if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
rm -f "$PID_FILE"
notify-send -t 2000 "Caffeine" "Idle inhibit OFF"
else
systemd-inhibit --what=idle:sleep \
systemd-inhibit --what=idle \
--who="caffeine" \
--why="Caffeine mode active" \
--mode=block \