hyprwm / hypridle

Hyprland's idle daemon
BSD 3-Clause "New" or "Revised" License
320 stars 16 forks source link

[Question] Can i somehow setup hypridle to suspend on battery, but not on charge? #66

Closed KomaDi closed 1 month ago

KomaDi commented 1 month ago

I have a laptop and want to have suspend only on battery. Is it even possible?

fufexan commented 1 month ago

Run a script that checks whether you're on battery, and only suspends if that's the case.

KomaDi commented 1 month ago

Run a script that checks whether you're on battery, and only suspends if that's the case.

How do i create that script? I'm newbie in linux and actually don't know how to manage sh scripts.

KomaDi commented 1 month ago

Okay, i made a sh file but i don't know how to activate this for hypridle

`ac_adapter="$(cat /sys/class/power_supply/ACAD/online)"

if [[ ac_adapter -eq 0 ]];

then

notify-send -u low "Amogus"

fi` P.S. notify-send is just for test

KomaDi commented 1 month ago

Ok, i made it and it's work perfectly. If anyone need this i just leave code here.

`#!/bin/bash

ac_adapter=0 mode=$(cat /sys/class/power_supply/ACAD/online)

while :; do ac_adapter=$(cat /sys/class/power_supply/ACAD/online) if [[ $ac_adapter -eq 0 ]] && [[ $mode -eq 0 ]]; then pkill hypridle hypridle -c ~/.config/hypr/hypridle.conf &>/dev/null & mode=1 elif [[ $ac_adapter -eq 1 ]] && [[ $mode -eq 1 ]]; then pkill hypridle hypridle -c ~/.config/hypr/hypridle2.conf &>/dev/null & mode=0 fi sleep 5 done`