diff options
Diffstat (limited to 'accounts/gkleen@sif/niri')
| -rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 977 | ||||
| -rw-r--r-- | accounts/gkleen@sif/niri/mako.nix | 112 | ||||
| -rw-r--r-- | accounts/gkleen@sif/niri/swayosd.nix | 66 | ||||
| -rw-r--r-- | accounts/gkleen@sif/niri/waybar.nix | 347 |
4 files changed, 0 insertions, 1502 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix deleted file mode 100644 index b57e1cc0..00000000 --- a/accounts/gkleen@sif/niri/default.nix +++ /dev/null | |||
| @@ -1,977 +0,0 @@ | |||
| 1 | { config, hostConfig, pkgs, lib, flakeInputs, ... }: | ||
| 2 | let | ||
| 3 | cfg = config.programs.niri; | ||
| 4 | |||
| 5 | kdl = flakeInputs.niri-flake.lib.kdl; | ||
| 6 | |||
| 7 | niri = cfg.package; | ||
| 8 | terminal = lib.getExe config.programs.kitty.package; | ||
| 9 | makoctl = lib.getExe' config.services.mako.package "makoctl"; | ||
| 10 | loginctl = lib.getExe' hostConfig.systemd.package "loginctl"; | ||
| 11 | systemctl = lib.getExe' hostConfig.systemd.package "systemctl"; | ||
| 12 | swayosd-client = lib.getExe' config.services.swayosd.package "swayosd-client"; | ||
| 13 | |||
| 14 | focus_or_spawn = pkgs.writeShellApplication { | ||
| 15 | name = "focus-or-spawn"; | ||
| 16 | runtimeInputs = [ niri pkgs.gojq pkgs.gnugrep pkgs.socat ]; | ||
| 17 | text = '' | ||
| 18 | window_select="$1" | ||
| 19 | shift | ||
| 20 | workspace_name="$1" | ||
| 21 | shift | ||
| 22 | |||
| 23 | workspaces_json="$(niri msg -j workspaces)" | ||
| 24 | workspace_output="$(jq -r --arg workspace_name "$workspace_name" '.[] | select(.name == $workspace_name) | .output' <<<"$workspaces_json")" | ||
| 25 | # active_workspace="$(jq -r --arg workspace_output "$workspace_output" '.[] | select(.output == $workspace_output and .is_active) | .id' <<<"$workspaces_json")" | ||
| 26 | active_output="$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
| 27 | if [[ $workspace_output != "$active_output" ]]; then | ||
| 28 | niri msg action move-workspace-to-monitor --reference "$workspace_name" "$active_output" | ||
| 29 | # socat STDIO "$NIRI_SOCKET" <<<'{"Action":{"FocusWorkspace":{"reference":{"Id":'"''${active_workspace}"'}}}}' | ||
| 30 | # niri msg action move-workspace-to-index --reference "$workspace_name" 1 | ||
| 31 | fi | ||
| 32 | |||
| 33 | while IFS=$'\n' read -r window_json; do | ||
| 34 | if [[ -n $(jq -c "$window_select" <<<"$window_json") ]]; then | ||
| 35 | if jq -e '.is_focused' <<<"$window_json" >/dev/null; then | ||
| 36 | niri msg action focus-workspace-previous | ||
| 37 | else | ||
| 38 | if [[ $(jq -r --arg workspace_name "$workspace_name" 'map(select(.name == $workspace_name)) | .[0].is_focused' <<<"$workspaces_json") != "true" ]] && [[ $(jq -r --arg workspace_name "$workspace_name" 'map(select(.name == $workspace_name)) | .[0].id' <<<"$workspaces_json") = $(jq -r '.workspace_id' <<<"$window_json") ]]; then | ||
| 39 | niri msg action focus-workspace "$workspace_name" | ||
| 40 | else | ||
| 41 | niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")" | ||
| 42 | fi | ||
| 43 | fi | ||
| 44 | exit 0 | ||
| 45 | fi | ||
| 46 | done < <(niri msg -j windows | jq -c '.[]') | ||
| 47 | |||
| 48 | exec "$@" | ||
| 49 | ''; | ||
| 50 | }; | ||
| 51 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); | ||
| 52 | |||
| 53 | with_adjacent_workspace = pkgs.writeShellApplication { | ||
| 54 | name = "with-adjacent-workspace"; | ||
| 55 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
| 56 | text = '' | ||
| 57 | blacklist="$1" | ||
| 58 | shift | ||
| 59 | direction="$1" | ||
| 60 | shift | ||
| 61 | action="$1" | ||
| 62 | shift | ||
| 63 | |||
| 64 | workspaces_json="$(niri msg -j workspaces)" | ||
| 65 | active_workspace="$(jq -r '.[] | select(.is_focused) | .id' <<<"$workspaces_json")" | ||
| 66 | workspace_output="$(jq -r --arg active_workspace "$active_workspace" '.[] | select(.id == ($active_workspace | tonumber)) | .output' <<<"$workspaces_json")" | ||
| 67 | workspace_idx="$(jq -r '.[] | select(.is_focused) | .idx' <<<"$workspaces_json")" | ||
| 68 | |||
| 69 | jq_script='map(select(' | ||
| 70 | case "$direction" in | ||
| 71 | down) | ||
| 72 | # shellcheck disable=SC2016 | ||
| 73 | jq_script=''${jq_script}'.idx > ($workspace_idx | tonumber)';; | ||
| 74 | up) | ||
| 75 | # shellcheck disable=SC2016 | ||
| 76 | jq_script=''${jq_script}'.idx < ($workspace_idx | tonumber)';; | ||
| 77 | esac | ||
| 78 | # shellcheck disable=SC2016 | ||
| 79 | jq_script=''${jq_script}' and .output == $workspace_output and ((.name == null) or (.name | test($blacklist) | not)))) | sort_by(.idx)' | ||
| 80 | [[ $direction == "up" ]] && jq_script=''${jq_script}' | reverse' | ||
| 81 | jq_script=''${jq_script}' | .[0]' | ||
| 82 | |||
| 83 | workspace_json=$(jq -c --arg blacklist "$blacklist" --arg workspace_output "$workspace_output" --arg workspace_idx "$workspace_idx" "$jq_script" <<<"$workspaces_json") | ||
| 84 | [[ -n $workspace_json && $workspace_json != null ]] || exit 0 | ||
| 85 | jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
| 86 | ''; | ||
| 87 | }; | ||
| 88 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^${lib.concatMapStringsSep "|" ({ name, ...}: name) cfg.scratchspaces}$"; | ||
| 89 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | ||
| 90 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}, "focus": true}}}''; | ||
| 91 | |||
| 92 | with_unnamed_workspace = pkgs.writeShellApplication { | ||
| 93 | name = "with-unnamed-workspace"; | ||
| 94 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
| 95 | text = '' | ||
| 96 | action="$1" | ||
| 97 | shift | ||
| 98 | |||
| 99 | workspaces_json="$(niri msg -j workspaces)" | ||
| 100 | active_output="$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
| 101 | active_workspace="$(jq -r '.[] | select(.is_focused) | .id' <<<"$workspaces_json")" | ||
| 102 | |||
| 103 | history_json="$(socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/niri-workspace-history.sock)" | ||
| 104 | workspace_json="$(jq -c --arg active_output "$active_output" --argjson history "$history_json" 'map(select(.output == $active_output and .name == null)) | map({"value": ., "history_idx": ((. as $workspace | ($history[$active_output] | index($workspace | .id))) as $active_idx | if $active_idx then $active_idx else ($history[$active_output] | length) + 1 end)}) | sort_by(.history_idx, .value.idx) | map(.value) | .[0]' <<<"$workspaces_json")" | ||
| 105 | [[ -n $workspace_json && $workspace_json != null ]] || exit 0 | ||
| 106 | jq --arg active_workspace "$active_workspace" -c "$action" <<<"$workspace_json" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
| 107 | ''; | ||
| 108 | }; | ||
| 109 | with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); | ||
| 110 | |||
| 111 | with_empty_unnamed_workspace = pkgs.writeShellApplication { | ||
| 112 | name = "with-empty-unnamed-workspace"; | ||
| 113 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
| 114 | text = '' | ||
| 115 | action="$1" | ||
| 116 | shift | ||
| 117 | |||
| 118 | workspaces_json="$(niri msg -j workspaces)" | ||
| 119 | active_output="$(jq '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" | ||
| 120 | target_workspace_id="$(jq --argjson active_output "$active_output" 'map(select(.active_window_id == null and .name == null and .output == $active_output)) | sort_by(.idx) | .[0].id' <<<"$workspaces_json")" | ||
| 121 | jq --argjson workspace_id "$target_workspace_id" -nc "$action" | tee /dev/stderr | socat STDIO "$NIRI_SOCKET" | ||
| 122 | ''; | ||
| 123 | }; | ||
| 124 | with-empty-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_empty_unnamed_workspace); | ||
| 125 | |||
| 126 | with_select_window = pkgs.writeShellApplication { | ||
| 127 | name = "with-select-window"; | ||
| 128 | runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; | ||
| 129 | text = '' | ||
| 130 | window_select="$1" | ||
| 131 | shift | ||
| 132 | action="$1" | ||
| 133 | shift | ||
| 134 | |||
| 135 | windows_json="$(niri msg -j windows)" | ||
| 136 | active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" | ||
| 137 | window_ix="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\u0000icon\u001f\(.app_id)"' <<<"$windows_json" | fuzzel --log-level=warning --dmenu --index)" | ||
| 138 | # shellcheck disable=SC2016 | ||
| 139 | window_json="$(gojq -rc --arg active_workspace "$active_workspace" --arg window_ix "$window_ix" 'map(select('"$window_select"')) | .[($window_ix | tonumber)]' <<<"$windows_json")" | ||
| 140 | |||
| 141 | [[ -z "$window_json" ]] && exit 1 | ||
| 142 | |||
| 143 | jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET" | ||
| 144 | ''; | ||
| 145 | }; | ||
| 146 | with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); | ||
| 147 | |||
| 148 | with_predicate_window = pred: pkgs.writeShellApplication { | ||
| 149 | name = "with-predicate-window"; | ||
| 150 | runtimeInputs = [ niri pkgs.gojq pkgs.socat ]; | ||
| 151 | text = '' | ||
| 152 | action="$1" | ||
| 153 | shift | ||
| 154 | |||
| 155 | windows_json="$(niri msg -j windows)" | ||
| 156 | window_json="$(gojq -rc 'map(select(${pred})) | .[0]' <<<"$windows_json")" | ||
| 157 | |||
| 158 | [[ -z "$window_json" || $window_json = "null" ]] && exit 1 | ||
| 159 | |||
| 160 | jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET" | ||
| 161 | ''; | ||
| 162 | }; | ||
| 163 | |||
| 164 | with-urgent-window-action = config.lib.niri.actions.spawn (lib.getExe (with_predicate_window ".is_urgent")); | ||
| 165 | with-focused-window-action = config.lib.niri.actions.spawn (lib.getExe (with_predicate_window ".is_focused")); | ||
| 166 | in { | ||
| 167 | imports = [ | ||
| 168 | ./waybar.nix | ||
| 169 | ./mako.nix | ||
| 170 | ./swayosd.nix | ||
| 171 | ]; | ||
| 172 | |||
| 173 | options = { | ||
| 174 | programs.niri.scratchspaces = lib.mkOption { | ||
| 175 | type = lib.types.listOf (lib.types.submodule ({ config, ... }: { | ||
| 176 | options = { | ||
| 177 | name = lib.mkOption { | ||
| 178 | type = lib.types.str; | ||
| 179 | }; | ||
| 180 | match = lib.mkOption { | ||
| 181 | type = lib.types.listOf (lib.types.attrsOf kdl.types.kdl-args); | ||
| 182 | default = []; | ||
| 183 | }; | ||
| 184 | exclude = lib.mkOption { | ||
| 185 | type = lib.types.listOf (lib.types.attrsOf kdl.types.kdl-args); | ||
| 186 | default = []; | ||
| 187 | }; | ||
| 188 | windowRuleExtra = lib.mkOption { | ||
| 189 | type = kdl.types.kdl-nodes; | ||
| 190 | default = []; | ||
| 191 | }; | ||
| 192 | key = lib.mkOption { | ||
| 193 | type = lib.types.nullOr lib.types.str; | ||
| 194 | default = null; | ||
| 195 | }; | ||
| 196 | moveKey = lib.mkOption { | ||
| 197 | type = lib.types.nullOr lib.types.str; | ||
| 198 | default = let | ||
| 199 | keys = lib.splitString "+" config.key; | ||
| 200 | defMoveKey = lib.concatStringsSep "+" (lib.flatten [ | ||
| 201 | (lib.take (lib.length keys - 1) keys) | ||
| 202 | ["Shift"] | ||
| 203 | (lib.takeEnd 1 keys) | ||
| 204 | ]); | ||
| 205 | in if config.key == null then null else defMoveKey; | ||
| 206 | }; | ||
| 207 | spawn = lib.mkOption { | ||
| 208 | type = lib.types.nullOr (lib.types.listOf lib.types.str); | ||
| 209 | default = null; | ||
| 210 | }; | ||
| 211 | app-id = lib.mkOption { | ||
| 212 | type = lib.types.nullOr lib.types.str; | ||
| 213 | default = null; | ||
| 214 | }; | ||
| 215 | selector = lib.mkOption { | ||
| 216 | type = lib.types.nullOr lib.types.str; | ||
| 217 | default = null; | ||
| 218 | }; | ||
| 219 | }; | ||
| 220 | |||
| 221 | config = lib.mkMerge [ | ||
| 222 | (lib.mkIf (config.app-id != null) { | ||
| 223 | match = lib.mkDefault [ { app-id = "^${lib.escapeRegex config.app-id}$"; } ]; | ||
| 224 | selector = lib.mkDefault "select(.app_id == \"${config.app-id}\")"; | ||
| 225 | }) | ||
| 226 | ]; | ||
| 227 | })); | ||
| 228 | default = []; | ||
| 229 | }; | ||
| 230 | }; | ||
| 231 | |||
| 232 | config = { | ||
| 233 | systemd.user.services.xwayland-satellite = { | ||
| 234 | Unit = { | ||
| 235 | BindsTo = [ "graphical-session.target" ]; | ||
| 236 | PartOf = [ "graphical-session.target" ]; | ||
| 237 | After = [ "graphical-session.target" ]; | ||
| 238 | Requisite = [ "graphical-session.target" ]; | ||
| 239 | }; | ||
| 240 | Service = { | ||
| 241 | Type = "notify"; | ||
| 242 | NotifyAccess = "all"; | ||
| 243 | Environment = [ "DISPLAY=:0" ]; | ||
| 244 | ExecStart = ''${lib.getExe pkgs.xwayland-satellite-unstable} ''${DISPLAY}''; | ||
| 245 | ExecStartPre = "${systemctl} --user import-environment DISPLAY"; | ||
| 246 | StandardOutput = "journal"; | ||
| 247 | }; | ||
| 248 | Install = { | ||
| 249 | WantedBy = [ "graphical-session.target" ]; | ||
| 250 | }; | ||
| 251 | }; | ||
| 252 | |||
| 253 | services.swayidle = { | ||
| 254 | events = [ | ||
| 255 | { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; } | ||
| 256 | ]; | ||
| 257 | timeouts = [ | ||
| 258 | { timeout = 540; | ||
| 259 | command = "${lib.getExe niri} msg action power-off-monitors"; | ||
| 260 | } | ||
| 261 | ]; | ||
| 262 | }; | ||
| 263 | |||
| 264 | systemd.user.sockets.niri-workspace-history = { | ||
| 265 | Socket = { | ||
| 266 | ListenStream = "%t/niri-workspace-history.sock"; | ||
| 267 | SocketMode = "0600"; | ||
| 268 | }; | ||
| 269 | }; | ||
| 270 | systemd.user.services.niri-workspace-history = { | ||
| 271 | Unit = { | ||
| 272 | BindsTo = [ "niri.service" ]; | ||
| 273 | After = [ "niri.service" ]; | ||
| 274 | }; | ||
| 275 | Install = { | ||
| 276 | WantedBy = [ "niri.service" ]; | ||
| 277 | }; | ||
| 278 | Service = { | ||
| 279 | Type = "simple"; | ||
| 280 | Sockets = [ "niri-workspace-history.socket" ]; | ||
| 281 | ExecStart = pkgs.writers.writePython3 "niri-workspace-history" { flakeIgnore = ["E501"]; } '' | ||
| 282 | import os | ||
| 283 | import socket | ||
| 284 | import json | ||
| 285 | # import sys | ||
| 286 | from collections import defaultdict | ||
| 287 | from threading import Thread, Lock | ||
| 288 | from socketserver import StreamRequestHandler, ThreadingTCPServer | ||
| 289 | from contextlib import contextmanager | ||
| 290 | from io import TextIOWrapper | ||
| 291 | |||
| 292 | |||
| 293 | @contextmanager | ||
| 294 | def detaching(thing): | ||
| 295 | try: | ||
| 296 | yield thing | ||
| 297 | finally: | ||
| 298 | thing.detach() | ||
| 299 | |||
| 300 | |||
| 301 | workspace_history = defaultdict(list) | ||
| 302 | history_lock = Lock() | ||
| 303 | |||
| 304 | |||
| 305 | def monitor_niri(): | ||
| 306 | workspaces = list() | ||
| 307 | |||
| 308 | def focus_workspace(output, workspace): | ||
| 309 | with history_lock: | ||
| 310 | workspace_history[output] = [workspace] + [ws for ws in workspace_history[output] if ws != workspace] | ||
| 311 | # print(json.dumps(workspace_history), file=sys.stderr) | ||
| 312 | |||
| 313 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
| 314 | sock.connect(os.environ["NIRI_SOCKET"]) | ||
| 315 | sock.send(b"\"EventStream\"\n") | ||
| 316 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
| 317 | if line_json := json.loads(line): | ||
| 318 | if "WorkspacesChanged" in line_json: | ||
| 319 | workspaces = line_json["WorkspacesChanged"]["workspaces"] | ||
| 320 | for ws in workspaces: | ||
| 321 | if ws["is_focused"]: | ||
| 322 | focus_workspace(ws["output"], ws["id"]) | ||
| 323 | if "WorkspaceActivated" in line_json: | ||
| 324 | for ws in workspaces: | ||
| 325 | if ws["id"] != line_json["WorkspaceActivated"]["id"]: | ||
| 326 | continue | ||
| 327 | focus_workspace(ws["output"], ws["id"]) | ||
| 328 | break | ||
| 329 | |||
| 330 | |||
| 331 | class RequestHandler(StreamRequestHandler): | ||
| 332 | def handle(self): | ||
| 333 | with detaching(TextIOWrapper(self.wfile, encoding='utf-8', write_through=True)) as out: | ||
| 334 | with history_lock: | ||
| 335 | json.dump(workspace_history, out) | ||
| 336 | |||
| 337 | |||
| 338 | class Server(ThreadingTCPServer): | ||
| 339 | def __init__(self): | ||
| 340 | ThreadingTCPServer.__init__(self, ("", 8000), RequestHandler, bind_and_activate=False) | ||
| 341 | self.socket = socket.fromfd(3, self.address_family, self.socket_type) | ||
| 342 | |||
| 343 | |||
| 344 | def run_server(): | ||
| 345 | with Server() as server: | ||
| 346 | server.serve_forever() | ||
| 347 | |||
| 348 | |||
| 349 | niri = Thread(target=monitor_niri) | ||
| 350 | niri.daemon = True | ||
| 351 | niri.start() | ||
| 352 | |||
| 353 | server_thread = Thread(target=run_server) | ||
| 354 | server_thread.daemon = True | ||
| 355 | server_thread.start() | ||
| 356 | |||
| 357 | while True: | ||
| 358 | server_thread.join(timeout=0.5) | ||
| 359 | niri.join(timeout=0.5) | ||
| 360 | |||
| 361 | if not (niri.is_alive() and server_thread.is_alive()): | ||
| 362 | break | ||
| 363 | ''; | ||
| 364 | }; | ||
| 365 | }; | ||
| 366 | systemd.user.services.niri-workspace-sort = { | ||
| 367 | Unit = { | ||
| 368 | BindsTo = [ "niri.service" ]; | ||
| 369 | After = [ "niri.service" ]; | ||
| 370 | }; | ||
| 371 | Install = { | ||
| 372 | WantedBy = [ "niri.service" ]; | ||
| 373 | }; | ||
| 374 | Service = { | ||
| 375 | Type = "simple"; | ||
| 376 | ExecStart = pkgs.writers.writePython3 "niri-workspace-sort" { flakeIgnore = ["E501"]; } '' | ||
| 377 | import os | ||
| 378 | import sys | ||
| 379 | import socket | ||
| 380 | import json | ||
| 381 | |||
| 382 | outputs = None | ||
| 383 | only = {'HDMI-A-1': {'bmr'}, 'eDP-1': {'vid'}} | ||
| 384 | |||
| 385 | |||
| 386 | class Niri(socket.socket): | ||
| 387 | def __init__(self): | ||
| 388 | super().__init__(socket.AF_UNIX, socket.SOCK_STREAM) | ||
| 389 | super().connect(os.environ["NIRI_SOCKET"]) | ||
| 390 | self.fh = super().makefile(mode='rw', buffering=1, encoding='utf-8') | ||
| 391 | |||
| 392 | def cmd(self, obj): | ||
| 393 | print(json.dumps(obj, separators=(',', ':')), flush=True, file=self.fh) | ||
| 394 | |||
| 395 | def event_stream(self): | ||
| 396 | self.cmd("EventStream") | ||
| 397 | return self.fh | ||
| 398 | |||
| 399 | |||
| 400 | with Niri() as niri, Niri().event_stream() as niri_stream: | ||
| 401 | for line in niri_stream: | ||
| 402 | workspaces = None | ||
| 403 | if line_json := json.loads(line): | ||
| 404 | if "WorkspacesChanged" in line_json: | ||
| 405 | workspaces = line_json["WorkspacesChanged"]["workspaces"] | ||
| 406 | |||
| 407 | if workspaces is None: | ||
| 408 | continue | ||
| 409 | |||
| 410 | old_outputs = outputs | ||
| 411 | outputs = {ws["output"] for ws in workspaces} | ||
| 412 | if old_outputs is None: | ||
| 413 | print("Initial outputs: {}".format(outputs), file=sys.stderr) | ||
| 414 | continue | ||
| 415 | |||
| 416 | new_outputs = outputs - old_outputs | ||
| 417 | if not new_outputs: | ||
| 418 | continue | ||
| 419 | print("New outputs: {}".format(new_outputs), file=sys.stderr) | ||
| 420 | |||
| 421 | relevant_workspaces = list(filter(lambda ws: (ws["name"] is not None) or (ws["active_window_id"] is not None), workspaces)) | ||
| 422 | target_output = next(iter(outputs - set(only.keys()))) | ||
| 423 | if not target_output: | ||
| 424 | continue | ||
| 425 | for ws in relevant_workspaces: | ||
| 426 | ws_ident = ws["name"] if ws["name"] is not None else (ws["output"], ws["idx"]) | ||
| 427 | if ws["output"] not in set(only.keys()): | ||
| 428 | continue | ||
| 429 | if ws_ident in only[ws["output"]]: | ||
| 430 | continue | ||
| 431 | |||
| 432 | print("{} -> {}".format(ws_ident, target_output), file=sys.stderr) | ||
| 433 | niri.cmd({"Action": {"MoveWorkspaceToMonitor": {"reference": {"Id": ws["id"]}, "output": target_output}}}) | ||
| 434 | ''; | ||
| 435 | Restart = "on-failure"; | ||
| 436 | RestartSec = 10; | ||
| 437 | }; | ||
| 438 | }; | ||
| 439 | |||
| 440 | programs.niri.scratchspaces = [ | ||
| 441 | { name = "pwctl"; | ||
| 442 | key = "Mod+Control+A"; | ||
| 443 | spawn = ["pwvucontrol"]; | ||
| 444 | app-id = "com.saivert.pwvucontrol"; | ||
| 445 | } | ||
| 446 | { name = "kpxc"; | ||
| 447 | exclude = [ | ||
| 448 | { title = "^Unlock Database.*"; } | ||
| 449 | { title = "^Access Request.*"; } | ||
| 450 | { title = ".*Passkey credentials$"; } | ||
| 451 | ]; | ||
| 452 | windowRuleExtra = [ | ||
| 453 | (kdl.leaf "open-focused" false) | ||
| 454 | ]; | ||
| 455 | key = "Mod+Control+P"; | ||
| 456 | app-id = "org.keepassxc.KeePassXC"; | ||
| 457 | spawn = [ "keepassxc" ]; | ||
| 458 | } | ||
| 459 | { name = "bmgr"; | ||
| 460 | key = "Mod+Control+B"; | ||
| 461 | app-id = ".blueman-manager-wrapped"; | ||
| 462 | spawn = [ "blueman-manager" ]; | ||
| 463 | } | ||
| 464 | { name = "term"; | ||
| 465 | key = "Mod+Control+Return"; | ||
| 466 | app-id = "kitty-scratch"; | ||
| 467 | spawn = [ "kitty" "--app-id" "kitty-scratch" ]; | ||
| 468 | } | ||
| 469 | { name = "edit"; | ||
| 470 | match = [ { title = "^scratch$"; app-id = "^emacs$"; } ]; | ||
| 471 | key = "Mod+Control+E"; | ||
| 472 | selector = "select(.app_id == \"emacs\" and .title == \"scratch\")"; | ||
| 473 | spawn = [ "emacsclient" "-c" "--frame-parameters=(quote (name . \"scratch\"))" ]; | ||
| 474 | } | ||
| 475 | { name = "eff"; | ||
| 476 | key = "Mod+Control+O"; | ||
| 477 | app-id = "com.github.wwmm.easyeffects"; | ||
| 478 | spawn = [ "easyeffects" ]; | ||
| 479 | } | ||
| 480 | ]; | ||
| 481 | programs.niri.config = | ||
| 482 | let | ||
| 483 | inherit (kdl) node plain leaf flag; | ||
| 484 | optional-node = cond: v: | ||
| 485 | if cond | ||
| 486 | then v | ||
| 487 | else null; | ||
| 488 | opt-props = lib.filterAttrs (lib.const (value: value != null)); | ||
| 489 | in | ||
| 490 | [ (flag "prefer-no-csd") | ||
| 491 | |||
| 492 | (leaf "screenshot-path" "~/screenshots/%Y-%m-%dT%H:%M:%S.png") | ||
| 493 | |||
| 494 | (plain "hotkey-overlay" [ | ||
| 495 | (flag "skip-at-startup") | ||
| 496 | ]) | ||
| 497 | |||
| 498 | (plain "input" [ | ||
| 499 | (plain "keyboard" [ | ||
| 500 | (leaf "repeat-delay" 300) | ||
| 501 | (leaf "repeat-rate" 50) | ||
| 502 | |||
| 503 | (plain "xkb" [ | ||
| 504 | (leaf "layout" "us,us") | ||
| 505 | (leaf "variant" "dvp,") | ||
| 506 | (leaf "options" "compose:caps,grp:win_space_toggle") | ||
| 507 | ]) | ||
| 508 | ]) | ||
| 509 | |||
| 510 | (flag "workspace-auto-back-and-forth") | ||
| 511 | # (leaf "focus-follows-mouse" {}) | ||
| 512 | # (flag "warp-mouse-to-focus") | ||
| 513 | |||
| 514 | # (plain "touchpad" [ (flag "off") ]) | ||
| 515 | (plain "trackball" [ | ||
| 516 | (leaf "scroll-method" "on-button-down") | ||
| 517 | (leaf "scroll-button" 278) | ||
| 518 | ]) | ||
| 519 | (plain "touch" [ | ||
| 520 | (leaf "map-to-output" "eDP-1") | ||
| 521 | ]) | ||
| 522 | ]) | ||
| 523 | |||
| 524 | (plain "gestures" [ | ||
| 525 | (plain "hot-corners" [(flag "off")]) | ||
| 526 | ]) | ||
| 527 | |||
| 528 | (plain "environment" (lib.mapAttrsToList leaf { | ||
| 529 | NIXOS_OZONE_WL = "1"; | ||
| 530 | QT_QPA_PLATFORM = "wayland"; | ||
| 531 | QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; | ||
| 532 | GDK_BACKEND = "wayland"; | ||
| 533 | SDL_VIDEODRIVER = "wayland"; | ||
| 534 | DISPLAY = ":0"; | ||
| 535 | ELECTRON_OZONE_PLATFORM_HINT = "auto"; | ||
| 536 | SSH_ASKPASS_REQUIRE = "prefer"; | ||
| 537 | SSH_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass; | ||
| 538 | SUDO_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass; | ||
| 539 | })) | ||
| 540 | |||
| 541 | (node "output" "eDP-1" [ | ||
| 542 | (leaf "scale" 1.5) | ||
| 543 | (leaf "position" { x = 0; y = 0; }) | ||
| 544 | ]) | ||
| 545 | (node "output" "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" [ | ||
| 546 | (leaf "scale" 1.5) | ||
| 547 | (leaf "position" { x = 2560; y = 0; }) | ||
| 548 | ]) | ||
| 549 | (node "output" "HP Inc. HP 727pu CN4417143K" [ | ||
| 550 | (leaf "mode" "2560x1440@119.998") | ||
| 551 | (leaf "scale" 1) | ||
| 552 | (leaf "position" { x = 2560; y = 0; }) | ||
| 553 | (flag "variable-refresh-rate") | ||
| 554 | ]) | ||
| 555 | |||
| 556 | (plain "debug" [ | ||
| 557 | (leaf "render-drm-device" "/dev/dri/by-path/pci-0000:00:02.0-render") | ||
| 558 | ]) | ||
| 559 | |||
| 560 | (plain "animations" [ | ||
| 561 | (leaf "slowdown" 0.5) | ||
| 562 | (plain "workspace-switch" [(flag "off")]) | ||
| 563 | ]) | ||
| 564 | |||
| 565 | (plain "layout" [ | ||
| 566 | (leaf "gaps" 8) | ||
| 567 | (plain "struts" [ | ||
| 568 | (leaf "left" 26) | ||
| 569 | (leaf "right" 26) | ||
| 570 | (leaf "top" 0) | ||
| 571 | (leaf "bottom" 0) | ||
| 572 | ]) | ||
| 573 | (plain "border" [ | ||
| 574 | (leaf "width" 2) | ||
| 575 | (leaf "active-gradient" { | ||
| 576 | from = "hsla(195 100% 45% 1)"; | ||
| 577 | to = "hsla(155 100% 37.5% 1)"; | ||
| 578 | angle = 29; | ||
| 579 | relative-to = "workspace-view"; | ||
| 580 | }) | ||
| 581 | (leaf "inactive-gradient" { | ||
| 582 | from = "hsla(0 0% 27.7% 1)"; | ||
| 583 | to = "hsla(0 0% 23% 1)"; | ||
| 584 | angle = 29; | ||
| 585 | relative-to = "workspace-view"; | ||
| 586 | }) | ||
| 587 | ]) | ||
| 588 | (plain "focus-ring" [ | ||
| 589 | (flag "off") | ||
| 590 | ]) | ||
| 591 | |||
| 592 | (plain "preset-column-widths" (map (prop: leaf "proportion" prop) [ | ||
| 593 | (1. / 4.) (1. / 3.) (1. / 2.) (2. / 3.) (3. / 4.) (1.) | ||
| 594 | ])) | ||
| 595 | (plain "default-column-width" [ (leaf "proportion" (1. / 2.)) ]) | ||
| 596 | (plain "preset-window-heights" (map (prop: leaf "proportion" prop) [ | ||
| 597 | (1. / 3.) (1. / 2.) (2. / 3.) (1.) | ||
| 598 | ])) | ||
| 599 | |||
| 600 | (flag "always-center-single-column") | ||
| 601 | |||
| 602 | (plain "tab-indicator" [ | ||
| 603 | (leaf "gap" 4) | ||
| 604 | (leaf "width" 8) | ||
| 605 | (leaf "gaps-between-tabs" 4) | ||
| 606 | (flag "place-within-column") | ||
| 607 | (leaf "length" { total-proportion = 1.; }) | ||
| 608 | (leaf "active-gradient" { | ||
| 609 | from = "hsla(195 100% 60% 0.75)"; | ||
| 610 | to = "hsla(155 100% 50% 0.75)"; | ||
| 611 | angle = 29; | ||
| 612 | relative-to = "workspace-view"; | ||
| 613 | }) | ||
| 614 | (leaf "inactive-gradient" { | ||
| 615 | from = "hsla(0 0% 42% 0.66)"; | ||
| 616 | to = "hsla(0 0% 35% 0.66)"; | ||
| 617 | angle = 29; | ||
| 618 | relative-to = "workspace-view"; | ||
| 619 | }) | ||
| 620 | ]) | ||
| 621 | ]) | ||
| 622 | |||
| 623 | (plain "cursor" [ | ||
| 624 | (flag "hide-when-typing") | ||
| 625 | ]) | ||
| 626 | |||
| 627 | (map (name: | ||
| 628 | (node "workspace" name [ | ||
| 629 | (leaf "open-on-output" "eDP-1") | ||
| 630 | ]) | ||
| 631 | ) (map ({name, ...}: name) cfg.scratchspaces)) | ||
| 632 | (map (name: | ||
| 633 | (leaf "workspace" name) | ||
| 634 | ) ["comm" "web" "vid" "bmr"]) | ||
| 635 | |||
| 636 | (plain "window-rule" [ | ||
| 637 | (leaf "clip-to-geometry" true) | ||
| 638 | ]) | ||
| 639 | |||
| 640 | (plain "window-rule" [ | ||
| 641 | (leaf "match" { is-floating = true; }) | ||
| 642 | (leaf "geometry-corner-radius" 8) | ||
| 643 | (plain "shadow" [ (flag "on") ]) | ||
| 644 | ]) | ||
| 645 | |||
| 646 | (plain "window-rule" [ | ||
| 647 | (leaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; }) | ||
| 648 | (leaf "block-out-from" "screencast") | ||
| 649 | ]) | ||
| 650 | (plain "window-rule" [ | ||
| 651 | (map (title: | ||
| 652 | (leaf "match" { app-id = "^org\\.keepassxc\\.KeePassXC$"; inherit title; }) | ||
| 653 | ) ["^Unlock Database.*" "^Access Request.*" ".*Passkey credentials$"]) | ||
| 654 | (leaf "open-focused" true) | ||
| 655 | (leaf "open-floating" true) | ||
| 656 | ]) | ||
| 657 | |||
| 658 | (map ({ name, match, exclude, windowRuleExtra, ... }: | ||
| 659 | (optional-node (match != []) (plain "window-rule" [ | ||
| 660 | (map (leaf "match") match) | ||
| 661 | (map (leaf "exclude") exclude) | ||
| 662 | (leaf "open-on-workspace" name) | ||
| 663 | (leaf "open-maximized" true) | ||
| 664 | windowRuleExtra | ||
| 665 | ])) | ||
| 666 | ) cfg.scratchspaces) | ||
| 667 | |||
| 668 | (plain "window-rule" [ | ||
| 669 | (leaf "match" { app-id = "^emacs$"; }) | ||
| 670 | (leaf "match" { app-id = "^firefox$"; }) | ||
| 671 | (plain "default-column-width" [(leaf "proportion" (2. / 3.))]) | ||
| 672 | ]) | ||
| 673 | (plain "window-rule" [ | ||
| 674 | (leaf "match" { app-id = "^kitty$"; }) | ||
| 675 | (leaf "match" { app-id = "^kitty-play$"; }) | ||
| 676 | (plain "default-column-width" [(leaf "proportion" (1. / 3.))]) | ||
| 677 | ]) | ||
| 678 | |||
| 679 | (plain "window-rule" [ | ||
| 680 | (leaf "match" { app-id = "^thunderbird$"; }) | ||
| 681 | (leaf "match" { app-id = "^Element$"; }) | ||
| 682 | (leaf "match" { app-id = "^Rainbow$"; }) | ||
| 683 | (leaf "open-on-workspace" "comm") | ||
| 684 | ]) | ||
| 685 | (plain "window-rule" [ | ||
| 686 | (leaf "match" { app-id = "^firefox$"; }) | ||
| 687 | (leaf "open-on-workspace" "web") | ||
| 688 | (leaf "open-maximized" true) | ||
| 689 | ]) | ||
| 690 | (plain "window-rule" [ | ||
| 691 | (leaf "match" { app-id = "^mpv$"; }) | ||
| 692 | (leaf "open-on-workspace" "vid") | ||
| 693 | (plain "default-column-width" [(leaf "proportion" 1.)]) | ||
| 694 | ]) | ||
| 695 | (plain "window-rule" [ | ||
| 696 | (leaf "match" { app-id = "^kitty-play$"; }) | ||
| 697 | (leaf "open-on-workspace" "vid") | ||
| 698 | (leaf "open-focused" false) | ||
| 699 | ]) | ||
| 700 | (plain "window-rule" [ | ||
| 701 | (leaf "match" { app-id = "^pdfpc$"; }) | ||
| 702 | (plain "default-column-width" [(leaf "proportion" 1.)]) | ||
| 703 | ]) | ||
| 704 | (plain "window-rule" [ | ||
| 705 | (leaf "match" { app-id = "^pdfpc$"; title = "^.*presentation.*$"; }) | ||
| 706 | (plain "default-column-width" [(leaf "proportion" 1.)]) | ||
| 707 | (leaf "open-fullscreen" true) | ||
| 708 | (leaf "open-on-workspace" "bmr") | ||
| 709 | (leaf "open-focused" false) | ||
| 710 | ]) | ||
| 711 | (plain "window-rule" [ | ||
| 712 | (map (leaf "match") [ | ||
| 713 | { app-id = "^Gimp-"; title = "^Quit GIMP$"; } | ||
| 714 | { app-id = "^org\\.kde\\.polkit-kde-authentication-agent-1$"; } | ||
| 715 | { app-id = "^xdg-desktop-portal-gtk$"; } | ||
| 716 | ]) | ||
| 717 | (leaf "open-floating" true) | ||
| 718 | ]) | ||
| 719 | (plain "window-rule" [ | ||
| 720 | (leaf "match" { app-id = "^org\\.pwmt\\.zathura$"; }) | ||
| 721 | (leaf "match" { app-id = "^evince$"; }) | ||
| 722 | (leaf "match" { app-id = "^org\\.gnome\\.Papers$"; }) | ||
| 723 | (leaf "default-column-display" "tabbed") | ||
| 724 | ]) | ||
| 725 | |||
| 726 | (plain "layer-rule" [ | ||
| 727 | (leaf "match" { namespace = "^notifications$"; }) | ||
| 728 | (leaf "match" { namespace = "^waybar$"; }) | ||
| 729 | (leaf "match" { namespace = "^launcher$"; }) | ||
| 730 | (leaf "block-out-from" "screencast") | ||
| 731 | ]) | ||
| 732 | |||
| 733 | (plain "binds" | ||
| 734 | (let | ||
| 735 | bind = name: cfg: node name (opt-props { | ||
| 736 | cooldown-ms = cfg.cooldown-ms or null; | ||
| 737 | } | ||
| 738 | // (lib.optionalAttrs (!(cfg.repeat or true)) { | ||
| 739 | repeat = false; | ||
| 740 | }) | ||
| 741 | // (lib.optionalAttrs (cfg.allow-when-locked or false) { | ||
| 742 | allow-when-locked = true; | ||
| 743 | })) (lib.mapAttrsToList leaf (lib.removeAttrs cfg.action ["__functor"])); | ||
| 744 | in | ||
| 745 | [ | ||
| 746 | (lib.mapAttrsToList bind (with config.lib.niri.actions; { | ||
| 747 | "Mod+Slash".action = show-hotkey-overlay; | ||
| 748 | |||
| 749 | "Mod+Return".action = spawn terminal; | ||
| 750 | "Mod+Shift+Return".action = | ||
| 751 | let | ||
| 752 | nushellKitty = pkgs.symlinkJoin { | ||
| 753 | name = "nushell-kitty"; | ||
| 754 | paths = [ config.programs.kitty.package ]; | ||
| 755 | buildInputs = [ pkgs.makeWrapper ]; | ||
| 756 | postBuild = '' | ||
| 757 | wrapProgram $out/bin/kitty \ | ||
| 758 | --add-flags "--config ${pkgs.writeText "kitty.conf" '' | ||
| 759 | include $HOME/${config.xdg.configFile."kitty/kitty.conf".target} | ||
| 760 | shell ${lib.getExe config.programs.nushell.package} | ||
| 761 | ''}" | ||
| 762 | ''; | ||
| 763 | }; | ||
| 764 | in spawn (lib.getExe' nushellKitty "kitty"); | ||
| 765 | "Mod+Q".action = close-window; | ||
| 766 | "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); | ||
| 767 | "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; | ||
| 768 | |||
| 769 | "Mod+Alt+E".action = spawn (lib.getExe' config.services.emacs.package "emacsclient") "-c"; | ||
| 770 | "Mod+Alt+Y".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
| 771 | name = "queue-yt-dlp"; | ||
| 772 | runtimeInputs = with pkgs; [ wl-clipboard-rs socat ]; | ||
| 773 | text = '' | ||
| 774 | socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' | ||
| 775 | ''; | ||
| 776 | })); | ||
| 777 | "Mod+Alt+L".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
| 778 | name = "queue-yt-dlp"; | ||
| 779 | runtimeInputs = with pkgs; [ wl-clipboard-rs config.programs.kitty.package ]; | ||
| 780 | text = '' | ||
| 781 | exec -- kitty --app-id kitty-play --directory "$HOME"/media mpv "$(wl-paste)" | ||
| 782 | ''; | ||
| 783 | })); | ||
| 784 | "Mod+Alt+M".action = spawn (lib.getExe' pkgs.screen-message "sm") "-n" "Fira Mono" "-a" "1" "-f" "#fff" "-b" "#000"; | ||
| 785 | |||
| 786 | "Mod+U".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
| 787 | name = "qalc-fuzzel"; | ||
| 788 | runtimeInputs = with pkgs; [ wl-clipboard-rs libqalculate config.programs.fuzzel.package coreutils findutils libnotify gnugrep ]; | ||
| 789 | text = '' | ||
| 790 | RESULTS_DIR="$HOME/.cache/qalc-fuzzel" | ||
| 791 | prev() { | ||
| 792 | FOUND=false | ||
| 793 | while IFS= read -r line; do | ||
| 794 | [[ -n "$line" ]] || continue | ||
| 795 | FOUND=true | ||
| 796 | echo "$line" | ||
| 797 | done < <(export LC_ALL=C.UTF-8; echo; find "$RESULTS_DIR" -type f -printf $'%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs -r cat) | ||
| 798 | $FOUND || echo | ||
| 799 | } | ||
| 800 | FUZZEL_RES=$(prev | fuzzel --dmenu --prompt "qalc> ") || exit $? | ||
| 801 | if [[ "$FUZZEL_RES" =~ .*\ =\ .* ]]; then | ||
| 802 | QALC_RES="$FUZZEL_RES" | ||
| 803 | QALC_RET=0 | ||
| 804 | else | ||
| 805 | QALC_RES=$(qalc "$FUZZEL_RES" 2>&1) | ||
| 806 | QALC_RET=$? | ||
| 807 | fi | ||
| 808 | [[ -n "$QALC_RES" ]] || exit 1 | ||
| 809 | EXISTING=false | ||
| 810 | set +o pipefail | ||
| 811 | grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch | ||
| 812 | [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true | ||
| 813 | set -o pipefail | ||
| 814 | if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then | ||
| 815 | set +o pipefail | ||
| 816 | RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' </dev/random | head -c 10) | ||
| 817 | set -o pipefail | ||
| 818 | cat >"$RES_FILE" <<<"$QALC_RES" | ||
| 819 | fi | ||
| 820 | [[ "$QALC_RES" =~ .*\ =\ (.*) ]] && QALC_RES="''${BASH_REMATCH[1]}" | ||
| 821 | [[ $QALC_RET -eq 0 ]] && wl-copy "$QALC_RES" | ||
| 822 | notify-send "$QALC_RES" | ||
| 823 | ''; | ||
| 824 | })); | ||
| 825 | "Mod+E".action = spawn (lib.getExe (pkgs.writeShellApplication { | ||
| 826 | name = "emoji-fuzzel"; | ||
| 827 | runtimeInputs = with pkgs; [ config.programs.fuzzel.package wtype wl-clipboard-rs ]; | ||
| 828 | text = '' | ||
| 829 | FUZZEL_RES=$(fuzzel --dmenu --prompt "emoji> " <"$HOME"/.local/share/emoji-data/list.txt) || exit $? | ||
| 830 | [[ -n "$FUZZEL_RES" ]] || exit 1 | ||
| 831 | wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste | ||
| 832 | ''; | ||
| 833 | })); | ||
| 834 | "Print".action = screenshot; | ||
| 835 | "Control+Print".action = screenshot-window; | ||
| 836 | "Shift+Print".action = kdl.magic-leaf "screenshot-screen"; | ||
| 837 | "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
| 838 | "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
| 839 | |||
| 840 | "Mod+Escape" = { | ||
| 841 | allow-inhibiting = false; | ||
| 842 | action = toggle-keyboard-shortcuts-inhibit; | ||
| 843 | }; | ||
| 844 | |||
| 845 | "Mod+H".action = focus-column-left; | ||
| 846 | "Mod+T".action = focus-window-down; | ||
| 847 | "Mod+N".action = focus-window-up; | ||
| 848 | "Mod+S".action = focus-column-right; | ||
| 849 | |||
| 850 | "Mod+Shift+H".action = move-column-left; | ||
| 851 | "Mod+Shift+T".action = move-window-down; | ||
| 852 | "Mod+Shift+N".action = move-window-up; | ||
| 853 | "Mod+Shift+S".action = move-column-right; | ||
| 854 | |||
| 855 | "Mod+Control+H".action = focus-monitor-left; | ||
| 856 | "Mod+Control+T".action = focus-monitor-down; | ||
| 857 | "Mod+Control+N".action = focus-monitor-up; | ||
| 858 | "Mod+Control+S".action = focus-monitor-right; | ||
| 859 | |||
| 860 | "Mod+Shift+Control+H".action = move-workspace-to-monitor-left; | ||
| 861 | "Mod+Shift+Control+T".action = move-workspace-to-monitor-down; | ||
| 862 | "Mod+Shift+Control+N".action = move-workspace-to-monitor-up; | ||
| 863 | "Mod+Shift+Control+S".action = move-workspace-to-monitor-right; | ||
| 864 | |||
| 865 | "Mod+G".action = focus-adjacent-workspace "down"; | ||
| 866 | "Mod+C".action = focus-adjacent-workspace "up"; | ||
| 867 | |||
| 868 | "Mod+Shift+G".action = move-column-to-adjacent-workspace "down"; | ||
| 869 | "Mod+Shift+C".action = move-column-to-adjacent-workspace "up"; | ||
| 870 | |||
| 871 | "Mod+Shift+Control+G".action = move-workspace-down; | ||
| 872 | "Mod+Shift+Control+C".action = move-workspace-up; | ||
| 873 | |||
| 874 | "Mod+ParenLeft".action = focus-workspace "comm"; | ||
| 875 | "Mod+Shift+ParenLeft".action = kdl.magic-leaf "move-column-to-workspace" "comm"; | ||
| 876 | |||
| 877 | "Mod+ParenRight".action = focus-workspace "web"; | ||
| 878 | "Mod+Shift+ParenRight".action = kdl.magic-leaf "move-column-to-workspace" "web"; | ||
| 879 | |||
| 880 | "Mod+BraceRight".action = focus-workspace "read"; | ||
| 881 | "Mod+Shift+BraceRight".action = kdl.magic-leaf "move-column-to-workspace" "read"; | ||
| 882 | |||
| 883 | "Mod+BraceLeft".action = focus-workspace "mon"; | ||
| 884 | "Mod+Shift+BraceLeft".action = kdl.magic-leaf "move-column-to-workspace" "mon"; | ||
| 885 | |||
| 886 | "Mod+Asterisk".action = focus-workspace "vid"; | ||
| 887 | "Mod+Shift+Asterisk".action = kdl.magic-leaf "move-column-to-workspace" "vid"; | ||
| 888 | |||
| 889 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | ||
| 890 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}, "focus": true}}}''; | ||
| 891 | |||
| 892 | "Mod+M".action = consume-or-expel-window-left; | ||
| 893 | "Mod+W".action = consume-or-expel-window-right; | ||
| 894 | |||
| 895 | "Mod+Shift+M".action = toggle-column-tabbed-display; | ||
| 896 | |||
| 897 | "Mod+R".action = switch-preset-column-width; | ||
| 898 | "Mod+Shift+R".action = maximize-column; | ||
| 899 | "Mod+Shift+Ctrl+R".action = switch-preset-window-height; | ||
| 900 | "Mod+F".action = center-column; | ||
| 901 | "Mod+Shift+F".action = toggle-windowed-fullscreen; | ||
| 902 | "Mod+Ctrl+Shift+F".action = fullscreen-window; | ||
| 903 | |||
| 904 | "Mod+V".action = switch-focus-between-floating-and-tiling; | ||
| 905 | "Mod+Shift+V".action = toggle-window-floating; | ||
| 906 | |||
| 907 | "Mod+Left".action = set-column-width "-10%"; | ||
| 908 | "Mod+Down".action = set-window-height "-10%"; | ||
| 909 | "Mod+Up".action = set-window-height "+10%"; | ||
| 910 | "Mod+Right".action = set-column-width "+10%"; | ||
| 911 | |||
| 912 | "Mod+Shift+Z" = { | ||
| 913 | action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; | ||
| 914 | allow-when-locked = true; | ||
| 915 | }; | ||
| 916 | "Mod+Shift+L".action = spawn loginctl "lock-session"; | ||
| 917 | "Mod+Shift+E".action = quit; | ||
| 918 | "Mod+Shift+Minus" = { | ||
| 919 | action = spawn systemctl "suspend"; | ||
| 920 | allow-when-locked = true; | ||
| 921 | }; | ||
| 922 | "Mod+Shift+Control+Minus" = { | ||
| 923 | action = spawn systemctl "hibernate"; | ||
| 924 | allow-when-locked = true; | ||
| 925 | }; | ||
| 926 | "Mod+Shift+P" = { | ||
| 927 | action = spawn (lib.getExe pkgs.playerctl) "-a" "pause"; | ||
| 928 | allow-when-locked = true; | ||
| 929 | }; | ||
| 930 | |||
| 931 | "XF86MonBrightnessUp" = { | ||
| 932 | action = spawn swayosd-client "--brightness" "raise"; | ||
| 933 | allow-when-locked = true; | ||
| 934 | }; | ||
| 935 | "XF86MonBrightnessDown" = { | ||
| 936 | action = spawn swayosd-client "--brightness" "lower"; | ||
| 937 | allow-when-locked = true; | ||
| 938 | }; | ||
| 939 | "XF86AudioRaiseVolume" = { | ||
| 940 | action = spawn swayosd-client "--output-volume" "raise"; | ||
| 941 | allow-when-locked = true; | ||
| 942 | }; | ||
| 943 | "XF86AudioLowerVolume" = { | ||
| 944 | action = spawn swayosd-client "--output-volume" "lower"; | ||
| 945 | allow-when-locked = true; | ||
| 946 | }; | ||
| 947 | "XF86AudioMute" = { | ||
| 948 | action = spawn swayosd-client "--output-volume" "mute-toggle"; | ||
| 949 | allow-when-locked = true; | ||
| 950 | }; | ||
| 951 | "XF86AudioMicMute" = { | ||
| 952 | action = spawn swayosd-client "--input-volume" "mute-toggle"; | ||
| 953 | allow-when-locked = true; | ||
| 954 | }; | ||
| 955 | |||
| 956 | "Mod+Semicolon".action = spawn makoctl "dismiss" "--group"; | ||
| 957 | "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all"; | ||
| 958 | "Mod+Period".action = spawn makoctl "menu" "--" (lib.getExe config.programs.fuzzel.package) "--dmenu"; | ||
| 959 | "Mod+Comma".action = spawn makoctl "restore"; | ||
| 960 | |||
| 961 | "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; | ||
| 962 | "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_id}, \"focus\": true}}}"; | ||
| 963 | |||
| 964 | "Mod+X".action = set-dynamic-cast-window; | ||
| 965 | "Mod+Shift+X".action = set-dynamic-cast-monitor; | ||
| 966 | "Mod+Control+Shift+X".action = clear-dynamic-cast-target; | ||
| 967 | |||
| 968 | "Mod+D".action = with-urgent-window-action "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; | ||
| 969 | "Mod+Shift+D".action = with-focused-window-action "{\"Action\":{\"UnsetUrgent\":{\"id\": .id}}}"; | ||
| 970 | })) | ||
| 971 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) | ||
| 972 | (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) | ||
| 973 | ] | ||
| 974 | )) | ||
| 975 | ]; | ||
| 976 | }; | ||
| 977 | } | ||
diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix deleted file mode 100644 index 810bff89..00000000 --- a/accounts/gkleen@sif/niri/mako.nix +++ /dev/null | |||
| @@ -1,112 +0,0 @@ | |||
| 1 | { config, lib, pkgs, ... }: | ||
| 2 | { | ||
| 3 | config = { | ||
| 4 | services.mako = { | ||
| 5 | enable = true; | ||
| 6 | settings = { | ||
| 7 | font = "Fira Sans 10"; | ||
| 8 | format = "<i>%s</i>\\n%b"; | ||
| 9 | margin = "2"; | ||
| 10 | max-visible = -1; | ||
| 11 | background-color = "#000000dd"; | ||
| 12 | progress-color = "source #223544ff"; | ||
| 13 | width = 384; | ||
| 14 | outer-margin = 1; | ||
| 15 | max-history = 100; | ||
| 16 | max-icon-size = 48; | ||
| 17 | }; | ||
| 18 | criteria = { | ||
| 19 | grouped.format = "<b>(%g)</b> <i>%s</i>\\n%b"; | ||
| 20 | "urgency=low".text-color = "#999999ff"; | ||
| 21 | "urgency=critical".background-color = "#900000dd"; | ||
| 22 | "app-name=Element".group-by = "summary"; | ||
| 23 | "app-name=poweralertd" = { | ||
| 24 | history = false; | ||
| 25 | ignore-timeout = true; | ||
| 26 | default-timeout = 2000; | ||
| 27 | }; | ||
| 28 | "mode=silent".invisible = true; | ||
| 29 | }; | ||
| 30 | package = pkgs.symlinkJoin { | ||
| 31 | name = "${pkgs.mako.name}-wrapped"; | ||
| 32 | paths = with pkgs; [ mako ]; | ||
| 33 | inherit (pkgs.mako) meta; | ||
| 34 | postBuild = '' | ||
| 35 | rm -r $out/share/dbus-1 | ||
| 36 | ''; | ||
| 37 | }; | ||
| 38 | }; | ||
| 39 | systemd.user.services.mako = { | ||
| 40 | Unit = { | ||
| 41 | Description = "Mako notification daemon"; | ||
| 42 | PartOf = [ "graphical-session.target" ]; | ||
| 43 | }; | ||
| 44 | Install = { | ||
| 45 | WantedBy = [ "graphical-session.target" ]; | ||
| 46 | }; | ||
| 47 | Service = { | ||
| 48 | Type = "dbus"; | ||
| 49 | BusName = "org.freedesktop.Notifications"; | ||
| 50 | ExecStart = lib.getExe config.services.mako.package; | ||
| 51 | RestartSec = 5; | ||
| 52 | Restart = "always"; | ||
| 53 | }; | ||
| 54 | }; | ||
| 55 | |||
| 56 | systemd.user.services.mako-follows-focus = { | ||
| 57 | Unit = { | ||
| 58 | BindsTo = [ "niri.service" "mako.service" ]; | ||
| 59 | After = [ "niri.service" "mako.service" ]; | ||
| 60 | }; | ||
| 61 | Service = { | ||
| 62 | Type = "simple"; | ||
| 63 | Restart = "always"; | ||
| 64 | ExecStart = pkgs.writers.writePython3 "mako-follows-focus" { | ||
| 65 | libraries = with pkgs.python3Packages; []; | ||
| 66 | } '' | ||
| 67 | import os | ||
| 68 | import socket | ||
| 69 | import json | ||
| 70 | import subprocess | ||
| 71 | |||
| 72 | |||
| 73 | current_output = None | ||
| 74 | workspaces = [] | ||
| 75 | |||
| 76 | |||
| 77 | def output_changed(new_output): | ||
| 78 | global current_output | ||
| 79 | |||
| 80 | if current_output == new_output: | ||
| 81 | return | ||
| 82 | |||
| 83 | current_output = new_output | ||
| 84 | subprocess.run(["makoctl", "reload"]) | ||
| 85 | |||
| 86 | |||
| 87 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
| 88 | sock.connect(os.environ["NIRI_SOCKET"]) | ||
| 89 | sock.send(b"\"EventStream\"\n") | ||
| 90 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
| 91 | if line_json := json.loads(line): | ||
| 92 | if "WorkspacesChanged" in line_json: | ||
| 93 | workspaces = line_json["WorkspacesChanged"]["workspaces"] | ||
| 94 | for workspace in workspaces: | ||
| 95 | if not workspace["is_focused"]: | ||
| 96 | continue | ||
| 97 | output_changed(workspace["output"]) | ||
| 98 | break | ||
| 99 | if "WorkspaceActivated" in line_json and line_json["WorkspaceActivated"]["focused"]: # noqa: E501 | ||
| 100 | for workspace in workspaces: | ||
| 101 | if not workspace["id"] == line_json["WorkspaceActivated"]["id"]: # noqa: E501 | ||
| 102 | continue | ||
| 103 | output_changed(workspace["output"]) | ||
| 104 | break | ||
| 105 | ''; | ||
| 106 | }; | ||
| 107 | Install = { | ||
| 108 | WantedBy = [ "mako.service" ]; | ||
| 109 | }; | ||
| 110 | }; | ||
| 111 | }; | ||
| 112 | } | ||
diff --git a/accounts/gkleen@sif/niri/swayosd.nix b/accounts/gkleen@sif/niri/swayosd.nix deleted file mode 100644 index 54ebb302..00000000 --- a/accounts/gkleen@sif/niri/swayosd.nix +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | { pkgs, ... }: | ||
| 2 | { | ||
| 3 | config = { | ||
| 4 | services.swayosd = { | ||
| 5 | enable = true; | ||
| 6 | topMargin = 0.4769706078; | ||
| 7 | stylePath = pkgs.runCommand "style.css" { | ||
| 8 | passAsFile = [ "src" ]; | ||
| 9 | src = '' | ||
| 10 | window#osd { | ||
| 11 | padding: 12px 20px; | ||
| 12 | border-radius: 999px; | ||
| 13 | border: none; | ||
| 14 | background: rgba(0, 0, 0, 0.87); | ||
| 15 | |||
| 16 | #container { | ||
| 17 | margin: 16px; | ||
| 18 | } | ||
| 19 | |||
| 20 | image, | ||
| 21 | label { | ||
| 22 | color: rgb(255, 255, 255); | ||
| 23 | |||
| 24 | &:disabled { | ||
| 25 | opacity: 1; | ||
| 26 | color: rgb(84, 84, 84); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | progressbar { | ||
| 31 | min-height: 6px; | ||
| 32 | border-radius: 999px; | ||
| 33 | background: transparent; | ||
| 34 | border: none; | ||
| 35 | |||
| 36 | trough, progress { | ||
| 37 | min-height: inherit; | ||
| 38 | border-radius: inherit; | ||
| 39 | border: none; | ||
| 40 | } | ||
| 41 | |||
| 42 | trough { | ||
| 43 | background: rgb(127, 127, 127); | ||
| 44 | } | ||
| 45 | progress { | ||
| 46 | background: rgb(255, 255, 255); | ||
| 47 | } | ||
| 48 | |||
| 49 | &:disabled { | ||
| 50 | opacity: 1; | ||
| 51 | |||
| 52 | trough { | ||
| 53 | background: rgb(19, 19, 19); | ||
| 54 | } | ||
| 55 | progress { | ||
| 56 | background: rgb(38, 38, 38); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } | ||
| 61 | ''; | ||
| 62 | buildInputs = with pkgs; [sass]; | ||
| 63 | } "scss -C --sourcemap=none --style=compact $srcPath $out"; | ||
| 64 | }; | ||
| 65 | }; | ||
| 66 | } | ||
diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix deleted file mode 100644 index cc131c08..00000000 --- a/accounts/gkleen@sif/niri/waybar.nix +++ /dev/null | |||
| @@ -1,347 +0,0 @@ | |||
| 1 | { lib, config, pkgs, ... }: | ||
| 2 | let | ||
| 3 | swayosd-client = lib.getExe' config.services.swayosd.package "swayosd-client"; | ||
| 4 | in { | ||
| 5 | config = { | ||
| 6 | programs.waybar = { | ||
| 7 | enable = true; | ||
| 8 | systemd = { | ||
| 9 | enable = true; | ||
| 10 | target = "graphical-session.target"; | ||
| 11 | }; | ||
| 12 | settings = let | ||
| 13 | windowRewrites = { | ||
| 14 | "(.*) — Mozilla Firefox" = "$1"; | ||
| 15 | "(.*) - Mozilla Thunderbird" = "$1"; | ||
| 16 | "(.*) - mpv" = "$1"; | ||
| 17 | }; | ||
| 18 | iconSize = 11; | ||
| 19 | in [ | ||
| 20 | { | ||
| 21 | layer = "top"; | ||
| 22 | position = "top"; | ||
| 23 | height = 21; | ||
| 24 | output = [ "eDP-1" "DP-2" "DP-3" ]; | ||
| 25 | modules-left = [ "niri/workspaces" ]; | ||
| 26 | modules-center = [ "niri/window" ]; | ||
| 27 | modules-right = [ "custom/worktime" "custom/worktime-today" | ||
| 28 | "custom/weather" | ||
| 29 | "custom/keymap" | ||
| 30 | "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "custom/mako" "clock" ]; | ||
| 31 | |||
| 32 | "custom/mako" = { | ||
| 33 | format = "{}"; | ||
| 34 | return-type = "json"; | ||
| 35 | exec = pkgs.writers.writePython3 "mako-silent" { libraries = [ pkgs.python3Packages.dbus-next ]; } '' | ||
| 36 | from dbus_next.aio import MessageBus | ||
| 37 | |||
| 38 | import asyncio | ||
| 39 | |||
| 40 | import json | ||
| 41 | |||
| 42 | |||
| 43 | loop = asyncio.new_event_loop() | ||
| 44 | asyncio.set_event_loop(loop) | ||
| 45 | |||
| 46 | |||
| 47 | async def main(): | ||
| 48 | bus = await MessageBus().connect() | ||
| 49 | # the introspection xml would normally be included in your project, but | ||
| 50 | # this is convenient for development | ||
| 51 | introspection = await bus.introspect('org.freedesktop.Notifications', '/fr/emersion/Mako') # noqa: E501 | ||
| 52 | |||
| 53 | obj = bus.get_proxy_object('org.freedesktop.Notifications', '/fr/emersion/Mako', introspection) # noqa: E501 | ||
| 54 | mako = obj.get_interface('fr.emersion.Mako') | ||
| 55 | properties = obj.get_interface('org.freedesktop.DBus.Properties') | ||
| 56 | |||
| 57 | async def print_mode(): | ||
| 58 | modes = await mako.get_modes() | ||
| 59 | is_silent = "silent" in modes | ||
| 60 | icon = "󰂛" if is_silent else "󰂚" | ||
| 61 | text = f"<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>" # noqa: E501 | ||
| 62 | if is_silent: | ||
| 63 | text = f"<span color=\"#ffffff\">{text}</span>" | ||
| 64 | print(json.dumps({'text': text, 'tooltip': ', '.join(modes)}, separators=(',', ':')), flush=True) # noqa: E501 | ||
| 65 | |||
| 66 | async def on_properties_changed(interface_name, changed_properties, invalidated_properties): # noqa: E501 | ||
| 67 | if "Modes" not in invalidated_properties: | ||
| 68 | return | ||
| 69 | |||
| 70 | await print_mode() | ||
| 71 | |||
| 72 | properties.on_properties_changed(on_properties_changed) | ||
| 73 | await print_mode() | ||
| 74 | |||
| 75 | await loop.create_future() | ||
| 76 | |||
| 77 | |||
| 78 | loop.run_until_complete(main()) | ||
| 79 | ''; | ||
| 80 | on-click = "makoctl mode -t silent"; | ||
| 81 | }; | ||
| 82 | "custom/weather" = { | ||
| 83 | format = "{}"; | ||
| 84 | tooltip = true; | ||
| 85 | interval = 3600; | ||
| 86 | exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --nerd --custom-indicator \"<span font=\\\"Symbols Nerd Font Mono\\\" size=\\\"100%\\\">{ICON}</span> {FeelsLikeC}°\""; | ||
| 87 | return-type = "json"; | ||
| 88 | }; | ||
| 89 | "custom/keymap" = { | ||
| 90 | format = "{}"; | ||
| 91 | tooltip = true; | ||
| 92 | return-type = "json"; | ||
| 93 | exec = pkgs.writers.writePython3 "keymap" {} '' | ||
| 94 | import os | ||
| 95 | import socket | ||
| 96 | import json | ||
| 97 | |||
| 98 | |||
| 99 | def output(keymap): | ||
| 100 | short = keymap | ||
| 101 | if keymap == "English (programmer Dvorak)": | ||
| 102 | short = "dvp" | ||
| 103 | elif keymap == "English (US)": | ||
| 104 | short = "<span color=\"#ffffff\">us</span>" | ||
| 105 | print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 | ||
| 106 | |||
| 107 | |||
| 108 | keyboard_layouts = [] | ||
| 109 | |||
| 110 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
| 111 | sock.connect(os.environ["NIRI_SOCKET"]) | ||
| 112 | sock.send(b"\"EventStream\"\n") | ||
| 113 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
| 114 | if line_json := json.loads(line): | ||
| 115 | if "KeyboardLayoutsChanged" in line_json: | ||
| 116 | keyboard_layouts = line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["names"] # noqa: E501 | ||
| 117 | output(keyboard_layouts[line_json["KeyboardLayoutsChanged"]["keyboard_layouts"]["current_idx"]]) # noqa: E501 | ||
| 118 | if "KeyboardLayoutSwitched" in line_json: | ||
| 119 | output(keyboard_layouts[line_json["KeyboardLayoutSwitched"]["idx"]]) # noqa: E501 | ||
| 120 | ''; | ||
| 121 | on-click = "niri msg action switch-layout next"; | ||
| 122 | }; | ||
| 123 | "custom/worktime" = { | ||
| 124 | interval = 60; | ||
| 125 | exec = "${lib.getExe pkgs.worktime} time --waybar"; | ||
| 126 | return-type = "json"; | ||
| 127 | }; | ||
| 128 | "custom/worktime-today" = { | ||
| 129 | interval = 60; | ||
| 130 | exec = "${lib.getExe pkgs.worktime} today --waybar"; | ||
| 131 | return-type = "json"; | ||
| 132 | }; | ||
| 133 | "niri/workspaces" = { | ||
| 134 | ignore = map ({ name, ... }: name) config.programs.niri.scratchspaces; | ||
| 135 | }; | ||
| 136 | "niri/window" = { | ||
| 137 | separate-outputs = true; | ||
| 138 | icon = true; | ||
| 139 | icon-size = 14; | ||
| 140 | rewrite = windowRewrites; | ||
| 141 | }; | ||
| 142 | clock = { | ||
| 143 | interval = 1; | ||
| 144 | # timezone = "Europe/Berlin"; | ||
| 145 | format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
| 146 | tooltip-format = "<tt><small>{calendar}</small></tt>"; | ||
| 147 | calendar = { | ||
| 148 | mode = "year"; | ||
| 149 | mode-mon-col = 3; | ||
| 150 | weeks-pos = "left"; | ||
| 151 | on-scroll = 1; | ||
| 152 | format = { | ||
| 153 | months = "<span color='#ffead3'><b>{}</b></span>"; | ||
| 154 | days = "{}"; | ||
| 155 | weeks = "<span color='#99ffdd'><b>{}</b></span>"; | ||
| 156 | weekdays = "<span color='#ffcc66'><b>{}</b></span>"; | ||
| 157 | today = "<span color='#ff6699'><b>{}</b></span>"; | ||
| 158 | }; | ||
| 159 | }; | ||
| 160 | }; | ||
| 161 | battery = { | ||
| 162 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 163 | icon-size = iconSize - 2; | ||
| 164 | states = { warning = 30; critical = 15; }; | ||
| 165 | format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ]; | ||
| 166 | format-charging = "󰂄"; | ||
| 167 | format-plugged = "󰚥"; | ||
| 168 | tooltip-format = "{capacity}% {timeTo}"; | ||
| 169 | interval = 20; | ||
| 170 | }; | ||
| 171 | tray = { | ||
| 172 | icon-size = 16; | ||
| 173 | # show-passive-items = true; | ||
| 174 | spacing = 1; | ||
| 175 | }; | ||
| 176 | privacy = { | ||
| 177 | icon-spacing = 7; | ||
| 178 | icon-size = iconSize; | ||
| 179 | modules = [ | ||
| 180 | { type = "screenshare"; } | ||
| 181 | { type = "audio-in"; } | ||
| 182 | ]; | ||
| 183 | }; | ||
| 184 | idle_inhibitor = { | ||
| 185 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 186 | icon-size = iconSize; | ||
| 187 | format-icons = { activated = "󰈈"; deactivated = "󰈉"; }; | ||
| 188 | timeout = 120; | ||
| 189 | }; | ||
| 190 | backlight = { | ||
| 191 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 192 | icon-size = iconSize; | ||
| 193 | tooltip-format = "{percent}%"; | ||
| 194 | format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"]; | ||
| 195 | on-scroll-up = "${swayosd-client} --brightness raise"; | ||
| 196 | on-scroll-down = "${swayosd-client} --brightness lower"; | ||
| 197 | }; | ||
| 198 | wireplumber = { | ||
| 199 | format = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">{icon}</span>"; | ||
| 200 | icon-size = iconSize; | ||
| 201 | tooltip-format = "{volume}% {node_name}"; | ||
| 202 | format-icons = ["󰕿" "󰖀" "󰕾"]; | ||
| 203 | format-muted = "<span font=\"Symbols Nerd Font Mono\" size=\"90%\">󰝟</span>"; | ||
| 204 | # ignored-sinks = ["Easy Effects Sink"]; | ||
| 205 | on-scroll-up = "${swayosd-client} --output-volume raise"; | ||
| 206 | on-scroll-down = "${swayosd-client} --output-volume lower"; | ||
| 207 | on-click = "${swayosd-client} --output-volume mute-toggle"; | ||
| 208 | }; | ||
| 209 | } | ||
| 210 | { | ||
| 211 | layer = "top"; | ||
| 212 | position = "top"; | ||
| 213 | height = 14; | ||
| 214 | output = [ "!eDP-1" "!DP-2" "!DP-3" ]; | ||
| 215 | modules-left = [ "niri/workspaces" ]; | ||
| 216 | modules-center = [ "niri/window" ]; | ||
| 217 | modules-right = [ "clock" ]; | ||
| 218 | |||
| 219 | "niri/workspaces" = { | ||
| 220 | ignore = map ({ name, ... }: name) config.programs.niri.scratchspaces; | ||
| 221 | }; | ||
| 222 | "niri/window" = { | ||
| 223 | separate-outputs = true; | ||
| 224 | icon = true; | ||
| 225 | icon-size = 14; | ||
| 226 | rewrite = windowRewrites; | ||
| 227 | }; | ||
| 228 | clock = { | ||
| 229 | interval = 1; | ||
| 230 | # timezone = "Europe/Berlin"; | ||
| 231 | format = "{:%H:%M}"; | ||
| 232 | tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}"; | ||
| 233 | }; | ||
| 234 | } | ||
| 235 | ]; | ||
| 236 | style = '' | ||
| 237 | @define-color white #ffffff; | ||
| 238 | @define-color grey #555555; | ||
| 239 | @define-color blue #1a8fff; | ||
| 240 | @define-color green #23fd00; | ||
| 241 | @define-color orange #f28a21; | ||
| 242 | @define-color red #f2201f; | ||
| 243 | |||
| 244 | * { | ||
| 245 | border: none; | ||
| 246 | font-family: "Fira Sans"; | ||
| 247 | font-size: 10pt; | ||
| 248 | min-height: 0; | ||
| 249 | } | ||
| 250 | |||
| 251 | window#waybar { | ||
| 252 | background-color: rgba(0, 0, 0, 0.66); | ||
| 253 | color: @white; | ||
| 254 | } | ||
| 255 | |||
| 256 | .modules-left { | ||
| 257 | margin-left: 38px; | ||
| 258 | } | ||
| 259 | .modules-right { | ||
| 260 | margin-right: 38px; | ||
| 261 | } | ||
| 262 | |||
| 263 | .module { | ||
| 264 | margin: 0 5px; | ||
| 265 | } | ||
| 266 | |||
| 267 | #workspaces button { | ||
| 268 | color: @white; | ||
| 269 | padding: 2px 5px; | ||
| 270 | } | ||
| 271 | #workspaces button.empty { | ||
| 272 | color: @grey; | ||
| 273 | } | ||
| 274 | #workspaces button.active { | ||
| 275 | color: @green; | ||
| 276 | } | ||
| 277 | #workspaces button.urgent { | ||
| 278 | color: @red; | ||
| 279 | } | ||
| 280 | |||
| 281 | #custom-weather, #custom-keymap, #custom-worktime, #custom-worktime-today { | ||
| 282 | color: @grey; | ||
| 283 | margin: 0 5px; | ||
| 284 | } | ||
| 285 | #custom-weather { | ||
| 286 | margin-right: 3px; | ||
| 287 | } | ||
| 288 | #custom-keymap { | ||
| 289 | margin-left: 3px; | ||
| 290 | margin-right: 3px; | ||
| 291 | } | ||
| 292 | |||
| 293 | #tray { | ||
| 294 | margin: 0; | ||
| 295 | } | ||
| 296 | #battery, #idle_inhibitor, #backlight, #wireplumber, #custom-mako { | ||
| 297 | color: @grey; | ||
| 298 | margin: 0 5px 0 2px; | ||
| 299 | } | ||
| 300 | #idle_inhibitor { | ||
| 301 | margin-right: 4px; | ||
| 302 | margin-left: 6px; | ||
| 303 | } | ||
| 304 | #custom-mako { | ||
| 305 | margin-right: 2px; | ||
| 306 | margin-left: 3px; | ||
| 307 | } | ||
| 308 | #battery { | ||
| 309 | margin-right: 3px; | ||
| 310 | } | ||
| 311 | #battery.discharging { | ||
| 312 | color: @white; | ||
| 313 | } | ||
| 314 | #battery.warning { | ||
| 315 | color: @orange; | ||
| 316 | } | ||
| 317 | #battery.critical { | ||
| 318 | color: @red; | ||
| 319 | } | ||
| 320 | #battery.charging { | ||
| 321 | color: @white; | ||
| 322 | } | ||
| 323 | #idle_inhibitor.activated { | ||
| 324 | color: @white; | ||
| 325 | } | ||
| 326 | #custom-worktime.running, #custom-worktime-today.running { | ||
| 327 | color: @white; | ||
| 328 | } | ||
| 329 | #custom-worktime.over, #custom-worktime-today.over { | ||
| 330 | color: @orange; | ||
| 331 | } | ||
| 332 | |||
| 333 | #idle_inhibitor { | ||
| 334 | padding-top: 1px; | ||
| 335 | } | ||
| 336 | |||
| 337 | #privacy { | ||
| 338 | color: @red; | ||
| 339 | margin: -1px 4px 0px 3px; | ||
| 340 | } | ||
| 341 | #clock { | ||
| 342 | /* margin-right: 5px; */ | ||
| 343 | } | ||
| 344 | ''; | ||
| 345 | }; | ||
| 346 | }; | ||
| 347 | } | ||
