From 37e55957fbf411b928184465acb2b1ecd5ca6852 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 17 Jan 2025 22:20:56 +0100 Subject: mako --- accounts/gkleen@sif/niri/default.nix | 29 +++++++++--------- accounts/gkleen@sif/niri/mako.nix | 28 +++++++++++++++++ accounts/gkleen@sif/niri/waybar.nix | 58 ++++++++++++++++++++++++++++++++++-- 3 files changed, 99 insertions(+), 16 deletions(-) create mode 100644 accounts/gkleen@sif/niri/mako.nix (limited to 'accounts/gkleen@sif/niri') diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 841c972a..cc6c85c3 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -4,7 +4,7 @@ let terminal = lib.getExe config.programs.kitty.package; lightctl = lib.getExe' config.services.avizo.package "lightctl"; volumectl = lib.getExe' config.services.avizo.package "volumectl"; - dunstctl = lib.getExe' config.services.dunst.package "dunstctl"; + makoctl = lib.getExe' config.services.mako.package "makoctl"; loginctl = lib.getExe' hostConfig.systemd.package "loginctl"; systemctl = lib.getExe' hostConfig.systemd.package "systemctl"; @@ -121,6 +121,7 @@ let in { imports = [ ./waybar.nix + ./mako.nix ]; config = { @@ -244,13 +245,13 @@ in { }; window-rules = [ - { - geometry-corner-radius = - let - allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; }; - in allCorners 4.; - clip-to-geometry = true; - } + # { + # geometry-corner-radius = + # let + # allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; }; + # in allCorners 4.; + # clip-to-geometry = true; + # } { matches = [ { app-id = "^com\.saivert\.pwvucontrol$"; } ]; open-on-workspace = "pwctl"; @@ -264,7 +265,7 @@ in { excludes = [ { title = "^Unlock Database.*"; } { title = "^Access Request.*"; } - { title = "^Passkey credentials.*"; } + { title = ".*Passkey credentials$"; } ]; open-on-workspace = "kpxc"; open-focused = false; @@ -273,7 +274,7 @@ in { matches = [ { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Unlock Database.*"; } { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Access Request.*"; } - { app-id = "^org\.keepassxc\.KeePassXC$"; title = "^Passkey credentials.*"; } + { app-id = "^org\.keepassxc\.KeePassXC$"; title = ".*Passkey credentials$"; } ]; open-focused = true; } @@ -519,10 +520,10 @@ in { allow-when-locked = true; }; - "Mod+Semicolon".action = spawn dunstctl "close"; - "Mod+Shift+Semicolon".action = spawn dunstctl "close-all"; - "Mod+Period".action = spawn dunstctl "context"; - "Mod+Comma".action = spawn dunstctl "history-pop"; + "Mod+Semicolon".action = spawn makoctl "dismiss"; + "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all"; + "Mod+Period".action = spawn makoctl (lib.getExe config.programs.fuzzel.package) "--dmenu"; + "Mod+Comma".action = spawn makoctl "restore"; "Mod+Control+A".action = focus-or-spawn-action-app_id "com.saivert.pwvucontrol" "pwctl" "pwvucontrol"; "Mod+Control+P".action = focus-or-spawn-action-app_id "org.keepassxc.KeePassXC" "kpxc" "keepassxc"; diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix new file mode 100644 index 00000000..7e31f7e1 --- /dev/null +++ b/accounts/gkleen@sif/niri/mako.nix @@ -0,0 +1,28 @@ +{ config, lib, ... }: +{ + config = { + services.mako = { + enable = true; + font = "Fira Sans 10"; + format = "%s\\n%b"; + margin = "2"; + maxVisible = -1; + backgroundColor = "#000000dd"; + progressColor = "source #223544ff"; + width = 384; + extraConfig = '' + outer-margin=1 + max-history=100 + + [urgency=low] + text-color=#999999ff + + [urgency=critical] + background-color=#900000dd + + [mode=silent] + invisible=1 + ''; + }; + }; +} diff --git a/accounts/gkleen@sif/niri/waybar.nix b/accounts/gkleen@sif/niri/waybar.nix index ff48ba83..26e76a1d 100644 --- a/accounts/gkleen@sif/niri/waybar.nix +++ b/accounts/gkleen@sif/niri/waybar.nix @@ -25,8 +25,58 @@ modules-right = [ # "custom/worktime" "custom/worktime-today" "custom/weather" "custom/keymap" - "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "clock" ]; + "privacy" "tray" "wireplumber" "backlight" "battery" "idle_inhibitor" "custom/mako" "clock" ]; + "custom/mako" = { + format = "{}"; + return-type = "json"; + exec = pkgs.writers.writePython3 "mako-silent" { libraries = [ pkgs.python3Packages.dbus-next ]; } '' + from dbus_next.aio import MessageBus + + import asyncio + + import json + + + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + + + async def main(): + bus = await MessageBus().connect() + # the introspection xml would normally be included in your project, but + # this is convenient for development + introspection = await bus.introspect('org.freedesktop.Notifications', '/fr/emersion/Mako') # noqa: E501 + + obj = bus.get_proxy_object('org.freedesktop.Notifications', '/fr/emersion/Mako', introspection) # noqa: E501 + mako = obj.get_interface('fr.emersion.Mako') + properties = obj.get_interface('org.freedesktop.DBus.Properties') + + async def print_mode(): + modes = await mako.get_modes() + is_silent = "silent" in modes + icon = "󰂛" if is_silent else "󰂚" + text = f"{icon}" # noqa: E501 + if is_silent: + text = f"{text}" + print(json.dumps({'text': text}, separators=(',', ':')), flush=True) # noqa: E501 + + async def on_properties_changed(interface_name, changed_properties, invalidated_properties): # noqa: E501 + if "Modes" not in invalidated_properties: + return + + await print_mode() + + properties.on_properties_changed(on_properties_changed) + await print_mode() + + await loop.create_future() + + + loop.run_until_complete(main()) + ''; + on-click = "makoctl mode -t silent"; + }; "custom/weather" = { format = "{}"; tooltip = true; @@ -240,11 +290,15 @@ #tray { margin: 0; } - #battery, #idle_inhibitor, #backlight, #wireplumber { + #battery, #idle_inhibitor, #backlight, #wireplumber, #custom-mako { color: @grey; margin: 0 5px 0 2px; } #idle_inhibitor { + margin-right: 4px; + margin-left: 6px; + } + #custom-mako { margin-right: 2px; margin-left: 3px; } -- cgit v1.2.3