sxmo: conky: include battery estimate
This commit is contained in:
parent
29bf9d410f
commit
67a52eca86
31
hosts/modules/gui/sxmo/battery_estimate
Executable file
31
hosts/modules/gui/sxmo/battery_estimate
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash
|
||||||
|
|
||||||
|
full=$(cat /sys/class/power_supply/axp20x-battery/charge_full_design)
|
||||||
|
rate=$(cat /sys/class/power_supply/axp20x-battery/current_now)
|
||||||
|
perc=$(cat /sys/class/power_supply/axp20x-battery/capacity)
|
||||||
|
perc_left=$((100 - $perc))
|
||||||
|
# these icons come from sxmo; they only render in nerdfonts
|
||||||
|
bat_dis=""
|
||||||
|
bat_chg=""
|
||||||
|
|
||||||
|
fmt_minutes() {
|
||||||
|
if [[ $2 -gt 1440 ]]; then
|
||||||
|
echo "∞" # more than 1d
|
||||||
|
else
|
||||||
|
hr=$(($2 / 60))
|
||||||
|
hr_in_min=$(($hr * 60))
|
||||||
|
min=$(($2 - $hr_in_min))
|
||||||
|
echo "$1 ${hr}h${min}m"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $rate -lt 0 ]]; then
|
||||||
|
# discharging
|
||||||
|
fmt_minutes "$bat_dis" $(($full * 60 * $perc / (-100 * $rate)))
|
||||||
|
elif [[ $rate -gt 0 ]]; then
|
||||||
|
# charging
|
||||||
|
fmt_minutes "$bat_chg" $(($full * 60 * $perc_left / (100 * $rate)))
|
||||||
|
else
|
||||||
|
echo " N/A"
|
||||||
|
fi
|
|
@ -17,7 +17,7 @@ ${alignc}${font Sxmo:size=50:style=Bold}${exec date +"%H"}${font Sxmo:size=50}:$
|
||||||
${font Sxmo:size=20}${exec date +"%a %d %b %Y"}${font}
|
${font Sxmo:size=20}${exec date +"%a %d %b %Y"}${font}
|
||||||
|
|
||||||
${alignc}${font Sxmo:size=15}${color lightgrey}☵ $memperc%${font}
|
${alignc}${font Sxmo:size=15}${color lightgrey}☵ $memperc%${font}
|
||||||
${alignc}${font Sxmo:size=15}${color lightgrey} $cpu%${font}
|
${alignc}${font Sxmo:size=15}${color lightgrey} $cpu%${font}
|
||||||
${alignc}${font Sxmo:size=15}${color lightgrey}⇅ ${downspeedf wlan0}K/s${font}
|
${alignc}${font Sxmo:size=15}${color lightgrey}⇅ ${downspeedf wlan0}K/s${font}
|
||||||
${alignc}${font Sxmo:size=15}${color lightgrey} ${exec echo $(( $(cat /sys/class/power_supply/axp20x-battery/charge_full_design) * -60 / $(cat /sys/class/power_supply/axp20x-battery/current_now) )) }m${font}
|
${alignc}${font Sxmo:size=15}${color lightgrey}${exec @bat@ }${font}
|
||||||
]]
|
]]
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
# - gestures: lisgd
|
# - gestures: lisgd
|
||||||
# - on-screen keyboard: wvkbd (if wayland), svkbd (if X)
|
# - on-screen keyboard: wvkbd (if wayland), svkbd (if X)
|
||||||
#
|
#
|
||||||
{ lib, config, pkgs, sane-lib, ... }:
|
{ config, lib, pkgs, sane-lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.sane.gui.sxmo;
|
cfg = config.sane.gui.sxmo;
|
||||||
|
@ -217,8 +217,15 @@ in
|
||||||
# sane.user.fs.".config/waybar/style.css".symlink.text =
|
# sane.user.fs.".config/waybar/style.css".symlink.text =
|
||||||
# builtins.readFile ./waybar-style.css;
|
# builtins.readFile ./waybar-style.css;
|
||||||
|
|
||||||
sane.user.fs.".config/sxmo/conky.conf".symlink.target =
|
sane.user.fs.".config/sxmo/conky.conf".symlink.target = let
|
||||||
builtins.readFile ./conky-config;
|
battery_estimate = pkgs.static-nix-shell.mkBash {
|
||||||
|
pname = "battery_estimate";
|
||||||
|
src = ./.;
|
||||||
|
};
|
||||||
|
in pkgs.substituteAll {
|
||||||
|
src = ./conky-config;
|
||||||
|
bat = "${battery_estimate}/bin/battery_estimate";
|
||||||
|
};
|
||||||
|
|
||||||
## greeter
|
## greeter
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user