From d286a7eac9fa02c72d2b4084188523c8c7fc62f7 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 22 Jun 2025 16:10:49 +0200 Subject: [PATCH] feat(ironbar): Add optional battery module --- flake.nix | 2 +- modules/programs/hypr/hyprland.nix | 2 +- modules/programs/ironbar.nix | 54 +++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 38a651e..b709627 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,7 @@ inputs = { unstable.url = "github:NixOs/nixpkgs/nixos-unstable"; - stable.url = "github:NixOs/nixpkgs/nixos-24.11"; + stable.url = "github:NixOs/nixpkgs/nixos-25.05"; nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; nur.url = "github:nix-community/NUR"; lanzaboote = { diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index 2a7d35e..65beb78 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -141,7 +141,7 @@ in { ''; }; filePickerPortal = lib.mkOption { - default = "gnome"; + default = "gtk"; example = "kde"; type = with lib.types; (enum ["gnome" "kde" "gtk" "disable"]); description = '' diff --git a/modules/programs/ironbar.nix b/modules/programs/ironbar.nix index 30427f6..ed3fa08 100644 --- a/modules/programs/ironbar.nix +++ b/modules/programs/ironbar.nix @@ -10,8 +10,14 @@ username = config.conf.username; base16 = pkgs.callPackage inputs.base16.lib {}; scheme = base16.mkSchemeAttrs config.stylix.base16Scheme; - ironbarDefaultConfig = { + ironbarDefaultConfig = useBatteryModule: { end = [ + (lib.mkIf useBatteryModule + { + type = "upower"; + class = "battery"; + icon_size = 0; + }) { class = "music"; type = "music"; @@ -176,10 +182,10 @@ } ]; }; - monitorConfig = + monitorConfig = useBatteryModule: if config.mods.hypr.hyprland.ironbarSingleMonitor - then {monitors.${config.mods.hypr.hyprland.defaultMonitor} = ironbarDefaultConfig;} - else ironbarDefaultConfig; + then {monitors.${config.mods.hypr.hyprland.defaultMonitor} = ironbarDefaultConfig useBatteryModule;} + else ironbarDefaultConfig useBatteryModule; in { options.mods = { ironbar = { @@ -197,6 +203,12 @@ in { Use preconfigured ironbar config. ''; }; + useBatteryModule = lib.mkOption { + default = false; + example = true; + type = lib.types.bool; + description = "Whether to use the preconfigured battery module."; + }; customConfig = lib.mkOption { default = {}; example = {}; @@ -398,6 +410,38 @@ in { color: @background; } + /* upower */ + .upower { + font-size: 13px; + padding: 0px 4px 0px 0px; + margin: 2px 0px 2px 0px; + background-color: @background; + color: @primary; + } + + .upower .icon { + opacity: 0.0; + } + + .upower .label { + margin: 2px 0px 0px -8px; + color: @primary; + } + + .upower:hover { + background-color: @secondary-background; + border-radius: 5px; + } + + .popup-upower { + background-color: @background; + color: @primary; + border-radius: 8px; + border: 1px solid @primary; + padding: 16px; + font-size: 20px; + } + /* music */ .music { font-size: 13px; @@ -473,7 +517,7 @@ in { then lib.mkMerge [ - monitorConfig + (monitorConfig config.mods.ironbar.useBatteryModule) config.mods.ironbar.customConfig ] else config.mods.ironbar.customConfig;