module(waybar): Refactor waybar module
This commit is contained in:
parent
90a5b36616
commit
6c4546df9c
4 changed files with 181 additions and 129 deletions
|
|
@ -1,7 +1,14 @@
|
||||||
{inputs, ...}: let
|
{
|
||||||
|
config,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
inherit (inputs.niri-flake.lib.kdl) node leaf flag;
|
inherit (inputs.niri-flake.lib.kdl) node leaf flag;
|
||||||
in {
|
in {
|
||||||
david.programs.niri = {
|
david.programs.niri = {
|
||||||
|
waybar.settings = let
|
||||||
|
cfg = config.david.programs.niri.waybar;
|
||||||
|
in [(cfg.template // (cfg.mkBacklight "intel_backlight") // {output = "eDP-1";})];
|
||||||
wluma.extraSettings = {
|
wluma.extraSettings = {
|
||||||
output = {
|
output = {
|
||||||
backlight = [
|
backlight = [
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,17 @@
|
||||||
{inputs, ...}: let
|
{
|
||||||
|
config,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
inherit (inputs.niri-flake.lib.kdl) node leaf flag;
|
inherit (inputs.niri-flake.lib.kdl) node leaf flag;
|
||||||
in {
|
in {
|
||||||
david.programs.niri = {
|
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 = {
|
wluma.extraSettings = {
|
||||||
output = {
|
output = {
|
||||||
backlight = [
|
backlight = [
|
||||||
|
|
@ -12,7 +22,7 @@ in {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "DP-3";
|
name = "DP-3";
|
||||||
path = "/sys/class/backlight/ddcci15";
|
path = "/sys/class/backlight/ddcci13";
|
||||||
capturer = "wayland";
|
capturer = "wayland";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,21 @@ in {
|
||||||
wluma.extraSettings = lib.mkOption {
|
wluma.extraSettings = lib.mkOption {
|
||||||
inherit (options.david.programs.wluma.extraSettings) type;
|
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 [
|
config = lib.mkMerge [
|
||||||
|
|
@ -65,7 +80,10 @@ in {
|
||||||
};
|
};
|
||||||
david.programs = {
|
david.programs = {
|
||||||
fuzzel.enable = true;
|
fuzzel.enable = true;
|
||||||
waybar.enable = true;
|
waybar = {
|
||||||
|
enable = true;
|
||||||
|
inherit (cfg.waybar) settings;
|
||||||
|
};
|
||||||
wluma = {
|
wluma = {
|
||||||
enable = true;
|
enable = true;
|
||||||
inherit (cfg.wluma) extraSettings;
|
inherit (cfg.wluma) extraSettings;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
options,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
cfg = config.david.programs.waybar;
|
cfg = config.david.programs.waybar;
|
||||||
|
|
@ -9,15 +10,13 @@ in {
|
||||||
options = {
|
options = {
|
||||||
david.programs.waybar = {
|
david.programs.waybar = {
|
||||||
enable = lib.mkEnableOption "waybar";
|
enable = lib.mkEnableOption "waybar";
|
||||||
|
settings = lib.mkOption {
|
||||||
|
type = options.programs.waybar.settings.type;
|
||||||
};
|
};
|
||||||
};
|
template = lib.mkOption {
|
||||||
config = lib.mkMerge [
|
readOnly = true;
|
||||||
(lib.mkIf cfg.enable {
|
type = lib.types.anything;
|
||||||
programs.waybar = {
|
default = {
|
||||||
enable = true;
|
|
||||||
systemd.enable = false;
|
|
||||||
settings = [
|
|
||||||
{
|
|
||||||
layer = "top";
|
layer = "top";
|
||||||
position = "top";
|
position = "top";
|
||||||
modules-left = [
|
modules-left = [
|
||||||
|
|
@ -29,7 +28,7 @@ in {
|
||||||
"tray"
|
"tray"
|
||||||
"idle_inhibitor"
|
"idle_inhibitor"
|
||||||
"memory"
|
"memory"
|
||||||
"backlight"
|
"custom/backlight"
|
||||||
"pulseaudio"
|
"pulseaudio"
|
||||||
"battery"
|
"battery"
|
||||||
"custom/notification"
|
"custom/notification"
|
||||||
|
|
@ -61,12 +60,6 @@ in {
|
||||||
format = " {percentage}%";
|
format = " {percentage}%";
|
||||||
on-click = lib.getExe pkgs.resources;
|
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 = {
|
pulseaudio = {
|
||||||
format = "{icon}{volume}%";
|
format = "{icon}{volume}%";
|
||||||
|
|
@ -138,8 +131,32 @@ in {
|
||||||
"on-click-right" = "swaync-client -d -sw";
|
"on-click-right" = "swaync-client -d -sw";
|
||||||
"escape" = true;
|
"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 [
|
||||||
|
(lib.mkIf cfg.enable {
|
||||||
|
programs.waybar = {
|
||||||
|
enable = true;
|
||||||
|
systemd.enable = false;
|
||||||
|
settings = cfg.settings;
|
||||||
style = ''
|
style = ''
|
||||||
* {
|
* {
|
||||||
font-family: Libertinus Serif, Source Han Serif;
|
font-family: Libertinus Serif, Source Han Serif;
|
||||||
|
|
@ -160,7 +177,7 @@ in {
|
||||||
#tray,
|
#tray,
|
||||||
#mpris,
|
#mpris,
|
||||||
#idle_inhibitor,
|
#idle_inhibitor,
|
||||||
#backlight,
|
#custom-backlight,
|
||||||
#cpu,
|
#cpu,
|
||||||
#memory,
|
#memory,
|
||||||
#pulseaudio,
|
#pulseaudio,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue