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
keep-derivations = 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)

View file

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

View file

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

View file

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

View file

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