diff options
Diffstat (limited to 'accounts/gkleen@sif')
-rw-r--r-- | accounts/gkleen@sif/default.nix | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index eea4088a..6b6c7e59 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix | |||
@@ -359,7 +359,7 @@ in { | |||
359 | output = "eDP-1"; | 359 | output = "eDP-1"; |
360 | modules-left = [ "hyprland/workspaces" ]; | 360 | modules-left = [ "hyprland/workspaces" ]; |
361 | modules-center = [ "hyprland/window" ]; | 361 | modules-center = [ "hyprland/window" ]; |
362 | modules-right = [ "custom/weather" "clock" "privacy" "tray" "pulseaudio" "backlight" "battery" "idle_inhibitor" ]; | 362 | modules-right = [ "custom/weather" "custom/keymap" "clock" "privacy" "tray" "pulseaudio" "backlight" "battery" "idle_inhibitor" ]; |
363 | 363 | ||
364 | "custom/weather" = { | 364 | "custom/weather" = { |
365 | format = "{}"; | 365 | format = "{}"; |
@@ -368,6 +368,41 @@ in { | |||
368 | exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --custom-indicator \"{ICON} {FeelsLikeC}°\""; | 368 | exec = "${lib.getExe pkgs.wttrbar} --hide-conditions --custom-indicator \"{ICON} {FeelsLikeC}°\""; |
369 | return-type = "json"; | 369 | return-type = "json"; |
370 | }; | 370 | }; |
371 | "custom/keymap" = { | ||
372 | format = "{}"; | ||
373 | tooltip = true; | ||
374 | return-type = "json"; | ||
375 | exec = pkgs.writers.writePython3 "keymap" {} '' | ||
376 | import os | ||
377 | import socket | ||
378 | import re | ||
379 | import subprocess | ||
380 | import json | ||
381 | |||
382 | |||
383 | def output(keymap): | ||
384 | short = keymap | ||
385 | if keymap == "English (programmer Dvorak)": | ||
386 | short = "dvp" | ||
387 | elif keymap == "English (US)": | ||
388 | short = "us" | ||
389 | print(json.dumps({'text': short, 'tooltip': keymap}, separators=(',', ':')), flush=True) # noqa: E501 | ||
390 | |||
391 | |||
392 | r = subprocess.run(["hyprctl", "devices", "-j"], check=True, stdout=subprocess.PIPE, text=True) # noqa: E501 | ||
393 | for keyboard in json.loads(r.stdout)['keyboards']: | ||
394 | if keyboard['name'] != "at-translated-set-2-keyboard": | ||
395 | continue | ||
396 | output(keyboard['active_keymap']) | ||
397 | |||
398 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
399 | sock.connect(os.environ["XDG_RUNTIME_DIR"] + "/hypr/" + os.environ["HYPRLAND_INSTANCE_SIGNATURE"] + "/.socket2.sock") # noqa: E501 | ||
400 | expected = re.compile(r'^activelayout>>at-translated-set-2-keyboard,(?P<keymap>.+)$') # noqa: E501 | ||
401 | for line in sock.makefile(buffering=1, encoding='utf-8'): | ||
402 | if match := expected.match(line): | ||
403 | output(match.group("keymap")) | ||
404 | ''; | ||
405 | }; | ||
371 | "hyprland/workspaces" = { | 406 | "hyprland/workspaces" = { |
372 | all-outputs = true; | 407 | all-outputs = true; |
373 | }; | 408 | }; |
@@ -512,7 +547,7 @@ in { | |||
512 | color: @red; | 547 | color: @red; |
513 | } | 548 | } |
514 | 549 | ||
515 | #custom-weather { | 550 | #custom-weather, #custom-keymap { |
516 | color: @white; | 551 | color: @white; |
517 | opacity: 0.33; | 552 | opacity: 0.33; |
518 | } | 553 | } |