nixify bar

This commit is contained in:
Grimmauld 2024-05-05 16:25:16 +02:00
parent 9ce574a6e0
commit f4a943d189
Signed by: Grimmauld
GPG key ID: C2946668769F91FB
3 changed files with 134 additions and 145 deletions

View file

@ -1,138 +0,0 @@
{
// "layer": "top", // Waybar at top layer
"position": "top",
"height": 30, // Waybar height (to be removed for auto height)
// "width": 1280, // Waybar width
"spacing": 4, // Gaps between modules (4px)
// Choose the order of the modules
"modules-left": ["sway/workspaces", "sway/mode", "sway/scratchpad"],
"modules-center": ["wlr/taskbar"], // "sway/window"],
"modules-right": ["custom/media", "idle_inhibitor", "pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "keyboard-state", "battery", "clock", "tray"],
"keyboard-state": {
"numlock": true,
"capslock": true,
"format": "{name} {icon}",
"format-icons": {
"locked": "",
"unlocked": ""
}
},
"wlr/taskbar": {
"format": "{icon}",
"icon-size": 14,
"tooltip-format": "{title}",
"on-click": "activate",
"on-click-middle": "close",
"ignore-list": [
],
"app_ids-mapping": {
"firefoxdeveloperedition": "firefox-developer-edition",
"firefox.*": "Firefox"
},
"rewrite": {
"Firefox Web Browser": "Firefox"
}
},
"sway/mode": {
"format": "<span style=\"italic\">{}</span>"
},
"sway/scratchpad": {
"format": "{icon} {count}",
"show-empty": false,
"format-icons": ["", ""],
"tooltip": true,
"tooltip-format": "{app}: {title}"
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "",
"deactivated": ""
}
},
"tray": {
// "icon-size": 21,
"spacing": 10
},
"clock": {
// "timezone": "America/New_York",
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
"format-alt": "{:%d.%m.%Y}"
},
"cpu": {
"format": "{usage}% ",
"tooltip": false
},
"memory": {
"format": "{}% "
},
"temperature": {
// "thermal-zone": 2,
// "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input",
"critical-threshold": 80,
// "format-critical": "{temperatureC}°C {icon}",
"format": "{temperatureC}°C {icon}",
"format-icons": ["", "", ""]
},
"backlight": {
// "device": "acpi_video1",
"format": "{percent}%",
"format-icons": ["", "", "", "", "", "", "", "", ""]
},
"battery": {
"states": {
// "good": 95,
"warning": 30,
"critical": 15
},
"format": "{capacity}% {icon}",
"format-charging": "{capacity}% ",
"format-plugged": "{capacity}% ",
"format-alt": "{time} {icon}",
// "format-good": "", // An empty format will hide the module
// "format-full": "",
"format-icons": ["", "", "", "", ""],
"on-click": "rmenu -r powermenu --single-click true"
},
"battery#bat2": {
"bat": "BAT2"
},
"network": {
"format-wifi": "{essid} ({signalStrength}%) ",
"format-ethernet": "{ipaddr}/{cidr} ",
"tooltip-format": "{ifname} via {gwaddr} ",
"format-linked": "{ifname} (No IP) ",
"format-disconnected": "Disconnected ⚠",
"format-alt": "{ifname}: {ipaddr}/{cidr}",
"on-click-right": "rmenu -r network --single-click true"
},
"pulseaudio": {
// "scroll-step": 1, // %, can be a float
"format": "{volume}% {icon} {format_source}",
"format-bluetooth": "{volume}% {icon} {format_source}",
"format-bluetooth-muted": " {icon} {format_source}",
"format-muted": " {format_source}",
"format-source": "{volume}% ",
"format-source-muted": "",
"format-icons": {
"headphone": "",
"hands-free": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": ["", "", ""]
},
"on-click": "pwvucontrol"
},
"custom/media": {
"return-type": "json",
"on-click": "waybar-mpris --send toggle",
"exec": "waybar-mpris --position --autofocus --pause ⏵ --play ⏸ --order SYMBOL:TITLE:ARTIST:ALBUM:POSITION ",
"on-scroll-up": "waybar-mpris --send next",
"on-scroll-down": "waybar-mpris --send prev",
"max-length": 40,
"escape": true
}
}

128
sway/bar/default.nix Normal file
View file

@ -0,0 +1,128 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) getExe;
config = with pkgs; {
backlight = {
format = "{percent}%";
format-icons = [ "" "" "" "" "" "" "" "" "" ];
};
battery = {
format = "{capacity}% {icon}";
format-alt = "{time} {icon}";
format-charging = "{capacity}% ";
format-icons = [ "" "" "" "" "" ];
format-plugged = "{capacity}% ";
on-click = "${getExe rmenu} -r powermenu --single-click true";
states = { critical = 15; warning = 30; };
};
clock = {
format-alt = "{:%d.%m.%Y}";
tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
};
cpu = {
format = "{usage}% ";
tooltip = false;
on-click = "${getExe xdg-terminal-exec} ${getExe btop}";
};
"custom/media" = {
escape = true;
exec = "${getExe waybar-mpris} --position --autofocus --pause --play --order SYMBOL:TITLE:ARTIST:ALBUM:POSITION ";
max-length = 40;
on-click = "${getExe waybar-mpris} --send toggle";
on-scroll-down = "${getExe waybar-mpris} --send prev";
on-scroll-up = "${getExe waybar-mpris} --send next";
return-type = "json";
};
height = 30;
idle_inhibitor = {
format = "{icon}";
format-icons = { activated = ""; deactivated = ""; };
};
keyboard-state = {
capslock = true;
format = "{name} {icon}";
format-icons = { locked = ""; unlocked = ""; };
numlock = true;
};
memory = { format = "{}% "; };
modules-center = [
# "wlr/taskbar"
];
modules-left = [ "sway/workspaces" "sway/mode" "sway/scratchpad" ];
modules-right = [
"custom/media"
"idle_inhibitor"
"pulseaudio"
"network"
"cpu"
"memory"
"temperature"
"backlight"
"keyboard-state"
"battery"
"clock"
"tray"
];
network = {
format-alt = "{ifname}: {ipaddr}/{cidr}";
format-disconnected = "Disconnected ";
format-ethernet = "{ipaddr}/{cidr} ";
format-linked = "{ifname} (No IP) ";
format-wifi = "{essid} ({signalStrength}%) ";
on-click-right = "nm-connection-editor";
tooltip-format = "{ifname} via {gwaddr} ";
};
position = "top";
pulseaudio = {
format = "{volume}% {icon} {format_source}";
format-bluetooth = "{volume}% {icon} {format_source}";
format-bluetooth-muted = "{icon} {format_source}";
format-icons = {
car = "";
default = [ "" "" "" ];
hands-free = "";
headphone = "";
headset = "";
phone = "";
portable = "";
muted = "🔇";
};
format-muted = "{icon} {format_source}";
format-source = "{volume}% ";
format-source-muted = "";
on-click = "${getExe pwvucontrol}";
};
spacing = 4;
"sway/mode" = { format = "<span style=\"italic\">{}</span>"; };
"sway/scratchpad" = {
format = "{icon} {count}";
format-icons = [ "" "" ];
show-empty = false;
tooltip = true;
tooltip-format = "{app}: {title}";
};
temperature = {
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = [ "" "" "" ];
};
tray = { spacing = 10; };
"wlr/taskbar" = {
format = "{icon}";
icon-size = 14;
ignore-list = [ ];
on-click = "activate";
on-click-middle = "close";
rewrite = { "Firefox Web Browser" = "Firefox"; };
tooltip-format = "{title}";
};
};
in
{
grimmShared.sway.bar = {
enable = true;
config = pkgs.writers.writeJSON "config.json" config;
style = ./style.css;
};
}

View file

@ -8,6 +8,10 @@ let
'';
in
{
imports = [
./bar
];
environment.systemPackages = with pkgs; [
rmenu
grim
@ -19,17 +23,11 @@ in
swaynotificationcenter
searchclip
ydotool
networkmanagerapplet
];
grimmShared.sway = {
enable = true;
bar = {
enable = true;
config = ./bar/config;
style = ./bar/style.css;
};
config = with pkgs; let
inherit (lib) getExe;
in
@ -188,6 +186,7 @@ in
"lxqt-policykit-agent"
"otd-daemon"
swaynotificationcenter
networkmanagerapplet
# (pkgs.writeShellScriptBin "rmenu-cache-clear" "rm -r $HOME/.cache/rmenu") # invalidate rmenu cache on sway restart
"dbus-update-activation-environment"
];