1
0
forked from extern/nix-config

waybar: Move modules to separate attribute set

Makes it possible to use the same modules in multiple bars.
This commit is contained in:
Donovan Glover 2023-06-29 09:58:23 -04:00
parent bc6f862279
commit c143c065a2
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -6,13 +6,90 @@ let
position = "top";
opposite = builtins.replaceStrings ["left" "right" "top" "bottom"] ["right" "left" "bottom" "top"] position;
isVertical = position == "left" || position == "right";
modules = {
tray = {
icon-size = 24;
spacing = 8;
};
"wlr/taskbar" = {
icon-size = 32;
on-click = "activate";
on-click-middle = "activate";
on-click-right = "activate";
};
"hyprland/window" = {
rotate = if isVertical then 90 else 0;
};
"wlr/workspaces" = {
on-click = "activate";
sort-by-number = true;
format = "{icon}";
format-icons = {
"1" = "";
"2" = "";
"3" = "";
"4" = "";
"5" = "";
"6" = "";
"7" = "";
"8" = "";
"9" = "";
"10" = "";
};
};
wireplumber = {
format = "{icon}";
tooltip-format = "{volume}% {node_name}";
format-muted = "";
format-icons = [ "" "" ];
};
battery = {
format = "{icon}";
tooltip-format = "{capacity}% {timeTo}";
format-icons = [ "" "" "" "" "" ];
};
clock = {
format = if isVertical then "{:%H\n%M}" else "{:%H:%M}";
tooltip-format = "<tt>{calendar}</tt>";
calendar = {
mode = "month";
weeks-pos = "right";
format = {
months = "<span color='#ffead3'><b>{}</b></span>";
days = "<span color='#ecc6d9'><b>{}</b></span>";
weeks = "<span size='14pt' color='#99ffdd'><b>W{}</b></span>";
weekdays = "<span size='18pt' color='#ffcc66'><b>{}</b></span>";
today = "<span color='#ff6699'><b>{}</b></span>";
};
};
};
backlight = {
format = "{icon}";
format-icons = [ "" "" ];
};
"custom/new-workspace" = {
format = "+";
on-click = "hyprctl dispatch workspace empty && sleep 0.1 && rofi -show drun";
on-click-right = "sleep 0.1 && rofi -show drun";
on-click-middle = "hyprctl dispatch workspace empty";
tooltip = false;
};
};
in
{
programs.waybar = {
enable = true;
settings = {
mainBar = {
mainBar = modules // {
layer = "top";
position = position;
width = if isVertical then 45 else null;
@ -25,82 +102,6 @@ in
modules-left = if icons then [ "wlr/taskbar" ] else [ "wlr/workspaces" "custom/new-workspace" ];
modules-right = [ "tray" "wireplumber" "backlight" "battery" "clock" ];
tray = {
icon-size = 24;
spacing = 8;
};
"wlr/taskbar" = {
icon-size = 32;
on-click = "activate";
on-click-middle = "activate";
on-click-right = "activate";
};
"hyprland/window" = {
rotate = if isVertical then 90 else 0;
};
"wlr/workspaces" = {
on-click = "activate";
sort-by-number = true;
format = "{icon}";
format-icons = {
"1" = "";
"2" = "";
"3" = "";
"4" = "";
"5" = "";
"6" = "";
"7" = "";
"8" = "";
"9" = "";
"10" = "";
};
};
wireplumber = {
format = "{icon}";
tooltip-format = "{volume}% {node_name}";
format-muted = "";
format-icons = [ "" "" ];
};
battery = {
format = "{icon}";
tooltip-format = "{capacity}% {timeTo}";
format-icons = [ "" "" "" "" "" ];
};
clock = {
format = if isVertical then "{:%H\n%M}" else "{:%H:%M}";
tooltip-format = "<tt>{calendar}</tt>";
calendar = {
mode = "month";
weeks-pos = "right";
format = {
months = "<span color='#ffead3'><b>{}</b></span>";
days = "<span color='#ecc6d9'><b>{}</b></span>";
weeks = "<span size='14pt' color='#99ffdd'><b>W{}</b></span>";
weekdays = "<span size='18pt' color='#ffcc66'><b>{}</b></span>";
today = "<span color='#ff6699'><b>{}</b></span>";
};
};
};
backlight = {
format = "{icon}";
format-icons = [ "" "" ];
};
"custom/new-workspace" = {
format = "+";
on-click = "hyprctl dispatch workspace empty && sleep 0.1 && rofi -show drun";
on-click-right = "sleep 0.1 && rofi -show drun";
on-click-middle = "hyprctl dispatch workspace empty";
tooltip = false;
};
};
};