From 4f9ea610d645a583e3d22316bce4256e1ce26d61 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Thu, 28 Aug 2025 23:11:34 +0200 Subject: [PATCH] change for waybar Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- home/scripts/caffeine/default.nix | 8 +- home/scripts/hyprfocus/default.nix | 3 + home/scripts/night-shift/default.nix | 10 +- home/scripts/system/default.nix | 4 +- home/system/hyprland/bindings.nix | 15 +- home/system/waybar/default.nix | 310 +++++++++++++++++++++++++++ home/system/waybar/swaync.nix | 105 +++++++++ home/system/waybar/swayosd.nix | 93 ++++++++ hosts/laptop/home.nix | 5 +- 9 files changed, 522 insertions(+), 31 deletions(-) create mode 100644 home/system/waybar/default.nix create mode 100644 home/system/waybar/swaync.nix create mode 100644 home/system/waybar/swayosd.nix diff --git a/home/scripts/caffeine/default.nix b/home/scripts/caffeine/default.nix index d07cc06..8941223 100644 --- a/home/scripts/caffeine/default.nix +++ b/home/scripts/caffeine/default.nix @@ -17,14 +17,10 @@ caffeine = pkgs.writeShellScriptBin "caffeine" '' if [[ $(pidof "hypridle") ]]; then systemctl --user stop hypridle.service - title="󰅶 Caffeine Activated" - description="Caffeine is now active! Your screen will not turn off automatically." + ${pkgs.swayosd}/bin/swayosd-client --custom-message="Caffeine On" --custom-icon="emblem-default" else systemctl --user start hypridle.service - title="󰾪 Caffeine Deactivated" - description="Caffeine is now deactivated! Your screen will turn off automatically." + ${pkgs.swayosd}/bin/swayosd-client --custom-message="Caffeine Off" --custom-icon="emblem-default" fi - - notif "caffeine" "$title" "$description" ''; in {home.packages = [caffeine-status caffeine caffeine-status-icon];} diff --git a/home/scripts/hyprfocus/default.nix b/home/scripts/hyprfocus/default.nix index 1b6197d..3dfb55b 100644 --- a/home/scripts/hyprfocus/default.nix +++ b/home/scripts/hyprfocus/default.nix @@ -25,6 +25,7 @@ keyword decoration:active_opacity 1" echo "1" > /tmp/hyprfocus + ${pkgs.swayosd}/bin/swayosd-client --custom-message="Hyprfocus On" --custom-icon="emblem-default" ''; hyprfocus-off = @@ -34,6 +35,8 @@ hyprctl reload hyprpanel-show rm /tmp/hyprfocus + + ${pkgs.swayosd}/bin/swayosd-client --custom-message="Hyprfocus Off" --custom-icon="emblem-default" ''; hyprfocus-toggle = diff --git a/home/scripts/night-shift/default.nix b/home/scripts/night-shift/default.nix index 328c084..1c6ca82 100644 --- a/home/scripts/night-shift/default.nix +++ b/home/scripts/night-shift/default.nix @@ -16,10 +16,7 @@ # bash '' ${pkgs.hyprsunset}/bin/hyprsunset -t ${value} & - title="󰖔 Night-Shift Activated" - description="Night-Shift is now activated! Your screen will be warmer and easier on the eyes." - - notif "night-shift" "$title" "$description" + ${pkgs.swayosd}/bin/swayosd-client --custom-message="Night-Shift On" --custom-icon="emblem-default" ''; night-shift-off = @@ -27,10 +24,7 @@ # bash '' pkill hyprsunset - title="󰖕 Night-Shift Deactivated" - description="Night-Shift is now deactivated! Your screen will return to normal." - - notif "night-shift" "$title" "$description" + ${pkgs.swayosd}/bin/swayosd-client --custom-message="Night-Shift Off" --custom-icon="emblem-default" ''; night-shift = diff --git a/home/scripts/system/default.nix b/home/scripts/system/default.nix index ec688b5..9035632 100644 --- a/home/scripts/system/default.nix +++ b/home/scripts/system/default.nix @@ -121,10 +121,10 @@ current_profile=$(powerprofilesctl get) if [ "$current_profile" = "performance" ]; then powerprofilesctl set balanced - notif "powermode" "󰗑 Balanced Mode Activated" "Enjoy the balance!" + ${pkgs.swayosd}/bin/swayosd-client --custom-message="Powermode set to balanced" --custom-icon="emblem-default" else powerprofilesctl set performance - notif "powermode" "󱐋 Performance Mode Activated" "Enjoy the power!" + ${pkgs.swayosd}/bin/swayosd-client --custom-message="Powermode set to performance" --custom-icon="emblem-default" fi ''; in {home.packages = [menu powermenu lock quickmenu powermode-toggle];} diff --git a/home/system/hyprland/bindings.nix b/home/system/hyprland/bindings.nix index f785606..da043a4 100644 --- a/home/system/hyprland/bindings.nix +++ b/home/system/hyprland/bindings.nix @@ -36,8 +36,8 @@ "$shiftMod,T, exec, hyprpanel-toggle" # Toggle hyprpanel "$shiftMod,C, exec, clipboard" # Clipboard picker with wofi "$shiftMod,E, exec, ${pkgs.wofi-emoji}/bin/wofi-emoji" # Emoji picker with wofi - "$mod,F2, exec, night-shift" # Toggle night shift - "$mod,F3, exec, night-shift" # Toggle night shift + "$shiftMod,F2, exec, night-shift" # Toggle night shift + "$shiftMod,F3, exec, night-shift" # Toggle night shift ] ++ (builtins.concatLists (builtins.genList (i: let ws = i + 1; @@ -53,18 +53,7 @@ ]; bindl = [ - ",XF86AudioMute, exec, sound-toggle" # Toggle Mute - ",XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause" # Play/Pause Song - ",XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl next" # Next Song - ",XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl previous" # Previous Song ",switch:Lid Switch, exec, ${pkgs.hyprlock}/bin/hyprlock" # Lock when closing Lid ]; - - bindle = [ - ",XF86AudioRaiseVolume, exec, sound-up" # Sound Up - ",XF86AudioLowerVolume, exec, sound-down" # Sound Down - ",XF86MonBrightnessUp, exec, brightness-up" # Brightness Up - ",XF86MonBrightnessDown, exec, brightness-down" # Brightness Down - ]; }; } diff --git a/home/system/waybar/default.nix b/home/system/waybar/default.nix new file mode 100644 index 0000000..7d33509 --- /dev/null +++ b/home/system/waybar/default.nix @@ -0,0 +1,310 @@ +{ + config, + pkgs, + ... +}: { + imports = [ + ./swaync.nix + ./swayosd.nix + ]; + + wayland.windowManager.hyprland.settings.exec-once = ["waybar" "${pkgs.networkmanagerapplet}/bin/nm-applet" "${pkgs.blueman}/bin/blueman-applet"]; + + programs.waybar = { + enable = true; + systemd.enable = true; + settings.mainBar = { + spacing = 5; + margin-bottom = -11; + + modules-left = ["hyprland/workspaces" "hyprland/window"]; + modules-center = ["cava"]; + modules-right = [ + "group/extras" + "pulseaudio" + "battery" + "custom/notification" + "clock" + ]; + + battery = { + states = {critical = 20;}; + format = "{icon}"; + format-icons = { + default = ["󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"]; + charging = ["󰢜" "󰂆" "󰂇" "󰂈" "󰢝" "󰂉" "󰢞" "󰂊" "󰂋" "󰂅"]; + }; + format-full = "󱟢"; + on-click = "powermode-toggle"; + on-click-right = ''${pkgs.swayosd}/bin/swayosd-client --custom-message="Powermode is set to $(powerprofilesctl get)" --custom-icon="emblem-default"''; + }; + + cava = { + framerate = 240; + bars = 20; + bar_delimiter = 0; + stereo = true; + input_delay = 4; + sleep_timer = 2; + hide_on_silence = true; + lower_cutoff_freq = 100; + higher_cutoff_freq = 8000; + format-icons = ["▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"]; + }; + + clock = { + timezone = "Europe/Paris"; + tooltip-format = "{calendar}"; + calendar = { + mode = "month"; + format = { + today = "{}"; + days = "{}"; + weekdays = "{}"; + months = "{}"; + }; + }; + interval = 60; + max-length = 25; + on-click = "brave --profile-directory=Default --app-id=ojibjkjikcpjonjjngfkegflhmffeemk"; # Proton Calendar + }; + + "custom/arrow-toggle" = { + format = " {icon} "; + format-icons = {default = "";}; + tooltip = false; + }; + + "custom/notification" = { + tooltip = false; + format = "{icon} {}"; + format-icons = { + notification = "󰂚"; + none = "󰂜"; + dnd-notification = "󰂚"; + dnd-none = "󰂜"; + inhibited-notification = "󰂚"; + inhibited-none = "󰂜"; + dnd-inhibited-notification = "󰂚"; + dnd-inhibited-none = "󰂜"; + }; + return-type = "json"; + exec-if = "which swaync-client"; + exec = "swaync-client -swb"; + on-click = "swaync-client -t"; + escape = true; + }; + + "group/extras" = { + orientation = "inherit"; + drawer = { + transition-duration = 300; + transitition-left-to-right = false; + }; + modules = ["custom/arrow-toggle" "tray"]; + }; + + "hyprland/window" = { + format = "{}"; + rewrite = {"^(.*?)[[:space:]]*[-—|].*?$" = "$1";}; + icon = true; + icon-size = 20; + max-length = 30; + }; + + "hyprland/workspaces" = { + format = "{icon}"; + format-active = " {icon} "; + all-outputs = true; + }; + + network = { + format = "{ifname}"; + format-wifi = "{icon} {essid}"; + format-ethernet = "󰈀 Ethernet"; + format-disconnected = " 󰤭 Disconnected "; + tooltip-format = "{ipaddr}  {bandwidthUpBits}  {bandwidthDownBits}"; + format-linked = "󰈁 {ifname} (No IP)"; + format-icons = ["󰤯" "󰤟" "󰤢" "󰤥" "󰤨"]; + on-click = "kitty --class nmtui-float-term nmtui"; + }; + + pulseaudio = { + format = "{icon}"; + format-muted = "󰖁"; + format-icons = ["󰕿" "󰖀" "󰕾"]; + on-click = "sound-toggle"; + scroll-step = 1; + }; + + tray = {spacing = 10;}; + }; + + style = '' + window#waybar { + background-color: transparent; + } + + #workspaces{ + background-color: transparent; + margin-top: 10px; + margin-bottom: 10px; + margin-right: 10px; + margin-left: 25px; + } + #workspaces button{ + background-color: #${config.lib.stylix.colors.base05}; + color: #${config.lib.stylix.colors.base00}; + box-shadow: rgba(0, 0, 0, 0.116) 2 2 5 2px; + border-radius: 15px; + margin-right: 10px; + padding-top: 4px; + padding-bottom: 2px; + padding-right: 10px; + font-weight: bolder; + } + + .modules-left #workspaces button { + border-bottom: 0px; + } + + #workspaces button.active{ + padding-right: 20px; + box-shadow: rgba(0, 0, 0, 0.288) 2 2 5 2px; + text-shadow: 0 0 5px rgba(0, 0, 0, 0.377); + padding-left: 20px; + background: #${config.lib.stylix.colors.base0D}; + color: #${config.lib.stylix.colors.base05}; + } + + .modules-left #workspaces button.focused, + .modules-left #workspaces button.active { + border-bottom: 0px; + } + + #window { + color: #${config.theme.textColorOnWallpaper}; + } + + #clock, + #battery, + #network, + #pulseaudio, + #tray, + #cava, + #custom-notification, + #mpd { + padding: 0 10px; + border-radius: 15px; + background-color: #${config.lib.stylix.colors.base05}; + color: #${config.lib.stylix.colors.base00}; + box-shadow: rgba(0, 0, 0, 0.116) 2 2 5 2px; + margin-top: 10px; + margin-bottom: 10px; + margin-right: 10px; + } + + #cava{ + background: #${config.lib.stylix.colors.base0D}; + color: #${config.lib.stylix.colors.base05}; + text-shadow: 0 0 5px rgba(0, 0, 0, 0.377); + font-weight: 900; + padding-top: 0px; + margin-left: 10px; + } + + #pulseaudio, + #pulseaudio.muted{ + color: #${config.lib.stylix.colors.base0D}; + font-size: 20px; + font-weight: bolder; + padding-left: 14px; + padding-right: 15px; + border-radius: 15px; + } + + #clock { + background: #${config.lib.stylix.colors.base0D}; + color: #${config.lib.stylix.colors.base05}; + margin-right: 25px; + background-size: 300% 300%; + text-shadow: 0 0 5px rgba(0, 0, 0, 0.377); + font-size: 15px; + padding-top: 5px; + padding-right: 21px; + font-weight: bolder; + padding-left: 20px + } + + #battery { + color: #86a381; + font-size: 17px; + padding-left: 15px; + padding-right: 15px; + border-radius: 15px; + } + + @keyframes blink { + to { + background-color: #f9e2af; + color:#96804e; + } + } + + #battery.critical:not(.charging) { + background-color: #f38ba8; + color:#bf5673; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; + } + + #network{ + color:#000; + } + + #network.disabled{ + background-color: #45475a; + } + + #network.disconnected{ + background: rgb(243,139,168); + color: #fff; + font-weight: bolder; + } + + #network.linked, #network.wifi{ + background-color: #a6e3a1 ; + } + + #network.ethernet{ + background-color:#f9e2af ; + } + + #tray { + background-color: #1c1816; + } + + #tray > .passive { + -gtk-icon-effect: dim; + } + + #custom-arrow-toggle { + font-size: 16px; + color: #516079; + opacity: 1; + transition: opacity 0.2s ease-in-out; + } + + #extras:hover #custom-arrow-toggle { + opacity: 0; + } + + #extras:hover { + background-color: transparent; + } + ''; + }; +} diff --git a/home/system/waybar/swaync.nix b/home/system/waybar/swaync.nix new file mode 100644 index 0000000..4a25547 --- /dev/null +++ b/home/system/waybar/swaync.nix @@ -0,0 +1,105 @@ +{ + services.swaync = { + enable = true; + settings = { + control-center-layer = "top"; + control-center-width = 400; + control-center-height = 400; + control-center-margin-top = 10; + control-center-margin-bottom = 250; + control-center-margin-right = 10; + + notification-window-width = 380; + notification-icon-size = 48; + notification-body-image-height = 80; + notification-body-image-width = 160; + notification-2fa-action = true; + notification-grouping = false; + + image-visibility = "when-available"; + transition-time = 100; + + widgets = [ "dnd" "mpris" "notifications" ]; + + widget-config = { + inhibitors = { + text = "Inhibitors"; + button-text = "Clear All"; + clear-all-button = true; + }; + title = { + text = "Notifications"; + clear-all-button = true; + button-text = "Clear All"; + }; + dnd = { text = "Do Not Disturb"; }; + mpris = { + image-size = 64; + blur = true; + }; + }; + }; + style = '' + .notification, + .notification.low, + .notification.normal, + .notification.critical, + .notification-default-action, + .notification-default-action:hover, + .notification-default-action:active, + .notification-row:focus, + .notification-group:focus, + .notification-group.collapsed .notification-row .notification, + .control-center .notification-row .notification-background, + .control-center .notification-row .notification-background:hover, + .control-center .notification-row .notification-background:active { + background: transparent; + border: none; + outline: none; + box-shadow: none; + margin: 0; + padding: 0; + } + + .control-center { + background: @base00; + border: 1px solid @base0D; + color: @base05; + padding: 5px; + border-radius: 15px; + } + + .widget-body, .widget-mpris, .widget-dnd, .widget-inhibitors { + margin: 4px 5px; + } + + .notification-content { + border-radius: 12px; + padding: 10px; + margin: 8px; + } + + .notification-title { + font-weight: bold; + color: @base05; + } + + .close-button { + margin: 6px; + padding: 3px; + border-radius: 100px; + background-color: transparent; + border: 1px solid transparent; + } + + .close-button:hover { + background-color: @base0C; + } + + .close-button:active { + background-color: @base0C; + color: @base00; + } + ''; + }; +} diff --git a/home/system/waybar/swayosd.nix b/home/system/waybar/swayosd.nix new file mode 100644 index 0000000..23a3840 --- /dev/null +++ b/home/system/waybar/swayosd.nix @@ -0,0 +1,93 @@ +{ + lib, + config, + pkgs, + ... +}: let + accent = "#${config.lib.stylix.colors.base0D}"; + background = "#${config.lib.stylix.colors.base00}"; + foreground = "#${config.lib.stylix.colors.base05}"; + borderSize = config.theme.border-size; + nerdFont = config.stylix.fonts.sansSerif.name; + + theme = pkgs.writeTextFile { + name = "swayosd-css"; + text = '' + window#osd { + padding: 12px 18px; + border-radius: 999px; + border: solid ${toString borderSize}px ${accent}; + background: alpha(${background}, 0.99); + } + + #container { + margin: 0px; + } + + image { + font-family: "${nerdFont}"; + font-size: 14px; + color: ${foreground}; + } + + label { + color: ${foreground}; + } + + progressbar:disabled, + image:disabled { + opacity: 0.5; + } + + progressbar { + min-width: 150px; + min-height: 5px; + border-radius: 999px; + background: transparent; + border: none; + } + + trough { + min-height: inherit; + border-radius: inherit; + border: none; + background: alpha(${accent},0.3); + } + + progress { + min-height: inherit; + border-radius: inherit; + border: none; + background: ${accent}; + } + ''; + }; +in { + wayland.windowManager.hyprland.settings = { + exec-once = ["swayosd-server"]; + bind = [",XF86AudioMute, exec, ${pkgs.swayosd}/bin/swayosd-client --output-volume mute-toggle"]; + bindl = [ + ",XF86MonBrightnessUp, exec, ${pkgs.swayosd}/bin/swayosd-client --brightness raise 5%+" + ",XF86MonBrightnessDown, exec, ${pkgs.swayosd}/bin/swayosd-client --brightness lower 5%-" + "$mod,F2,exec, ${pkgs.swayosd}/bin/swayosd-client --brightness 100" + "$mod,F3,exec, ${pkgs.swayosd}/bin/swayosd-client --brightness 0" + ",XF86AudioPlay, exec, ${pkgs.swayosd}/bin/swayosd-client --playerctl play-pause" + ",XF86AudioNext, exec, ${pkgs.swayosd}/bin/swayosd-client --playerctl next" + ",XF86AudioPrev, exec, ${pkgs.swayosd}/bin/swayosd-client --playerctl previous" + ]; + bindle = [ + ",XF86AudioRaiseVolume, exec, ${pkgs.swayosd}/bin/swayosd-client --output-volume +2 --max-volume=100" + ",XF86AudioLowerVolume, exec, ${pkgs.swayosd}/bin/swayosd-client --output-volume -2" + ]; + bindr = [ + "CAPS,Caps_Lock,exec,${pkgs.swayosd}/bin/swayosd-client --caps-lock" + ",Scroll_Lock,exec,${pkgs.swayosd}/bin/swayosd-client --scroll-lock" + ",Num_Lock,exec,${pkgs.swayosd}/bin/swayosd-client --num-lock" + ]; + }; + + services.swayosd = { + enable = true; + stylePath = theme; + }; +} diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index 5c9c34a..76e10c3 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -27,7 +27,8 @@ # System (Desktop environment like stuff) ../../home/system/hyprland ../../home/system/hyprlock - ../../home/system/hyprpanel + # ../../home/system/hyprpanel + ../../home/system/waybar ../../home/system/hyprpaper ../../home/system/wofi ../../home/system/zathura @@ -64,7 +65,7 @@ protonvpn-gui protonvpn-cli proton-pass - protonmail-desktop + # protonmail-desktop # Now using the online brave app proton-authenticator # Dev