Waybar : Refactor config.

This commit is contained in:
Dmitry Voronin 2024-06-23 00:14:13 +03:00
parent a4c027fbb3
commit 2ed0b8ba85
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
5 changed files with 143 additions and 142 deletions

View file

@ -22,7 +22,7 @@
experimental-features = nix-command flakes experimental-features = nix-command flakes
keep-derivations = true keep-derivations = true
keep-outputs = true keep-outputs = true
min-free = ${toString 50 * 1000 * 1000 * 1000} min-free = ${toString (50 * 1000 * 1000 * 1000)}
''; '';
# NOTE: Currently I run GC completely, but this setting (put above near min-free) # NOTE: Currently I run GC completely, but this setting (put above near min-free)

View file

@ -4,7 +4,7 @@ in {
programs.waybar.enable = true; programs.waybar.enable = true;
environment.variables = { environment.variables = {
WAYBAR_CONFIG = pkgs.writeText "waybarConfig" waybar.config; WAYBAR_CONFIG = waybar.config;
WAYBAR_STYLE = pkgs.writeText "waybarStyle" waybar.style; WAYBAR_STYLE = waybar.style;
}; };
} }

View file

@ -1,137 +1,137 @@
{ setting, style, ... }: let { setting, style, pkgs, ... }: let
refreshInterval = 2; refreshInterval = 2;
in { in {
text = '' file = (pkgs.formats.json {}).generate "WaybarConfig" {
// -*- mode: jsonc -*- height = 30;
{ layer = "top";
"layer": "top", margin-left = style.window.gap;
"position": "top", margin-right = style.window.gap;
"height": 30, margin-top = style.window.gap;
"spacing": 4, mode = "dock";
"margin-top": ${toString style.window.gap}, position = "top";
"margin-left": ${toString style.window.gap}, spacing = 4;
"margin-right": ${toString style.window.gap}, start_hidden = false;
"mode": "dock", # exclusive = false;
// "exclusive": false, modules-left = [
"start_hidden": false, "sway/workspaces"
"modules-left": [ "sway/scratchpad"
"sway/workspaces", ];
"sway/scratchpad", modules-center = [
], "clock"
"modules-center": [ "mpris"
"clock", ];
"mpris" modules-right = [
], "sway/language"
"modules-right": [ "pulseaudio"
"sway/language", "battery"
"pulseaudio", "custom/powerlimit"
"battery", "cpu"
"custom/powerlimit", # "temperature"
"cpu", "memory"
// "temperature", "custom/powersave"
"memory", "custom/display"
"custom/powersave", "tray"
"custom/display", ];
"tray" "sway/language" = {
], tooltip = false;
"sway/language": { on-click = "swaymsg 'input * xkb_switch_layout next'";
"tooltip": false, };
"on-click": "swaymsg 'input * xkb_switch_layout next'" "sway/scratchpad" = {
}, format = "{icon} {count}";
"sway/scratchpad": { show-empty = false;
"format": "{icon} {count}", format-icons = [ "" "" ];
"show-empty": false, tooltip = true;
"format-icons": ["", ""], tooltip-format = "{app}: {title}";
"tooltip": true, on-click = "swaymsg 'scratchpad show'";
"tooltip-format": "{app}: {title}", on-click-right = "swayscript scratchpad_kill";
"on-click": "swaymsg 'scratchpad show'", };
"on-click-right": "swayscript scratchpad_kill" tray = {
}, # icon-size = 21;
"tray": { spacing = 1;
// "icon-size": 21, };
"spacing": 10 clock = {
}, # timezone = "America/New_York";
"clock": { tooltip-format = "<big><tt>{calendar}</tt></big>";
// "timezone": "America/New_York", format-alt = "{:%d %a %H:%M}";
"tooltip-format": "<big><tt>{calendar}</tt></big>", calendar = {
"format-alt": "{:%d %a %H:%M}", mode-mon-col = 3;
}, };
"battery": { };
"states": { battery = {
"good": 60, states = {
"warning": 40, good = 60;
"critical": 20 warning = 40;
}, critical = 2;
"format": "{capacity}% {icon}", };
"format-charging": "{capacity}% ", format = "{capacity}% {icon}";
"format-plugged": "{capacity}% ", format-charging = "{capacity}% ";
"format-alt": "{time} {icon}", format-plugged = "{capacity}% ";
"format-icons": ["󰂎", "󱊡", "󱊢", "󱊣", "󱊣"], format-alt = "{time} {icon}";
"on-click-right": "powerlimit toggle", format-icons = ["󰂎" "󱊡" "󱊢" "󱊣" "󱊣"];
"interval": ${toString refreshInterval}, on-click-right = "powerlimit toggle";
}, interval = refreshInterval;
"custom/powerlimit": { };
"exec": "powerlimit waybar", "custom/powerlimit" = {
"interval": ${toString refreshInterval}, exec = "powerlimit waybar";
"on-click-right": "powerlimit toggle" interval = refreshInterval;
}, on-click-right = "powerlimit toggle";
"pulseaudio": { };
"scroll-step": ${toString setting.volume.step}, pulseaudio = {
"format": "{volume}% {icon}", scroll-step = setting.volume.step;
"format-muted": "󰸈", format = "{volume}% {icon}";
"format-icons": { format-muted = "󰸈";
"default": ["", "", ""] format-icons = {
}, default = [ "" "" "" ];
"on-click-right": "pactl set-sink-mute @DEFAULT_SINK@ toggle", };
"on-click-middle": "swayscript sound_output_cycle", on-click-right = "pactl set-sink-mute @DEFAULT_SINK@ toggle";
"on-click": "pavucontrol" on-click-middle = "swayscript sound_output_cycle";
}, on-click = "pavucontrol";
"mpris": { };
"format": "{player_icon} {title} - {artist}", mpris = {
"format-paused": "{status_icon} {title} - {artist}", format = "{player_icon} {title} - {artist}";
"player-icons": { format-paused = "{status_icon} {title} - {artist}";
"default": "", player-icons = {
"firefox": "󰈹", "default" = "";
"mpv": "" "firefox" = "󰈹";
}, "mpv" = "";
"status-icons": { };
"paused": "" status-icons = {
}, "paused" = "";
"on-click-middle": "playerctl stop" };
// "ignored-players": ["firefox"] on-click-middle = "playerctl stop";
}, # ignored-players = [ "firefox" ];
"cpu": { };
"format": "{usage}% ({load})", cpu = {
"tooltip": false, format = "{usage}% ({load})";
"on-click": "foot -e bash -c btop", interval = refreshInterval;
"on-click-right": "powersave toggle", on-click = "foot -e bash -c btop";
"interval": ${toString refreshInterval}, on-click-right = "powersave toggle";
}, tooltip = false;
"memory": { };
"format": "{percentage}%", memory = {
"on-click": "foot -e bash -c btop", format = "{percentage}%";
"on-click-right": "powersave toggle", interval = refreshInterval;
"interval": ${toString refreshInterval}, on-click = "foot -e bash -c btop";
}, on-click-right = "powersave toggle";
"temperature": { };
"format": "{temperatureC}°C", temperature = {
"on-click": "foot -e bash -c btop", format = "{temperatureC}°C";
"on-click-right": "powersave toggle", interval = refreshInterval;
"interval": ${toString refreshInterval}, on-click = "foot -e bash -c btop";
}, on-click-right = "powersave toggle";
"custom/powersave": { };
"exec": "powersave waybar", "custom/powersave" = {
"interval": ${toString refreshInterval}, exec = "powersave waybar";
"on-click": "foot -e bash -c btop", interval = refreshInterval;
"on-click-right": "powersave toggle" on-click = "foot -e bash -c btop";
}, on-click-right = "powersave toggle";
"custom/display": { };
"exec": "swayscript monbar", "custom/display" = {
"interval": ${toString refreshInterval}, exec = "swayscript monbar";
"return-type": "json", interval = refreshInterval;
"on-click": "sleep 0.1 && swayscript montoggle", // FIXME: remove sleep when resolved: https://github.com/Alexays/Waybar/issues/2166 on-click = "sleep 0.1 && swayscript montoggle"; # FIXME: remove sleep when resolved: https://github.com/Alexays/Waybar/issues/216
"on-click-right": "sleep 0.1 && swayscript vrrtoggle" on-click-right = "sleep 0.1 && swayscript vrrtoggle";
} return-type = "json";
} };
''; };
} }

View file

@ -1,4 +1,4 @@
{ util, ... } @args: { { util, pkgs, ... } @args: {
config = (import ./config args).text; config = (import ./config args).file;
style = util.catText (util.ls ./style) args; style = pkgs.writeText "WaybarStyle" (util.catText (util.ls ./style) args);
} }

View file

@ -77,10 +77,11 @@
mime = "audio/*"; mime = "audio/*";
use = "audio"; use = "audio";
} { } {
name = "*.json"; mime = "application/json";
use = "text"; use = "text";
} { } {
name = "*.html"; # name = "*.html";
mime = "text/html";
use = [ "browser" "text" ]; use = [ "browser" "text" ];
} }
]; ];