feat(ironbar): Add optional battery module

This commit is contained in:
DashieTM 2025-06-22 16:10:49 +02:00
parent db7e1c050b
commit d286a7eac9
3 changed files with 51 additions and 7 deletions

View file

@ -3,7 +3,7 @@
inputs = { inputs = {
unstable.url = "github:NixOs/nixpkgs/nixos-unstable"; 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"; nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
nur.url = "github:nix-community/NUR"; nur.url = "github:nix-community/NUR";
lanzaboote = { lanzaboote = {

View file

@ -141,7 +141,7 @@ in {
''; '';
}; };
filePickerPortal = lib.mkOption { filePickerPortal = lib.mkOption {
default = "gnome"; default = "gtk";
example = "kde"; example = "kde";
type = with lib.types; (enum ["gnome" "kde" "gtk" "disable"]); type = with lib.types; (enum ["gnome" "kde" "gtk" "disable"]);
description = '' description = ''

View file

@ -10,8 +10,14 @@
username = config.conf.username; username = config.conf.username;
base16 = pkgs.callPackage inputs.base16.lib {}; base16 = pkgs.callPackage inputs.base16.lib {};
scheme = base16.mkSchemeAttrs config.stylix.base16Scheme; scheme = base16.mkSchemeAttrs config.stylix.base16Scheme;
ironbarDefaultConfig = { ironbarDefaultConfig = useBatteryModule: {
end = [ end = [
(lib.mkIf useBatteryModule
{
type = "upower";
class = "battery";
icon_size = 0;
})
{ {
class = "music"; class = "music";
type = "music"; type = "music";
@ -176,10 +182,10 @@
} }
]; ];
}; };
monitorConfig = monitorConfig = useBatteryModule:
if config.mods.hypr.hyprland.ironbarSingleMonitor if config.mods.hypr.hyprland.ironbarSingleMonitor
then {monitors.${config.mods.hypr.hyprland.defaultMonitor} = ironbarDefaultConfig;} then {monitors.${config.mods.hypr.hyprland.defaultMonitor} = ironbarDefaultConfig useBatteryModule;}
else ironbarDefaultConfig; else ironbarDefaultConfig useBatteryModule;
in { in {
options.mods = { options.mods = {
ironbar = { ironbar = {
@ -197,6 +203,12 @@ in {
Use preconfigured ironbar config. 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 { customConfig = lib.mkOption {
default = {}; default = {};
example = {}; example = {};
@ -398,6 +410,38 @@ in {
color: @background; 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 */
.music { .music {
font-size: 13px; font-size: 13px;
@ -473,7 +517,7 @@ in {
then then
lib.mkMerge lib.mkMerge
[ [
monitorConfig (monitorConfig config.mods.ironbar.useBatteryModule)
config.mods.ironbar.customConfig config.mods.ironbar.customConfig
] ]
else config.mods.ironbar.customConfig; else config.mods.ironbar.customConfig;