diff --git a/profiles/desktop/battery-low-timer.nix b/profiles/desktop/battery-low-timer.nix new file mode 100644 index 00000000..c4110280 --- /dev/null +++ b/profiles/desktop/battery-low-timer.nix @@ -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" ]; + }; +} diff --git a/profiles/desktop/default.nix b/profiles/desktop/default.nix index 4de11673..70b8b33f 100644 --- a/profiles/desktop/default.nix +++ b/profiles/desktop/default.nix @@ -9,7 +9,7 @@ let in { # TODO modularize - #imports = [ ./xdg.nix ]; + imports = [ ./battery-low-timer.nix ]; services = { gnome.gnome-keyring.enable = true; @@ -150,6 +150,24 @@ in } 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.greeters.mini.enable = true;