From e0c1827b079ffea61965e0ea957930865514bc10 Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Sat, 17 Feb 2024 11:17:51 +0100 Subject: [PATCH] Waybar config + use swaync on hyprland --- instances/freya/hm.nix | 1 - instances/odin/hm.nix | 1 - instances/thor/hm.nix | 3 +- modules/hm/bspwm.nix | 1 + modules/hm/hyprland.nix | 6 ++ modules/hm/swaynotificationcenter.nix | 92 +++++++++++++++++++++++++ modules/hm/waybar.nix | 98 +++++++++++++++++++++++++++ 7 files changed, 198 insertions(+), 4 deletions(-) create mode 100644 modules/hm/swaynotificationcenter.nix diff --git a/instances/freya/hm.nix b/instances/freya/hm.nix index 0fdd590..4e48c84 100644 --- a/instances/freya/hm.nix +++ b/instances/freya/hm.nix @@ -15,7 +15,6 @@ ../../modules/hm/__basic.nix ../../modules/hm/cava.nix - ../../modules/hm/dunst.nix ../../modules/hm/helix.nix ../../modules/hm/kitty.nix ../../modules/hm/syncthing.nix diff --git a/instances/odin/hm.nix b/instances/odin/hm.nix index 8b912e9..056c03a 100644 --- a/instances/odin/hm.nix +++ b/instances/odin/hm.nix @@ -102,7 +102,6 @@ ../../modules/hm/blender.nix # ../../modules/hm/bspwm.nix ../../modules/hm/cava.nix - ../../modules/hm/dunst.nix # ../../modules/hm/dwarf-fortress.nix ../../modules/hm/easyeffects.nix ../../modules/hm/firefox.nix diff --git a/instances/thor/hm.nix b/instances/thor/hm.nix index 17f54ec..8aa5ec5 100644 --- a/instances/thor/hm.nix +++ b/instances/thor/hm.nix @@ -30,7 +30,7 @@ # pulseaudio pulseaudio # retroarchFull - # shotwell + # shotwell # signal-desktop skypeforlinux # slack @@ -90,7 +90,6 @@ ../../modules/hm/blender_nvidia.nix # ../../modules/hm/bspwm.nix ../../modules/hm/cava.nix - ../../modules/hm/dunst.nix # ../../modules/hm/dwarf-fortress.nix ../../modules/hm/easyeffects.nix ../../modules/hm/firefox.nix diff --git a/modules/hm/bspwm.nix b/modules/hm/bspwm.nix index 6fb8d4f..484804c 100644 --- a/modules/hm/bspwm.nix +++ b/modules/hm/bspwm.nix @@ -20,6 +20,7 @@ in ./sxhkd.nix ./update_background.nix ./xidlehook.nix + ./dunst.nix ]; home.packages = builtins.attrValues { diff --git a/modules/hm/hyprland.nix b/modules/hm/hyprland.nix index 842b34f..b201dd7 100644 --- a/modules/hm/hyprland.nix +++ b/modules/hm/hyprland.nix @@ -5,6 +5,8 @@ ./nautilus.nix ./nemo.nix ./waybar.nix + # ./dunst.nix + ./swaynotificationcenter.nix ./wl_update_background.nix ]; @@ -18,6 +20,10 @@ After = [ "graphical-session.target" ]; }; + systemd.user.services."swaynotificationcenter".Unit = { + Description = "Run "; + }; + xdg.configFile."hypr/hyprland.conf".text = let strPalette = pkgs.lib.nix-rice.palette.toRgbaShortHex pkgs.rice.colorPalette; diff --git a/modules/hm/swaynotificationcenter.nix b/modules/hm/swaynotificationcenter.nix new file mode 100644 index 0000000..a8fcbe3 --- /dev/null +++ b/modules/hm/swaynotificationcenter.nix @@ -0,0 +1,92 @@ +{ pkgs, ... }: { + systemd.user.services.swaynotificationcenter = { + Unit = { + After = [ "graphical-session-pre.target" ]; + # Description = pkgs.swaynotificationcenter.meta.description; + PartOf = [ "graphical-session.target" ]; + }; + Install.WantedBy = [ "graphical-session.target" ]; + Service = { + ExecStart = "${pkgs.swaynotificationcenter}/bin/swaync"; + # ExecRestart = "${pkgs.swaynotificationcenter}/bin/swaync-client -R"; + # KillMode = "mixed"; + # Restart = "on-failure"; + }; + }; + + xdg.configFile."swaync/config.json".text = '' + { + "$schema": "/etc/xdg/swaync/configSchema.json", + "positionX": "right", + "positionY": "top", + "control-center-margin-top": 16, + "control-center-margin-bottom": 16, + "control-center-margin-right": 16, + "notification-icon-size": 64, + "notification-body-image-height": 100, + "notification-body-image-width": 200, + "timeout": 10, + "timeout-low": 5, + "timeout-critical": 0, + "fit-to-screen": true, + "control-center-width": 500, + "control-center-height": 1000, + "notification-window-width": 500, + "keyboard-shortcuts": true, + "image-visibility": "when-available", + "transition-time": 200, + "hide-on-clear": false, + "hide-on-action": true, + "script-fail-notify": true, + "widgets": ["buttons-grid", "mpris", "volume", "title", "notifications"], + "widget-config": { + "title": { + "text": "Notifications", + "clear-all-button": true, + "button-text": "󰆴 Clear" + }, + "dnd": { + "text": "Do Not Disturb" + }, + "label": { + "max-lines": 1, + "text": "Notification Center" + }, + "mpris": { + "image-size": 96, + "image-radius": 7 + }, + "volume": { + "label": "" + }, + "backlight": { + "label": "󰃟" + }, + "buttons-grid": { + "actions": [ + { + "label": "󰐥", + "command": "systemctl poweroff" + }, + { + "label": "󰜉", + "command": "systemctl reboot" + }, + { + "label": "󰍃", + "command": "hyprctl dispatch exit" + }, + { + "label": "", + "command": "firefox bitwarden.serpentian.net" + }, + { + "label": "󰖂", + "command": "firefox vpn.serpentian.net" + } + ] + } + } + } + ''; +} diff --git a/modules/hm/waybar.nix b/modules/hm/waybar.nix index 1b0c8a0..b65ab38 100644 --- a/modules/hm/waybar.nix +++ b/modules/hm/waybar.nix @@ -1,3 +1,20 @@ +{ pkgs, ... }: +let + inherit (pkgs.rice) colorPalette; + inherit (pkgs.lib) nix-rice; + alpha = 0.9; + custom = nix-rice.palette.toRGBHex { + inherit (colorPalette.primary) background foreground; + alpha_background = nix-rice.color.setAlphaRgba alpha colorPalette.primary.background; + primary_accent = colorPalette.normal.blue; + secondary_accent = colorPalette.normal.cyan; + tertiary_accent = colorPalette.primary.yellow; + palette = { + primary_background_rgba = colorPalette.primary.background; + tertiary_background_hex = nix-rice.color.setAlphaRgba alpha colorPalette.primary.background; + }; + }; +in { programs.waybar = { enable = true; @@ -25,8 +42,26 @@ "battery#bat2" "clock" "tray" + "custom/notification" ]; + "custom/notification" = { + tooltip = "false"; + format = "{} {icon}"; + format-icons = { + notification = ""; + none = ""; + dnd-notification = ""; + dnd-none = ""; + }; + return-type = "json"; + exec-if = "which swaync-client"; + exec = "${pkgs.swaynotificationcenter}/bin/swaync-client -swb"; + on-click = "sleep 0.1 && ${pkgs.swaynotificationcenter}/bin/swaync-client -t -sw"; + on-click-right = "sleep 0.1 && ${pkgs.swaynotificationcenter}/bin/swaync-client -d -sw"; + escape = true; + }; + "keyboard-state" = { "numlock" = true; "capslock" = true; @@ -106,5 +141,68 @@ }; }; }; + style = '' + * { + border: none; + border-radius: 0px; + font-family: ${pkgs.rice.font.monospace.name}; + font-size: 10px; + min-height: 0; + } + window#waybar { + background: ${custom.alpha_background}; + } + #workspaces { + background: ${custom.background}; + margin: 0 5px; + padding: 0.5em; + border-radius: 0.5em; + color: ${custom.primary_accent} + } + #workspaces button { + padding: 0.5em; + margin: 0px 3px; + border-radius: 0.5em; + color: ${custom.primary_accent}; + background: ${custom.background}; + transition: all 0.3s ease-in-out; + } + + #workspaces button.active { + background-color: ${custom.secondary_accent}; + color: ${custom.background}; + border-radius: 0.5em; + min-width: 3em; + background-size: 400% 400%; + transition: all 0.3s ease-in-out; + } + + #workspaces button:hover { + background-color: ${custom.foreground}; + color: ${custom.background}; + border-radius: 0.5em; + min-width: 3em; + background-size: 400% 400%; + } + + #tray, #pulseaudio, #network, #language, #custom-notification { + background: ${custom.background}; + font-weight: bold; + font-size: 10px; + margin: 0px 5px; + } + #tray, #pulseaudio, #network, #language, #custom-notification, #cpu, #memory, #temperature, #keyboard-state, #backlight, #battery, #battery#bat2, #clock { + color: ${custom.foreground}; + border-radius: 0.5em; + padding: 0.5em; + margin-left: 7px; + } + #clock { + background: ${custom.alpha_background}; + } + #window{ + background: ${custom.palette.tertiary_background_hex}; + } + ''; }; }