diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-01-14 11:30:32 +0100 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-01-14 11:30:32 +0100 |
| commit | 21b52a31e1eff5c8142f26e091fde083c21db55f (patch) | |
| tree | 650eb693d91b353c866c42dfae49b7c5daee5ca9 /accounts/gkleen@sif/niri/waybar.nix | |
| parent | bef130240c10b90d912aa06239402a6ad98867fe (diff) | |
| download | nixos-21b52a31e1eff5c8142f26e091fde083c21db55f.tar nixos-21b52a31e1eff5c8142f26e091fde083c21db55f.tar.gz nixos-21b52a31e1eff5c8142f26e091fde083c21db55f.tar.bz2 nixos-21b52a31e1eff5c8142f26e091fde083c21db55f.tar.xz nixos-21b52a31e1eff5c8142f26e091fde083c21db55f.zip | |
niri
Diffstat (limited to 'accounts/gkleen@sif/niri/waybar.nix')
| -rw-r--r-- | accounts/gkleen@sif/niri/waybar.nix | 288 |
1 files changed, 288 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix new file mode 100644 index 00000000..1a25b581 --- /dev/null +++ b/accounts/gkleen@sif/niri/waybar.nix | |||
| @@ -0,0 +1,288 @@ | |||
| 1 | { lib, pkgs, ... }: | ||
| 2 | { | ||
| 3 | config = { | ||
| 4 | programs.waybar = { | ||
| 5 | enable = true; | ||
| 6 | systemd = { | ||
| 7 | enable = true; | ||
| 8 | target = "graphical-session.target"; | ||
| 9 | }; | ||
| 10 | settings = let | ||
| 11 | windowRewrites = { | ||
| 12 | "(.*) — Mozilla Firefox" = "$1"; | ||
| 13 | "(.*) - Mozilla Thunderbird" = "$1"; | ||
| 14 | "(.*) - mpv" = "$1"; | ||
| 15 | }; | ||
| 16 | iconSize = 11; | ||
| 17 | in [ | ||
| 18 | { | ||
| 19 | layer = "top"; | ||
| 20 | position = "top"; | ||
| 21 | height = 14; | ||
| 22 | output = [ "eDP-1" "DP-2" "DP-3" ]; | ||
| 23 | modules-left = [ "niri/workspaces" ]; | ||
| 24 | modules-center = [ "niri/window" ]; | ||
| 25 | modules-right = [ # "custom/worktime" "custom/worktime-today" | ||
| 26 | "custom/weather" | ||
| 27 | # "custom/keymap" | ||
| 28 | "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "clock" ]; | ||
| 29 | |||
| 30 | "custom/weather" = { | ||
| 31 | format = "{}"; | ||
| 32 | tooltip = true; | ||
| 33 | interval = 3600; | ||
| 34 | exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"<span font=\\\"Symbols Nerd Font Mono\\\" size=\\\"120%\\\">{ICON}</span> {FeelsLikeC}°\""; | ||
| 35 | return-type = "json"; | ||
| 36 | }; | ||
| 37 | "custom/keymap" = { | ||
| 38 | format = "{}"; | ||
| 39 | tooltip = true; | ||
| 40 | return-type = "json"; | ||
| 41 | exec = pkgs.writers.writePython3 "keymap" {} '' | ||
| 42 | import os | ||
| 43 | import socket | ||
| 44 | import re | ||
| 45 | import subprocess | ||
| 46 | import json | ||
| 47 | |||
| 48 | |||
| 49 | def output(keymap): | ||
| 50 | short = keymap | ||
| 51 | if keymap == "English (programmer Dvorak)": | ||
| 52 | short = "dvp" | ||
| 53 | elif keymap == "English (US)": | ||
| 54 | short = "<span color=\"#ffffff\">us</span>" | ||
| 55 | print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 | ||
| 56 | |||
| 57 | |||
| 58 | r = subprocess.run(["hyprctl", "devices", "-j"], check=True, stdout=subprocess.PIPE, text=True) # noqa: E501 | ||
| 59 | for keyboard in json.loads(r.stdout)['keyboards']: | ||
| 60 | if keyboard['name'] != "at-translated-set-2-keyboard": | ||
| 61 | continue | ||
| 62 | output(keyboard['active_keymap']) | ||
| 63 | |||
| 64 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
| 65 | sock.connect(os.environ["XDG_RUNTIME_DIR"] + "/hypr/" + os.environ["HYPRLAND_INSTANCE_SIGNATURE"] + "/.socket2.sock") # noqa: E501 | ||
| 66 | expected = re.compile(r'^activelayout>>at-translated-set-2-keyboard,(?P<keymap>.+)$') # noqa: E501 | ||
| 67 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
| 68 | if match := expected.match(line): | ||
| 69 | output(match.group("keymap")) | ||
| 70 | ''; | ||
| 71 | on-click = "hyprctl switchxkblayout at-translated-set-2-keyboard next"; | ||
| 72 | }; | ||
| 73 | "custom/worktime" = { | ||
| 74 | interval = 60; | ||
| 75 | exec = lib.getExe pkgs.worktime; | ||
| 76 | tooltip = false; | ||
| 77 | }; | ||
| 78 | "custom/worktime-today" = { | ||
| 79 | interval = 60; | ||
| 80 | exec = "${lib.getExe pkgs.worktime} today"; | ||
| 81 | tooltip = false; | ||
| 82 | }; | ||
| 83 | "niri/workspaces" = { | ||
| 84 | all-outputs = true; | ||
| 85 | }; | ||
| 86 | "niri/window" = { | ||
| 87 | separate-outputs = true; | ||
| 88 | icon = true; | ||
| 89 | icon-size = 14; | ||
| 90 | rewrite = windowRewrites; | ||
| 91 | }; | ||
| 92 | clock = { | ||
| 93 | interval = 1; | ||
| 94 | # timezone = "Europe/Berlin"; | ||
| 95 | format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
| 96 | tooltip-format = "<tt><small>{calendar}</small></tt>"; | ||
| 97 | calendar = { | ||
| 98 | mode = "year"; | ||
| 99 | mode-mon-col = 3; | ||
| 100 | weeks-pos = "left"; | ||
| 101 | on-scroll = 1; | ||
| 102 | format = { | ||
| 103 | months = "<span color='#ffead3'><b>{}</b></span>"; | ||
| 104 | days = "{}"; | ||
| 105 | weeks = "<span color='#99ffdd'><b>{}</b></span>"; | ||
| 106 | weekdays = "<span color='#ffcc66'><b>{}</b></span>"; | ||
| 107 | today = "<span color='#ff6699'><b>{}</b></span>"; | ||
| 108 | }; | ||
| 109 | }; | ||
| 110 | }; | ||
| 111 | battery = { | ||
| 112 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 113 | icon-size = iconSize - 2; | ||
| 114 | states = { warning = 30; critical = 15; }; | ||
| 115 | format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ]; | ||
| 116 | format-charging = "󰂄"; | ||
| 117 | format-plugged = "󰚥"; | ||
| 118 | tooltip-format = "{capacity}% {timeTo}"; | ||
| 119 | interval = 20; | ||
| 120 | }; | ||
| 121 | tray = { | ||
| 122 | icon-size = 16; | ||
| 123 | # show-passive-items = true; | ||
| 124 | spacing = 1; | ||
| 125 | }; | ||
| 126 | privacy = { | ||
| 127 | icon-spacing = 7; | ||
| 128 | icon-size = iconSize; | ||
| 129 | modules = [ | ||
| 130 | { type = "screenshare"; } | ||
| 131 | { type = "audio-in"; } | ||
| 132 | ]; | ||
| 133 | }; | ||
| 134 | idle_inhibitor = { | ||
| 135 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 136 | icon-size = iconSize; | ||
| 137 | format-icons = { activated = "󰈈"; deactivated = "󰈉"; }; | ||
| 138 | timeout = 120; | ||
| 139 | }; | ||
| 140 | backlight = { | ||
| 141 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 142 | icon-size = iconSize; | ||
| 143 | tooltip-format = "{percent}%"; | ||
| 144 | format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"]; | ||
| 145 | on-scroll-up = "lightctl -d -e4 -n1 up"; | ||
| 146 | on-scroll-down = "lightctl -d -e4 -n1 down"; | ||
| 147 | }; | ||
| 148 | wireplumber = { | ||
| 149 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 150 | icon-size = iconSize; | ||
| 151 | tooltip-format = "{volume}% {node_name}"; | ||
| 152 | format-icons = ["󰕿" "󰖀" "󰕾"]; | ||
| 153 | format-muted = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">󰝟</span>"; | ||
| 154 | # ignored-sinks = ["Easy Effects Sink"]; | ||
| 155 | on-scroll-up = "volumectl -d -u up"; | ||
| 156 | on-scroll-down = "volumectl -d -u down"; | ||
| 157 | on-click = "volumectl -d toggle-mute"; | ||
| 158 | }; | ||
| 159 | } | ||
| 160 | { | ||
| 161 | layer = "top"; | ||
| 162 | position = "top"; | ||
| 163 | height = 14; | ||
| 164 | output = [ "!eDP-1" "!DP-2" "!DP-3" ]; | ||
| 165 | modules-left = [ "niri/workspaces" ]; | ||
| 166 | modules-center = [ "niri/window" ]; | ||
| 167 | modules-right = [ "clock" ]; | ||
| 168 | |||
| 169 | "niri/workspaces" = { | ||
| 170 | all-outputs = false; | ||
| 171 | }; | ||
| 172 | "niri/window" = { | ||
| 173 | separate-outputs = true; | ||
| 174 | icon = true; | ||
| 175 | icon-size = 14; | ||
| 176 | rewrite = windowRewrites; | ||
| 177 | }; | ||
| 178 | clock = { | ||
| 179 | interval = 1; | ||
| 180 | # timezone = "Europe/Berlin"; | ||
| 181 | format = "{:%H:%M}"; | ||
| 182 | tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
| 183 | }; | ||
| 184 | } | ||
| 185 | ]; | ||
| 186 | style = '' | ||
| 187 | @define-color white #ffffff; | ||
| 188 | @define-color grey #555555; | ||
| 189 | @define-color blue #1a8fff; | ||
| 190 | @define-color green #23fd00; | ||
| 191 | @define-color orange #f28a21; | ||
| 192 | @define-color red #f2201f; | ||
| 193 | |||
| 194 | * { | ||
| 195 | border: none; | ||
| 196 | font-family: "Fira Sans Nerd Font"; | ||
| 197 | font-size: 10pt; | ||
| 198 | min-height: 0; | ||
| 199 | } | ||
| 200 | |||
| 201 | window#waybar { | ||
| 202 | background-color: rgba(0, 0, 0, 0.66); | ||
| 203 | color: @white; | ||
| 204 | } | ||
| 205 | |||
| 206 | .modules-left { | ||
| 207 | margin-left: 9px; | ||
| 208 | } | ||
| 209 | .modules-right { | ||
| 210 | margin-right: 9px; | ||
| 211 | } | ||
| 212 | |||
| 213 | .module { | ||
| 214 | margin: 0 5px; | ||
| 215 | } | ||
| 216 | |||
| 217 | #workspaces button { | ||
| 218 | color: @grey; | ||
| 219 | } | ||
| 220 | #workspaces button.hosting-monitor { | ||
| 221 | color: @white; | ||
| 222 | } | ||
| 223 | #workspaces button.visible { | ||
| 224 | color: @blue; | ||
| 225 | } | ||
| 226 | #workspaces button.active { | ||
| 227 | color: @green; | ||
| 228 | } | ||
| 229 | #workspaces button.urgent { | ||
| 230 | color: @red; | ||
| 231 | } | ||
| 232 | |||
| 233 | #custom-weather, #custom-keymap, #custom-worktime, #custom-worktime-today { | ||
| 234 | color: @grey; | ||
| 235 | margin: 0 5px; | ||
| 236 | } | ||
| 237 | #custom-weather, #custom-worktime-today { | ||
| 238 | margin-right: 3px; | ||
| 239 | } | ||
| 240 | #custom-keymap, #custom-weather { | ||
| 241 | margin-left: 3px; | ||
| 242 | } | ||
| 243 | |||
| 244 | #tray { | ||
| 245 | margin: 0; | ||
| 246 | } | ||
| 247 | #battery, #idle_inhibitor, #backlight, #wireplumber { | ||
| 248 | color: @grey; | ||
| 249 | margin: 0 5px 0 2px; | ||
| 250 | } | ||
| 251 | #idle_inhibitor { | ||
| 252 | margin-right: 2px; | ||
| 253 | margin-left: 3px; | ||
| 254 | } | ||
| 255 | #battery { | ||
| 256 | margin-right: 3px; | ||
| 257 | } | ||
| 258 | #battery.discharging { | ||
| 259 | color: @white; | ||
| 260 | } | ||
| 261 | #battery.warning { | ||
| 262 | color: @orange; | ||
| 263 | } | ||
| 264 | #battery.critical { | ||
| 265 | color: @red; | ||
| 266 | } | ||
| 267 | #battery.charging { | ||
| 268 | color: @white; | ||
| 269 | } | ||
| 270 | #idle_inhibitor.activated { | ||
| 271 | color: @white; | ||
| 272 | } | ||
| 273 | |||
| 274 | #idle_inhibitor { | ||
| 275 | padding-top: 1px; | ||
| 276 | } | ||
| 277 | |||
| 278 | #privacy { | ||
| 279 | color: @red; | ||
| 280 | margin: -1px 2px 0px 5px; | ||
| 281 | } | ||
| 282 | #clock { | ||
| 283 | /* margin-right: 5px; */ | ||
| 284 | } | ||
| 285 | ''; | ||
| 286 | }; | ||
| 287 | }; | ||
| 288 | } | ||
