From f4a943d189ee763a5d84906a33b994d6a3a7922b Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Sun, 5 May 2024 16:25:16 +0200 Subject: [PATCH] nixify bar --- sway/bar/config | 138 ------------------------------------------- sway/bar/default.nix | 128 +++++++++++++++++++++++++++++++++++++++ sway/default.nix | 13 ++-- 3 files changed, 134 insertions(+), 145 deletions(-) delete mode 100644 sway/bar/config create mode 100644 sway/bar/default.nix diff --git a/sway/bar/config b/sway/bar/config deleted file mode 100644 index 14def23..0000000 --- a/sway/bar/config +++ /dev/null @@ -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": "{}" - }, - "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": "{:%Y %B}\n{calendar}", - "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 - } -} - diff --git a/sway/bar/default.nix b/sway/bar/default.nix new file mode 100644 index 0000000..e63f698 --- /dev/null +++ b/sway/bar/default.nix @@ -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 = "{:%Y %B}\n{calendar}"; + }; + 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 = "{}"; }; + "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; + }; +} diff --git a/sway/default.nix b/sway/default.nix index 34cb246..2daeeb3 100644 --- a/sway/default.nix +++ b/sway/default.nix @@ -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" ];