diff --git a/home/david/configurations/Akun/niri.nix b/home/david/configurations/Akun/niri.nix
index 74ea5b8..8244cde 100644
--- a/home/david/configurations/Akun/niri.nix
+++ b/home/david/configurations/Akun/niri.nix
@@ -1,7 +1,14 @@
-{inputs, ...}: let
+{
+ config,
+ inputs,
+ ...
+}: let
inherit (inputs.niri-flake.lib.kdl) node leaf flag;
in {
david.programs.niri = {
+ waybar.settings = let
+ cfg = config.david.programs.niri.waybar;
+ in [(cfg.template // (cfg.mkBacklight "intel_backlight") // {output = "eDP-1";})];
wluma.extraSettings = {
output = {
backlight = [
diff --git a/home/david/configurations/Tytonidae/niri.nix b/home/david/configurations/Tytonidae/niri.nix
index f0eccf1..2dd8be3 100644
--- a/home/david/configurations/Tytonidae/niri.nix
+++ b/home/david/configurations/Tytonidae/niri.nix
@@ -1,7 +1,17 @@
-{inputs, ...}: let
+{
+ config,
+ inputs,
+ ...
+}: let
inherit (inputs.niri-flake.lib.kdl) node leaf flag;
in {
david.programs.niri = {
+ waybar.settings = let
+ cfg = config.david.programs.niri.waybar;
+ in [
+ (cfg.template // (cfg.helper.mkBacklight "ddcci13") // {output = "DP-3";})
+ (cfg.template // (cfg.helper.mkBacklight "nvidia_0") // {output = "eDP-1";})
+ ];
wluma.extraSettings = {
output = {
backlight = [
@@ -12,7 +22,7 @@ in {
}
{
name = "DP-3";
- path = "/sys/class/backlight/ddcci15";
+ path = "/sys/class/backlight/ddcci13";
capturer = "wayland";
}
];
diff --git a/home/david/modules/programs/niri/default.nix b/home/david/modules/programs/niri/default.nix
index dae9b6a..bd1a8c1 100644
--- a/home/david/modules/programs/niri/default.nix
+++ b/home/david/modules/programs/niri/default.nix
@@ -19,6 +19,21 @@ in {
wluma.extraSettings = lib.mkOption {
inherit (options.david.programs.wluma.extraSettings) type;
};
+ waybar = {
+ template = lib.mkOption {
+ readOnly = true;
+ type = lib.types.anything;
+ default = config.david.programs.waybar.template;
+ };
+ helper = lib.mkOption {
+ readOnly = true;
+ type = lib.types.anything;
+ default = config.david.programs.waybar.helper;
+ };
+ settings = lib.mkOption {
+ inherit (options.david.programs.waybar.settings) type;
+ };
+ };
};
};
config = lib.mkMerge [
@@ -65,7 +80,10 @@ in {
};
david.programs = {
fuzzel.enable = true;
- waybar.enable = true;
+ waybar = {
+ enable = true;
+ inherit (cfg.waybar) settings;
+ };
wluma = {
enable = true;
inherit (cfg.wluma) extraSettings;
diff --git a/home/david/modules/programs/waybar.nix b/home/david/modules/programs/waybar.nix
index 989dc0a..83301f2 100644
--- a/home/david/modules/programs/waybar.nix
+++ b/home/david/modules/programs/waybar.nix
@@ -2,6 +2,7 @@
pkgs,
config,
lib,
+ options,
...
}: let
cfg = config.david.programs.waybar;
@@ -9,6 +10,145 @@ in {
options = {
david.programs.waybar = {
enable = lib.mkEnableOption "waybar";
+ settings = lib.mkOption {
+ type = options.programs.waybar.settings.type;
+ };
+ template = lib.mkOption {
+ readOnly = true;
+ type = lib.types.anything;
+ default = {
+ layer = "top";
+ position = "top";
+ modules-left = [
+ "niri/workspaces"
+ "wlr/taskbar"
+ ];
+ modules-center = ["clock"];
+ modules-right = [
+ "tray"
+ "idle_inhibitor"
+ "memory"
+ "custom/backlight"
+ "pulseaudio"
+ "battery"
+ "custom/notification"
+ ];
+ "wlr/taskbar" = {
+ on-click = "activate";
+ };
+
+ "niri/worksapces" = {};
+ "niri/taskbar" = {
+ icon-size = 15;
+ on-click = "activate";
+ on-click-middle = "close";
+ };
+ "tray" = {
+ icon-size = 15;
+ spacing = 10;
+ };
+
+ idle_inhibitor = {
+ format = "{icon}";
+ format-icons = {
+ activated = " ";
+ deactivated = " ";
+ };
+ };
+
+ memory = {
+ format = " {percentage}%";
+ on-click = lib.getExe pkgs.resources;
+ };
+
+ pulseaudio = {
+ format = "{icon}{volume}%";
+ format-bluetooth = " {volume}%";
+ format-muted = " -%";
+ format-source = " {volume}%";
+ format-source-muted = " ";
+ format-icons = {
+ default = [
+ " "
+ " "
+ " "
+ ];
+ headphone = " ";
+ headset = " ";
+ hands-free = " ";
+ };
+ on-click = "${lib.getExe' pkgs.wireplumber "wpctl"} set-mute @DEFAULT_AUDIO_SINK@ toggle";
+ on-click-right = lib.getExe pkgs.pwvucontrol;
+ tooltip-format = "{icon}{desc} {volume}%";
+ };
+
+ battery = {
+ states = {
+ warning = 30;
+ critical = 15;
+ };
+ format = "{icon}{capacity}%";
+ format-charging = " {capacity}%";
+ format-icons = [
+ " "
+ " "
+ " "
+ " "
+ " "
+ ];
+ tooltip-format = ''
+ {power}W
+ {timeTo}'';
+ };
+
+ clock = {
+ format = "{:%a %b %d %R}";
+ calendar.format = {
+ months = "{}";
+ days = "{}";
+ weeks = "W{}";
+ weekdays = "{}";
+ today = "{}";
+ };
+ actions = {
+ on-scroll-up = "shift_up";
+ on-scroll-down = "shift_down";
+ };
+ tooltip-format = "{calendar}";
+ };
+ "custom/notification" = {
+ "tooltip" = false;
+ "format" = "{icon}";
+ "format-icons" = {
+ "notification" = "";
+ "none" = "";
+ "dnd-notification" = "";
+ "dnd-none" = "";
+ };
+ "return-type" = "json";
+ "exec" = "swaync-client -swb";
+ "on-click" = "swaync-client -t -sw";
+ "on-click-right" = "swaync-client -d -sw";
+ "escape" = true;
+ };
+ };
+ };
+ helper = lib.mkOption {
+ type = lib.types.anything;
+ readOnly = true;
+ default = {
+ mkBacklight = device: {
+ "custom/backlight" = {
+ format = "{icon}{}%";
+ interval = 2;
+ exec = "cat /sys/class/backlight/${device}/actual_brightness";
+ format-icons = " ";
+ on-scroll-up = "${lib.getExe pkgs.brightnessctl} -d ${device} set +1%";
+ on-scroll-down = "${lib.getExe pkgs.brightnessctl} -d ${device} set 1%-";
+ };
+ };
+ };
+ };
};
};
config = lib.mkMerge [
@@ -16,130 +156,7 @@ in {
programs.waybar = {
enable = true;
systemd.enable = false;
- settings = [
- {
- layer = "top";
- position = "top";
- modules-left = [
- "niri/workspaces"
- "wlr/taskbar"
- ];
- modules-center = ["clock"];
- modules-right = [
- "tray"
- "idle_inhibitor"
- "memory"
- "backlight"
- "pulseaudio"
- "battery"
- "custom/notification"
- ];
- "wlr/taskbar" = {
- on-click = "activate";
- };
-
- "niri/worksapces" = {};
- "niri/taskbar" = {
- icon-size = 15;
- on-click = "activate";
- on-click-middle = "close";
- };
- "tray" = {
- icon-size = 15;
- spacing = 10;
- };
-
- idle_inhibitor = {
- format = "{icon}";
- format-icons = {
- activated = " ";
- deactivated = " ";
- };
- };
-
- memory = {
- format = " {percentage}%";
- on-click = lib.getExe pkgs.resources;
- };
- backlight = {
- format = "{icon}{percent}%";
- format-icons = " ";
- on-scroll-up = "${lib.getExe pkgs.brightnessctl} set +1%";
- on-scroll-down = "${lib.getExe pkgs.brightnessctl} set 1%-";
- };
-
- pulseaudio = {
- format = "{icon}{volume}%";
- format-bluetooth = " {volume}%";
- format-muted = " -%";
- format-source = " {volume}%";
- format-source-muted = " ";
- format-icons = {
- default = [
- " "
- " "
- " "
- ];
- headphone = " ";
- headset = " ";
- hands-free = " ";
- };
- on-click = "${lib.getExe' pkgs.wireplumber "wpctl"} set-mute @DEFAULT_AUDIO_SINK@ toggle";
- on-click-right = lib.getExe pkgs.pwvucontrol;
- tooltip-format = "{icon}{desc} {volume}%";
- };
-
- battery = {
- states = {
- warning = 30;
- critical = 15;
- };
- format = "{icon}{capacity}%";
- format-charging = " {capacity}%";
- format-icons = [
- " "
- " "
- " "
- " "
- " "
- ];
- tooltip-format = ''
- {power}W
- {timeTo}'';
- };
-
- clock = {
- format = "{:%a %b %d %R}";
- calendar.format = {
- months = "{}";
- days = "{}";
- weeks = "W{}";
- weekdays = "{}";
- today = "{}";
- };
- actions = {
- on-scroll-up = "shift_up";
- on-scroll-down = "shift_down";
- };
- tooltip-format = "{calendar}";
- };
- "custom/notification" = {
- "tooltip" = false;
- "format" = "{icon}";
- "format-icons" = {
- "notification" = "";
- "none" = "";
- "dnd-notification" = "";
- "dnd-none" = "";
- };
- "return-type" = "json";
- "exec" = "swaync-client -swb";
- "on-click" = "swaync-client -t -sw";
- "on-click-right" = "swaync-client -d -sw";
- "escape" = true;
- };
- }
- ];
+ settings = cfg.settings;
style = ''
* {
font-family: Libertinus Serif, Source Han Serif;
@@ -160,7 +177,7 @@ in {
#tray,
#mpris,
#idle_inhibitor,
- #backlight,
+ #custom-backlight,
#cpu,
#memory,
#pulseaudio,