From 5d72a546abba56e757afbe6b665b0738000412e8 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sun, 12 Jan 2025 13:09:10 -0800 Subject: [PATCH] feat(home): Waybar --- modules/home/services/waybar/default.nix | 324 ++++++++++++++++++++++ modules/home/wayland/hyprland/default.nix | 3 +- modules/nixos/base/drivers/default.nix | 4 +- 3 files changed, 329 insertions(+), 2 deletions(-) create mode 100644 modules/home/services/waybar/default.nix diff --git a/modules/home/services/waybar/default.nix b/modules/home/services/waybar/default.nix new file mode 100644 index 0000000..f1b47a9 --- /dev/null +++ b/modules/home/services/waybar/default.nix @@ -0,0 +1,324 @@ +{ + lib, + config, + pkgs, + ... +}: let + cfg = config.marleyos.services.waybar; + inherit (config.marleyos.theme) colors; +in { + options.marleyos.services.waybar.enable = lib.mkEnableOption "waybar"; + + config = lib.mkIf cfg.enable { + programs.waybar = { + enable = true; + + rose-pine.enable = lib.mkIf colors.isRosePine true; + + # https://gitlab.com/Zaney/zaneyos/-/blob/main/config/waybar.nix + settings = [ + { + layer = "top"; + position = "top"; + + modules-left = [ + "custom/startmenu" + "hyprland/window" + "pulseaudio" + "cpu" + "memory" + "idle_inhibitor" + ]; + modules-center = ["hyprland/workspaces"]; + modules-right = [ + "custom/hyprbindings" + "custom/notifications" + "custom/exit" + "battery" + "tray" + "clock" + ]; + + "hyprland/workspaces" = { + format = "{name}"; + format-icons = { + default = " "; + active = " "; + urgent = " "; + }; + on-scroll-up = "hyprctl dispatch workspace e+1"; + on-scroll-down = "hyprctl dispatch workspace e-1"; + }; + + "clock" = { + format = " {:L%I:%M %p}"; + tooltip = true; + tooltip-format = "{:%A, %d.%B %Y }\n{calendar}"; + }; + + "hyprland/window" = { + max-length = 22; + separate-outputs = false; + rewrite = { + "" = " 🙈 No Windows? "; + }; + }; + + "memory" = { + interval = 5; + format = " {}%"; + tooltip = true; + }; + + "cpu" = { + interval = 5; + format = " {usage:2}%"; + tooltip = true; + }; + + "disk" = { + format = " {free}"; + tooltip = true; + }; + + "network" = { + format-icons = [ + "󰤯" + "󰤟" + "󰤢" + "󰤥" + "󰤨" + ]; + format-ethernet = " {bandwidthDownOctets}"; + format-wifi = "{icon} {signalStrength}%"; + format-disconnected = "󰤮"; + tooltip = false; + }; + + "tray" = { + spacing = 12; + }; + + "pulseaudio" = { + format = "{icon} {volume}% {format_source}"; + format-bluetooth = "{volume}% {icon} {format_source}"; + format-bluetooth-muted = " {icon} {format_source}"; + format-muted = " {format_source}"; + format-source = " {volume}%"; + format-source-muted = ""; + format-icons = { + headphone = ""; + hands-free = "󰏳"; + headset = "󰋎"; + phone = ""; + portable = ""; + car = ""; + default = [ + "" + "" + "" + ]; + }; + on-click = "sleep 0.1 && ${lib.getExe pkgs.pwvucontrol}"; + }; + + "custom/exit" = { + tooltip = false; + format = ""; + on-click = "sleep 0.1 && ${lib.getExe pkgs.wlogout}"; + }; + + "custom/startmenu" = { + tooltip = false; + format = ""; + on-click = let + inherit (config.marleyos.apps) launcher; + in "sleep 0.1 && ${lib.getExe launcher.package} ${launcher.command}"; + }; + + "custom/hyprbindings" = { + tooltip = false; + format = "󱕴"; + on-click = "sleep 0.1 && list-hypr-bindings"; + }; + + "idle_inhibitor" = { + format = "{icon}"; + format-icons = { + activated = ""; + deactivated = ""; + }; + tooltip = "true"; + }; + + "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 = "sleep 0.1 && task-waybar"; + escape = true; + }; + + "battery" = { + states = { + warning = 30; + critical = 15; + }; + format = "{icon} {capacity}%"; + format-charging = "󰂄 {capacity}%"; + format-plugged = "󱘖 {capacity}%"; + format-icons = [ + "󰁺" + "󰁻" + "󰁼" + "󰁽" + "󰁾" + "󰁿" + "󰂀" + "󰂁" + "󰂂" + "󰁹" + ]; + on-click = ""; + tooltip = false; + }; + } + ]; + + style = let + transition = "all 0.3s cubic-bezier(.55,-0.68,.48,1.682)"; + in + lib.concatStrings [ + (lib.optionalString colors.isRosePine + #css + '' + @define-color darkOne @base; + @define-color darkTwo @surface; + @define-color darkThree @overlay; + @define-color light @subtle; + @define-color highlight @highlightHigh; + @define-color main @love; + @define-color accentOne @pine; + @define-color accentTwo @gold; + @define-color accentThree @iris; + @define-color accentFour @foam; + '') + # css + '' + * { + font-family: ${config.marleyos.theme.fonts.monospace.name}; + font-size: 16px; + border-radius: 0; + border: none; + min-height: 0; + } + + window#waybar { + background: transparent; + } + + #workspaces { + color: @darkOne; + background: @darkTwo; + margin: 4px 4px; + padding: 5px 5px; + border-radius: 16px; + } + + #workspaces button { + font-weight: bold; + padding: 0 5px; + margin: 0 3px; + border-radius: 16px; + color: @darkOne; + background: linear-gradient(45deg, @main, @accentThree); + opacity: 0.5; + transition: ${transition}; + } + + #workspaces button.active { + font-weight: bold; + padding: 0 5px; + margin: 0 3px; + border-radius: 16px; + color: @darkOne; + background: linear-gradient(45deg, @main, @accentThree); + opacity: 1.0; + transition: ${transition}; + min-width: 40px; + } + + #workspaces button:hover { + font-weight: bold; + border-radius: 16px; + color: @darkOne; + background: linear-gradient(45deg, @main, @iris); + opacity: 0.8; + transition: ${transition}; + } + + tooltip { + background: @darkOne; + border: 1px solid @main; + border-radius: 12px; + } + + tooltip label { + color: @main; + } + + #window, #pulseaudio, #cpu, #memory, #idle_inhibitor { + font-weight: bold; + margin: 4px 0; + margin-left: 7px; + padding: 0 18px; + background: @light; + color: @darkOne; + border-radius: 24px 10px 24px 10px; + } + + #custom-startmenu { + color: @accentOne; + background: @darkThree; + font-size: 28px; + margin: 0; + padding: 0 30px 0 15px; + border-radius: 0 0 40px 0; + } + + #custom-hyprbindings, #network, #battery, #custom-notification, + #tray, #custom-exit { + font-weight: bold; + background: @highlight; + color: @darkOne; + margin: 4px 0; + margin-right: 7px; + border-radius: 10px 24px 10px 24px; + padding: 0 18px; + } + + #clock { + font-weight: bold; + color: @darkOne; + background: linear-gradient(90deg, @accentTwo, @accentFour); + margin: 0; + padding: 0 15px 0 30px; + border-radius: 0 0 0 40px; + } + '' + ]; + }; + }; +} diff --git a/modules/home/wayland/hyprland/default.nix b/modules/home/wayland/hyprland/default.nix index ea9099d..a638abe 100644 --- a/modules/home/wayland/hyprland/default.nix +++ b/modules/home/wayland/hyprland/default.nix @@ -123,6 +123,7 @@ in { then wsPerMonitor + 1 else 2; in [ + (lib.getExe pkgs.waybar) "[workspace 1 silent] $terminal" "[workspace ${toString browserWs} silent] $browser" ]; @@ -217,7 +218,7 @@ in { input = { kb_layout = "us"; numlock_by_default = true; - follow_mouse = 0; + follow_mouse = 2; }; "$mod" = "SUPER"; diff --git a/modules/nixos/base/drivers/default.nix b/modules/nixos/base/drivers/default.nix index 8135b81..15056ae 100644 --- a/modules/nixos/base/drivers/default.nix +++ b/modules/nixos/base/drivers/default.nix @@ -1,4 +1,4 @@ -_: { +{pkgs, ...}: { security.rtkit.enable = true; # Used for pulseaudio. services = { @@ -12,4 +12,6 @@ _: { printing.enable = true; }; + + environment.systemPackages = [pkgs.pwvucontrol]; }