diff options
Diffstat (limited to 'accounts/gkleen@sif/niri/waybar.nix')
| -rw-r--r-- | accounts/gkleen@sif/niri/waybar.nix | 338 |
1 files changed, 0 insertions, 338 deletions
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix deleted file mode 100644 index 79c429f8..00000000 --- a/accounts/gkleen@sif/niri/waybar.nix +++ /dev/null | |||
| @@ -1,338 +0,0 @@ | |||
| 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" "custom/mako" "clock" ]; | ||
| 29 | |||
| 30 | "custom/mako" = { | ||
| 31 | format = "{}"; | ||
| 32 | return-type = "json"; | ||
| 33 | exec = pkgs.writers.writePython3 "mako-silent" { libraries = [ pkgs.python3Packages.dbus-next ]; } '' | ||
| 34 | from dbus_next.aio import MessageBus | ||
| 35 | |||
| 36 | import asyncio | ||
| 37 | |||
| 38 | import json | ||
| 39 | |||
| 40 | |||
| 41 | loop = asyncio.new_event_loop() | ||
| 42 | asyncio.set_event_loop(loop) | ||
| 43 | |||
| 44 | |||
| 45 | async def main(): | ||
| 46 | bus = await MessageBus().connect() | ||
| 47 | # the introspection xml would normally be included in your project, but | ||
| 48 | # this is convenient for development | ||
| 49 | introspection = await bus.introspect('org.freedesktop.Notifications', '/fr/emersion/Mako') # noqa: E501 | ||
| 50 | |||
| 51 | obj = bus.get_proxy_object('org.freedesktop.Notifications', '/fr/emersion/Mako', introspection) # noqa: E501 | ||
| 52 | mako = obj.get_interface('fr.emersion.Mako') | ||
| 53 | properties = obj.get_interface('org.freedesktop.DBus.Properties') | ||
| 54 | |||
| 55 | async def print_mode(): | ||
| 56 | modes = await mako.get_modes() | ||
| 57 | is_silent = "silent" in modes | ||
| 58 | icon = "󰂛" if is_silent else "󰂚" | ||
| 59 | text = f"<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>" # noqa: E501 | ||
| 60 | if is_silent: | ||
| 61 | text = f"<span color=\"#ffffff\">{text}</span>" | ||
| 62 | print(json.dumps({'text': text}, separators=(',', ':')), flush=True) # noqa: E501 | ||
| 63 | |||
| 64 | async def on_properties_changed(interface_name, changed_properties, invalidated_properties): # noqa: E501 | ||
| 65 | if "Modes" not in invalidated_properties: | ||
| 66 | return | ||
| 67 | |||
| 68 | await print_mode() | ||
| 69 | |||
| 70 | properties.on_properties_changed(on_properties_changed) | ||
| 71 | await print_mode() | ||
| 72 | |||
| 73 | await loop.create_future() | ||
| 74 | |||
| 75 | |||
| 76 | loop.run_until_complete(main()) | ||
| 77 | ''; | ||
| 78 | on-click = "makoctl mode -t silent"; | ||
| 79 | }; | ||
| 80 | "custom/weather" = { | ||
| 81 | format = "{}"; | ||
| 82 | tooltip = true; | ||
| 83 | interval = 3600; | ||
| 84 | exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"<span font=\\\"Symbols Nerd Font Mono\\\" size=\\\"100%\\\">{ICON}</span> {FeelsLikeC}°\""; | ||
| 85 | return-type = "json"; | ||
| 86 | }; | ||
| 87 | "custom/keymap" = { | ||
| 88 | format = "{}"; | ||
| 89 | tooltip = true; | ||
| 90 | return-type = "json"; | ||
| 91 | exec = pkgs.writers.writePython3 "keymap" {} '' | ||
| 92 | import os | ||
| 93 | import socket | ||
| 94 | import json | ||
| 95 | |||
| 96 | |||
| 97 | def output(keymap): | ||
| 98 | short = keymap | ||
| 99 | if keymap == "English (programmer Dvorak)": | ||
| 100 | short = "dvp" | ||
| 101 | elif keymap == "English (US)": | ||
| 102 | short = "<span color=\"#ffffff\">us</span>" | ||
| 103 | print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 | ||
| 104 | |||
| 105 | |||
| 106 | keyboard_layouts = [] | ||
| 107 | |||
| 108 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
| 109 | sock.connect(os.environ["NIRI_SOCKET"]) | ||
| 110 | sock.send(b"\"EventStream\"\n") | ||
| 111 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
| 112 | if line_json := json.loads(line): | ||
| 113 | if "KeyboardLayoutsChanged" in line_json: | ||
| 114 | keyboard_layouts = line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["names"] # noqa: E501 | ||
| 115 | output(keyboard_layouts[line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["current_idx"]]) # noqa: E501 | ||
| 116 | if "KeyboardLayoutSwitched" in line_json: | ||
| 117 | output(keyboard_layouts[line_json["KeyboardLayoutSwitched"]["idx"]]) # noqa: E501 | ||
| 118 | ''; | ||
| 119 | on-click = "niri msg action switch-layout next"; | ||
| 120 | }; | ||
| 121 | "custom/worktime" = { | ||
| 122 | interval = 60; | ||
| 123 | exec = lib.getExe pkgs.worktime; | ||
| 124 | tooltip = false; | ||
| 125 | }; | ||
| 126 | "custom/worktime-today" = { | ||
| 127 | interval = 60; | ||
| 128 | exec = "${lib.getExe pkgs.worktime} today"; | ||
| 129 | tooltip = false; | ||
| 130 | }; | ||
| 131 | "niri/workspaces" = { | ||
| 132 | ignore = ["pwctl" "kpxc" "bmgr" "edit" "term"]; | ||
| 133 | }; | ||
| 134 | "niri/window" = { | ||
| 135 | separate-outputs = true; | ||
| 136 | icon = true; | ||
| 137 | icon-size = 14; | ||
| 138 | rewrite = windowRewrites; | ||
| 139 | }; | ||
| 140 | clock = { | ||
| 141 | interval = 1; | ||
| 142 | # timezone = "Europe/Berlin"; | ||
| 143 | format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
| 144 | tooltip-format = "<tt><small>{calendar}</small></tt>"; | ||
| 145 | calendar = { | ||
| 146 | mode = "year"; | ||
| 147 | mode-mon-col = 3; | ||
| 148 | weeks-pos = "left"; | ||
| 149 | on-scroll = 1; | ||
| 150 | format = { | ||
| 151 | months = "<span color='#ffead3'><b>{}</b></span>"; | ||
| 152 | days = "{}"; | ||
| 153 | weeks = "<span color='#99ffdd'><b>{}</b></span>"; | ||
| 154 | weekdays = "<span color='#ffcc66'><b>{}</b></span>"; | ||
| 155 | today = "<span color='#ff6699'><b>{}</b></span>"; | ||
| 156 | }; | ||
| 157 | }; | ||
| 158 | }; | ||
| 159 | battery = { | ||
| 160 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 161 | icon-size = iconSize - 2; | ||
| 162 | states = { warning = 30; critical = 15; }; | ||
| 163 | format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ]; | ||
| 164 | format-charging = "󰂄"; | ||
| 165 | format-plugged = "󰚥"; | ||
| 166 | tooltip-format = "{capacity}% {timeTo}"; | ||
| 167 | interval = 20; | ||
| 168 | }; | ||
| 169 | tray = { | ||
| 170 | icon-size = 16; | ||
| 171 | # show-passive-items = true; | ||
| 172 | spacing = 1; | ||
| 173 | }; | ||
| 174 | privacy = { | ||
| 175 | icon-spacing = 7; | ||
| 176 | icon-size = iconSize; | ||
| 177 | modules = [ | ||
| 178 | { type = "screenshare"; } | ||
| 179 | { type = "audio-in"; } | ||
| 180 | ]; | ||
| 181 | }; | ||
| 182 | idle_inhibitor = { | ||
| 183 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 184 | icon-size = iconSize; | ||
| 185 | format-icons = { activated = "󰈈"; deactivated = "󰈉"; }; | ||
| 186 | timeout = 120; | ||
| 187 | }; | ||
| 188 | backlight = { | ||
| 189 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 190 | icon-size = iconSize; | ||
| 191 | tooltip-format = "{percent}%"; | ||
| 192 | format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"]; | ||
| 193 | on-scroll-up = "lightctl -d -e4 -n1 up"; | ||
| 194 | on-scroll-down = "lightctl -d -e4 -n1 down"; | ||
| 195 | }; | ||
| 196 | wireplumber = { | ||
| 197 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 198 | icon-size = iconSize; | ||
| 199 | tooltip-format = "{volume}% {node_name}"; | ||
| 200 | format-icons = ["󰕿" "󰖀" "󰕾"]; | ||
| 201 | format-muted = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">󰝟</span>"; | ||
| 202 | # ignored-sinks = ["Easy Effects Sink"]; | ||
| 203 | on-scroll-up = "volumectl -d -u up"; | ||
| 204 | on-scroll-down = "volumectl -d -u down"; | ||
| 205 | on-click = "volumectl -d toggle-mute"; | ||
| 206 | }; | ||
| 207 | } | ||
| 208 | { | ||
| 209 | layer = "top"; | ||
| 210 | position = "top"; | ||
| 211 | height = 14; | ||
| 212 | output = [ "!eDP-1" "!DP-2" "!DP-3" ]; | ||
| 213 | modules-left = [ "niri/workspaces" ]; | ||
| 214 | modules-center = [ "niri/window" ]; | ||
| 215 | modules-right = [ "clock" ]; | ||
| 216 | |||
| 217 | "niri/workspaces" = { | ||
| 218 | ignore = ["pwctl" "kpxc" "bmgr" "edit" "term"]; | ||
| 219 | }; | ||
| 220 | "niri/window" = { | ||
| 221 | separate-outputs = true; | ||
| 222 | icon = true; | ||
| 223 | icon-size = 14; | ||
| 224 | rewrite = windowRewrites; | ||
| 225 | }; | ||
| 226 | clock = { | ||
| 227 | interval = 1; | ||
| 228 | # timezone = "Europe/Berlin"; | ||
| 229 | format = "{:%H:%M}"; | ||
| 230 | tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
| 231 | }; | ||
| 232 | } | ||
| 233 | ]; | ||
| 234 | style = '' | ||
| 235 | @define-color white #ffffff; | ||
| 236 | @define-color grey #555555; | ||
| 237 | @define-color blue #1a8fff; | ||
| 238 | @define-color green #23fd00; | ||
| 239 | @define-color orange #f28a21; | ||
| 240 | @define-color red #f2201f; | ||
| 241 | |||
| 242 | * { | ||
| 243 | border: none; | ||
| 244 | font-family: "Fira Sans Nerd Font"; | ||
| 245 | font-size: 10pt; | ||
| 246 | min-height: 0; | ||
| 247 | } | ||
| 248 | |||
| 249 | window#waybar { | ||
| 250 | background-color: rgba(0, 0, 0, 0.66); | ||
| 251 | color: @white; | ||
| 252 | } | ||
| 253 | |||
| 254 | .modules-left { | ||
| 255 | margin-left: 8px; | ||
| 256 | } | ||
| 257 | .modules-right { | ||
| 258 | margin-right: 8px; | ||
| 259 | } | ||
| 260 | |||
| 261 | .module { | ||
| 262 | margin: 0 5px; | ||
| 263 | } | ||
| 264 | |||
| 265 | #workspaces button { | ||
| 266 | color: @white; | ||
| 267 | padding: 2px 5px; | ||
| 268 | } | ||
| 269 | #workspaces button.empty { | ||
| 270 | color: @grey; | ||
| 271 | } | ||
| 272 | #workspaces button.active { | ||
| 273 | color: @green; | ||
| 274 | } | ||
| 275 | #workspaces button.urgent { | ||
| 276 | color: @red; | ||
| 277 | } | ||
| 278 | |||
| 279 | #custom-weather, #custom-keymap, #custom-worktime, #custom-worktime-today { | ||
| 280 | color: @grey; | ||
| 281 | margin: 0 5px; | ||
| 282 | } | ||
| 283 | #custom-weather, #custom-worktime-today { | ||
| 284 | margin-right: 3px; | ||
| 285 | } | ||
| 286 | #custom-keymap, #custom-weather { | ||
| 287 | margin-left: 3px; | ||
| 288 | } | ||
| 289 | |||
| 290 | #tray { | ||
| 291 | margin: 0; | ||
| 292 | } | ||
| 293 | #battery, #idle_inhibitor, #backlight, #wireplumber, #custom-mako { | ||
| 294 | color: @grey; | ||
| 295 | margin: 0 5px 0 2px; | ||
| 296 | } | ||
| 297 | #idle_inhibitor { | ||
| 298 | margin-right: 4px; | ||
| 299 | margin-left: 6px; | ||
| 300 | } | ||
| 301 | #custom-mako { | ||
| 302 | margin-right: 2px; | ||
| 303 | margin-left: 3px; | ||
| 304 | } | ||
| 305 | #battery { | ||
| 306 | margin-right: 3px; | ||
| 307 | } | ||
| 308 | #battery.discharging { | ||
| 309 | color: @white; | ||
| 310 | } | ||
| 311 | #battery.warning { | ||
| 312 | color: @orange; | ||
| 313 | } | ||
| 314 | #battery.critical { | ||
| 315 | color: @red; | ||
| 316 | } | ||
| 317 | #battery.charging { | ||
| 318 | color: @white; | ||
| 319 | } | ||
| 320 | #idle_inhibitor.activated { | ||
| 321 | color: @white; | ||
| 322 | } | ||
| 323 | |||
| 324 | #idle_inhibitor { | ||
| 325 | padding-top: 1px; | ||
| 326 | } | ||
| 327 | |||
| 328 | #privacy { | ||
| 329 | color: @red; | ||
| 330 | margin: -1px 2px 0px 5px; | ||
| 331 | } | ||
| 332 | #clock { | ||
| 333 | /* margin-right: 5px; */ | ||
| 334 | } | ||
| 335 | ''; | ||
| 336 | }; | ||
| 337 | }; | ||
| 338 | } | ||
