diff --git a/machines/liadtop/configuration.nix b/machines/liadtop/configuration.nix index 82f7a8f..d2c598d 100644 --- a/machines/liadtop/configuration.nix +++ b/machines/liadtop/configuration.nix @@ -23,6 +23,10 @@ rec { }; myHardware = { + battery = { + enable = true; + chargeUpperLimit = 80; + }; bluetooth.enable = true; sound.enable = true; }; @@ -202,7 +206,6 @@ rec { }; awesome = { enable = true; - showBattery = true; singleScreen = true; }; caffeine.enable = true; diff --git a/modules/apps/btop/default.nix b/modules/apps/btop/default.nix index 2eff223..e2c6ebd 100644 --- a/modules/apps/btop/default.nix +++ b/modules/apps/btop/default.nix @@ -13,6 +13,11 @@ in enable = lib.mkEnableOption "btop" // { default = true; }; + showBattery = lib.mkOption { + type = lib.types.bool; + description = "Show battery indicator."; + default = false; + }; }; config = lib.mkIf cfg.enable { @@ -39,9 +44,9 @@ in clock_format = "%X"; base_10_sizes = false; background_update = true; - show_battery = true; + show_battery = cfg.showBattery; selected_battery = "Auto"; - show_battery_watts = true; + show_battery_watts = cfg.showBattery; log_level = "WARNING"; # cpu diff --git a/modules/hardware/zenbook-14.nix b/modules/hardware/zenbook-14.nix index 1d22484..ad668b1 100644 --- a/modules/hardware/zenbook-14.nix +++ b/modules/hardware/zenbook-14.nix @@ -29,8 +29,9 @@ # power services.logind = { - extraConfig = "HandlePowerKey=suspend"; lidSwitch = "suspend"; + powerKey = "suspend"; + powerKeyLongPress = "poweroff"; }; # sound diff --git a/modules/system/hardware/battery.nix b/modules/system/hardware/battery.nix new file mode 100644 index 0000000..e5ba8ef --- /dev/null +++ b/modules/system/hardware/battery.nix @@ -0,0 +1,30 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.myHardware.battery; +in +{ + options.myHardware.battery = { + enable = lib.mkEnableOption "battery"; + chargeUpperLimit = lib.mkOption { + type = lib.types.int; + description = "Upper percentage limit to which battery will be charged."; + default = 100; + }; + }; + + config = lib.mkIf cfg.enable { + services.udev.extraRules = '' + ACTION=="add", KERNEL=="asus-nb-wmi", RUN+="${pkgs.bash}/bin/bash -c 'echo ${builtins.toString cfg.chargeUpperLimit} > /sys/class/power_supply/BAT?/charge_control_end_threshold'" + ''; + + home-manager.users."${config.mySystem.primaryUser}".myHomeApps = { + awesome.showBattery = true; + btop.showBattery = true; + }; + }; +} diff --git a/modules/system/hardware/default.nix b/modules/system/hardware/default.nix index 4712c8e..f3cbc94 100644 --- a/modules/system/hardware/default.nix +++ b/modules/system/hardware/default.nix @@ -1,5 +1,6 @@ _: { imports = [ + ./battery.nix ./bluetooth.nix ./nvidia.nix ./openrgb.nix