I’ve been using i3 for a while now, but the xfce power manager doesn’t work outside the desktop environment, is there any alternative you can recommend? It doesn’t matter if it is a terminal based or graphical interface program, I just need something that can suspend the computer after a certain time or lock it when the laptop is closed

  • gnuhaut@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    5 months ago

    I use tlp.

    I also have a battery info using i3status in the status bar, and a script I named battery-check, which warns me via a dunst popup and a beep when the battery gets low:

    #!/bin/sh
    set -eu
    
    bat=/sys/class/power_supply/BAT0
    
    if [ ! -d "$bat" ]; then
        exit 1;
    fi
    
    status=$(cat "$bat/status")
    energy_now=$(cat "$bat/energy_now")
    energy_full=$(cat "$bat/energy_full")
    
    battery_percent=$(( ${energy_now}00 / ${energy_full} ))
    
    if [ "$status" != "Charging" -a "$battery_percent" -le 15 ]; then
        dunstify -t 8000 -u critical "Battery at ${battery_percent}%"
        play -q -n -c1 synth 2 sine 600
    fi
    

    I run this from my ~/.config/sway/config like so:

    exec sh -c 'while true; do sleep 180; battery-check || break; done'