battery low notification timer
This commit is contained in:
parent
a65b2ca9a8
commit
a0a0ced225
35
profiles/desktop/battery-low-timer.nix
Normal file
35
profiles/desktop/battery-low-timer.nix
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
systemd.services.battery-low = {
|
||||||
|
serviceConfig.Type = "simple";
|
||||||
|
path = [
|
||||||
|
pkgs.acpi
|
||||||
|
];
|
||||||
|
startAt = "*08:00:00";
|
||||||
|
script = ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
if [ `acpi -b | grep "Battery 2" | awk ' { print ($3)}'` == "Discharging," ] ; then
|
||||||
|
# Discharging
|
||||||
|
# Monitor for low battery
|
||||||
|
if [ `acpi -b | grep "Battery 2" | awk ' { print ($4)-0}'` -le "15" ] ; then
|
||||||
|
notify-send "Battery Low";
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Charging
|
||||||
|
if [ `acpi -b | grep "Battery 2" | awk ' { print ($4)-0}'` -ge "98" ] ; then
|
||||||
|
# Fully charged
|
||||||
|
notify-send "Battery Full"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
User = "anish";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
systemd.timers.battery-low = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
partOf = [ "battery-low.service" ];
|
||||||
|
timerConfig.OnCalendar = [ "*:0/5" ];
|
||||||
|
};
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# TODO modularize
|
# TODO modularize
|
||||||
#imports = [ ./xdg.nix ];
|
imports = [ ./battery-low-timer.nix ];
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
gnome.gnome-keyring.enable = true;
|
gnome.gnome-keyring.enable = true;
|
||||||
|
@ -150,6 +150,24 @@ in
|
||||||
}
|
}
|
||||||
|
|
||||||
xrandr | grep "HDMI-2 connected" &>>/dev/null && connect || disconnect
|
xrandr | grep "HDMI-2 connected" &>>/dev/null && connect || disconnect
|
||||||
|
|
||||||
|
# keyboard on curve is busted
|
||||||
|
get_keyboard_id() {
|
||||||
|
xinput list | grep 'AT Translated Set' | cut -f2 | cut -d'=' -f2 | xinput float
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect_keyboard() {
|
||||||
|
id=$(get_keyboard_id)
|
||||||
|
xinput float $id
|
||||||
|
unset id
|
||||||
|
}
|
||||||
|
|
||||||
|
attach_keyboard() {
|
||||||
|
id=$(get_keyboard_id)
|
||||||
|
xinput reattach $id 3
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect_keyboard
|
||||||
'';
|
'';
|
||||||
lightdm.enable = true;
|
lightdm.enable = true;
|
||||||
lightdm.greeters.mini.enable = true;
|
lightdm.greeters.mini.enable = true;
|
||||||
|
|
Loading…
Reference in a new issue