From c241d3bfd3381edd3f8ebd7a310bfb8b68740b75 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Tue, 19 Sep 2023 22:14:47 +0200 Subject: [PATCH] pinwheel: Extract `dunst` to module --- hosts/pinwheel/configuration.nix | 1 + hosts/pinwheel/home.nix | 2 -- hosts/pinwheel/modules/dunst/default.nix | 42 +++++++++++++++++++++++ hosts/pinwheel/modules/waybar/default.nix | 22 ++++++++++-- 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 hosts/pinwheel/modules/dunst/default.nix diff --git a/hosts/pinwheel/configuration.nix b/hosts/pinwheel/configuration.nix index bb1e4ba..4e06ead 100644 --- a/hosts/pinwheel/configuration.nix +++ b/hosts/pinwheel/configuration.nix @@ -21,6 +21,7 @@ ./modules/hyprland ./modules/waybar ./modules/swaylock + ./modules/dunst ./modules/bemenu ./modules/syncthing ./modules/firefox diff --git a/hosts/pinwheel/home.nix b/hosts/pinwheel/home.nix index c23ea9a..4039f78 100644 --- a/hosts/pinwheel/home.nix +++ b/hosts/pinwheel/home.nix @@ -10,8 +10,6 @@ home.username = "alex"; home.homeDirectory = "/home/alex"; - services.dunst.enable = true; - home.packages = with pkgs; [ gnumake tig diff --git a/hosts/pinwheel/modules/dunst/default.nix b/hosts/pinwheel/modules/dunst/default.nix new file mode 100644 index 0000000..331ad4d --- /dev/null +++ b/hosts/pinwheel/modules/dunst/default.nix @@ -0,0 +1,42 @@ + +{ pkgs, ... }: +{ + home-manager.users.alex = { + services.dunst = { + enable = true; + + settings = { + global = { + width = 300; + height = 300; + offset = "10x50"; + origin = "top-right"; + transparency = 10; + frame_color = "#a57b06"; + font = "DejaVuSansM Nerd Font Mono 14"; + }; + + urgency_low = { + background = "#222222"; + foreground = "#888888"; + timeout = 10; + }; + + urgency_normal = { + background = "#262626"; + foreground = "#f9c22b"; + timeout = 10; + }; + + urgency_critical = { + background = "#900000"; + foreground = "#ffffff"; + frame_color = "#ff0000"; + timeout = 10; + }; + }; + }; + + home.packages = [ pkgs.libnotify ]; + }; +} diff --git a/hosts/pinwheel/modules/waybar/default.nix b/hosts/pinwheel/modules/waybar/default.nix index 8889d24..2af24c0 100644 --- a/hosts/pinwheel/modules/waybar/default.nix +++ b/hosts/pinwheel/modules/waybar/default.nix @@ -23,6 +23,17 @@ let fi ''; + notifications-status = pkgs.writeShellScript "notifications-status" '' + if ${pkgs.dunst}/bin/dunstctl is-paused | grep -q "false"; then + echo 󰂚; + else + DISABLED=󰂛 + COUNT=$(${pkgs.dunst}/bin/dunstctl count waiting) + [ $COUNT != 0 ] && DISABLED="󰂛 $COUNT" + echo $DISABLED + fi + ''; + toggle-bt-power = pkgs.writeShellScript "toggle-bt-power" '' POWERED_ON=$(bluetoothctl show | grep "Powered: yes") if [ -z "$POWERED_ON" ]; then @@ -49,7 +60,7 @@ in ]; modules-left = [ "hyprland/workspaces" ]; - modules-right = [ "custom/spotify" "bluetooth" "wireplumber" "network" "battery" "clock" ]; + modules-right = [ "custom/spotify" "custom/dunst" "bluetooth" "wireplumber" "network" "battery" "clock" ]; "custom/spotify" = { exec = spotify-status; @@ -57,6 +68,13 @@ in tooltip = false; }; + "custom/dunst" = { + exec = notifications-status; + on-click-right = "${pkgs.dunst}/bin/dunstctl set-paused toggle"; + interval = 1; + tooltip = false; + }; + bluetooth = { "format-off" = "󰂲"; "format-on" = ""; @@ -117,7 +135,7 @@ in background-color: ${background}; } - #custom-spotify, #bluetooth, #wireplumber, #network, #battery, #clock { + #custom-spotify, #custom-dunst, #bluetooth, #wireplumber, #network, #battery, #clock { margin: 0 12px; } '';