Caffeine not working
Hi, I was trying to use the caffeine function in the dock, however when I click the button there is no action that shows me if it's activated or no.
https://github.com/user-attachments/assets/b3769267-8dca-40f4-a983-cb1bd4cb00ab
I also noticed this, I'm already searching for the error
6 minutes later...... It is probably because you don't have 'wlinhibit' installed (that was the case for me). 🤦♂️
For now, I use this partial solution just visually cuz the button it's not updated anyway:
- Make a script for toggle and notify about caffeine status:
#!/bin/bash
CAFFEINE_FILE="$HOME/.config/hypr/caffeine.enabled"
if [[ -f "$CAFFEINE_FILE" ]]; then
rm "$CAFFEINE_FILE"
notify-send "☕ Caffeine OFF"
else
touch "$CAFFEINE_FILE"
notify-send "☕ Caffeine ON"
fi
- Modify actual
hypridle.conffile (you can use the one that makes an overwrite, created by the author)
Reference:
general {
lock_cmd = pidof hyprlock || hyprlock
before_sleep_cmd = if [ ! -f "$HOME/.config/hypr/caffeine.enabled" ]; then loginctl lock-session; fi
after_sleep_cmd = hyprctl dispatch dpms on
}
listener {
timeout = 150
on-timeout = brightnessctl -s set 10
on-resume = brightnessctl -r
}
listener {
timeout = 300
on-timeout = if [ ! -f "$HOME/.config/hypr/caffeine.enabled" ]; then loginctl lock-session; fi
}
listener {
timeout = 330
on-timeout = if [ ! -f "$HOME/.config/hypr/caffeine.enabled" ]; then hyprctl dispatch dpms off; fi
on-resume = hyprctl dispatch dpms on
}
listener {
timeout = 1800
on-timeout = if [ ! -f "$HOME/.config/hypr/caffeine.enabled" ]; then systemctl suspend; fi
}
I just modified the original version:
general {
lock_cmd = pidof hyprlock || hyprlock # avoid starting multiple hyprlock instances.
before_sleep_cmd = loginctl lock-session # lock before suspend.
after_sleep_cmd = hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display.
}
listener {
timeout = 150 # 2.5min.
on-timeout = brightnessctl -s set 10 # set monitor backlight to minimum, avoid 0 on OLED monitor.
on-resume = brightnessctl -r # monitor backlight restore.
}
listener {
timeout = 300 # 5min
on-timeout = loginctl lock-session # lock screen when timeout has passed
}
listener {
timeout = 330 # 5.5min
on-timeout = hyprctl dispatch dpms off # screen off when timeout has passed
on-resume = hyprctl dispatch dpms on # screen on when activity is detected after timeout has fired.
}
listener {
timeout = 1800 # 30min
on-timeout = systemctl suspend # suspend pc
}
- (Optinal) Add ad keybind for use it more easily, in my case:
bind = $mainMod SHIFT, C, exec, sh -c '$HOME/ruta/al/toggle-caffeine.sh'
Preview:
6 minutes later...... It is probably because you don't have 'wlinhibit' installed (that was the case for me). 🤦♂️
Oh, I'll try, I just finished my partial solution when you updated your case
6 minutes later...... It is probably because you don't have 'wlinhibit' installed (that was the case for me). 🤦♂️
How did you install it? I'm having an error in yay I think that's the reason why the script for this config just skipped it
I am on Fedora, there it isnt even in the repo, so I just built it myself:
git clone https://github.com/0x5a4/wlinhibit.git
cd wlinhibit
meson setup build
cd build
meson install
Hi, indeed, you need wlinhibit. I'm glad to see that the button correctly checks for it instead of showing as activated when it's not.
Anyway, I'll try to replace wlinhibit today, but for now you could try to install the git version or the one precompiled from Chaotic AUR.
I am on Fedora, there it isnt even in the repo, so I just built it myself:
git clone https://github.com/0x5a4/wlinhibit.git cd wlinhibit meson setup build cd build meson install
Yessir, worked in my arch, tx
Hi, indeed, you need wlinhibit. I'm glad to see that the button correctly checks for it instead of showing as activated when it's not.
Anyway, I'll try to replace wlinhibit today, but for now you could try to install the git version or the one precompiled from Chaotic AUR.
Can I configure a keybind to activate caffeine in the dock and visualize the change as I did? I don't find where in the source code this button has an action or how
The button just runs wlinhibit, so you can just add a keybind in Hyprland for this:
pgrep wlinhibit && pkill wlinhibit || wlinhibit &
Though it won't update the button, because the button updates on start and on click. I'll add something to trigger it.
Alright, bind this:
fabric-cli exec ax-shell 'notch.dashboard.widgets.buttons.caffeine_button.toggle_wlinhibit()'
@Deivis44 I added a shortcut for Caffeine. Just update and reapply the config. :)