add: eww
This commit is contained in:
parent
659b7407d5
commit
ccffa13eb2
3 changed files with 57 additions and 35 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
../standard
|
../standard
|
||||||
../standard/wayland
|
../standard/wayland
|
||||||
../music
|
../music
|
||||||
|
../standard/wayland/eww
|
||||||
|
|
||||||
./tty-init.nix
|
./tty-init.nix
|
||||||
./binds.nix
|
./binds.nix
|
||||||
|
|
|
||||||
12
home/ooks/opt/desktop/standard/wayland/eww/default.nix
Normal file
12
home/ooks/opt/desktop/standard/wayland/eww/default.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{ pkgs, config, ... }:
|
||||||
|
{
|
||||||
|
programs.eww = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.eww-wayland;
|
||||||
|
configDir = ./config;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,51 +1,60 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
# Regularly check the battery status and send a notification when it discharges
|
||||||
|
# below certain thresholds.
|
||||||
|
# Implemented by calling the `acpi` program regularly. This is the simpler and
|
||||||
|
# safer approach because the battery might not send discharging events.
|
||||||
|
# author: github:Julow
|
||||||
|
|
||||||
|
let conf = config.modules.battery-notify;
|
||||||
|
|
||||||
let
|
|
||||||
conf = config.modules.battery-notify;
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
options.modules.battery-notify = with lib; {
|
options.modules.battery-notify = with lib; {
|
||||||
enable = mkEnableOption "battery-notify";
|
enable = mkEnableOption "battery-notify";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf conf.enable {
|
config = lib.mkIf conf.enable {
|
||||||
|
# Regularly check battery status
|
||||||
systemd.user.services.battery-notify = {
|
systemd.user.services.battery-notify = {
|
||||||
wantedBy = [ "graphical-session.target" ];
|
wantedBy = [ "graphical-session.target" ];
|
||||||
script = ''
|
script = ''
|
||||||
|
prev_val=100
|
||||||
batval=$(cat /sys/class/power_supply/BAT0/capacity)
|
check () { [[ $1 -ge $val ]] && [[ $1 -lt $prev_val ]]; }
|
||||||
tempbatval="/tmp/bat_val_$batval"
|
get_battery_glyph() {
|
||||||
|
local val="$1"
|
||||||
if [ ! -f "$tempbatval" ]; then
|
if [[ "$val" -le 10 ]]; then
|
||||||
case "$batval" in
|
echo "" # or echo -e "\uf244" if using the Unicode code
|
||||||
75|50|25|10|5)
|
elif [[ "$val" -le 25 ]]; then
|
||||||
${pkgs.libnotify}/bin/notify-send -a bat-notify "battery:" "$batval"
|
echo ""
|
||||||
touch "tempbatval"
|
elif [[ "$val" -le 50 ]]; then
|
||||||
;;
|
echo ""
|
||||||
esac
|
elif [[ "$val" -le 75 ]]; then
|
||||||
fi
|
echo ""
|
||||||
|
else
|
||||||
for level in 75 50 25 10 5; do
|
echo ""
|
||||||
if [ "$batval" -gt "$level" ]; then
|
|
||||||
rm -f "/tmp/bat_val_$level"
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
notify () {
|
||||||
|
glyph=$(get_battery_glyph $val)
|
||||||
|
${pkgs.libnotify}/bin/notify-send -a bat-notify "$glyph $val%"
|
||||||
|
}
|
||||||
|
while true; do
|
||||||
|
IFS=: read _ bat0 < <(${pkgs.acpi}/bin/acpi -b)
|
||||||
|
IFS=\ , read status val remaining <<<"$bat0"
|
||||||
|
val=''${val%\%}
|
||||||
|
if [[ $status = Discharging ]]; then
|
||||||
|
echo "$val%, $remaining"
|
||||||
|
if check 75 || check 50 ||check 30 || check 25 || check 20; then notify
|
||||||
|
elif check 15 || [[ $val -le 10 ]]; then notify -u critical
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
prev_val=$val
|
||||||
|
# Sleep longer when battery is high to save CPU
|
||||||
|
if [[ $val -gt 30 ]]; then sleep 10m; elif [[ $val -ge 20 ]]; then sleep 5m; else sleep 1m; fi
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
systemd.user.timers.battery-notify = {
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
after = [ "basic.target" ];
|
|
||||||
requires = [ "battery-notify.service" ];
|
|
||||||
partOf = [ "battery-notify.service" ];
|
|
||||||
timerConfig = {
|
|
||||||
OnBootSec = "1m";
|
|
||||||
OnUnitActiveSec = "1m";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue