Closed KomaDi closed 1 month ago
Run a script that checks whether you're on battery, and only suspends if that's the case.
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.
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
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`
I have a laptop and want to have suspend only on battery. Is it even possible?