{ lib, config, pkgs, ... }: let cfg = config.marleyos.programs.waybar; in { options.marleyos.programs.waybar = { enable = lib.mkEnableOption "waybar"; keybindings-script = lib.mkOption { type = lib.types.listOf lib.types.str; default = ""; description = "The keybindings to use for a cheatsheet."; }; }; config = lib.mkIf cfg.enable { marleyos.services.swaync.enable = true; programs.waybar = let keybindings-script = pkgs.writeShellScript "keybindings-cheatsheet-wayland" # bash '' ${lib.getExe pkgs.yad} \ --width=800 \ --height=650 \ --center \ --fixed \ --title="Keybindings" \ --no-buttons \ --list \ --column=Key: \ --column=Description: \ --column=Command: \ --timeout=90 \ --timeout-indicator=right \ ${lib.concatStringsSep "\\\n" cfg.keybindings-script} \ "" ''; in { enable = 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" = let hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"; in { 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 && ${keybindings-script}"; }; "idle_inhibitor" = { format = "{icon}"; format-icons = { activated = ""; deactivated = ""; }; tooltip = "true"; }; "custom/notifications" = let swaync-client = lib.getExe' config.services.swaync.package "swaync-client"; in { 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 = "${swaync-client} -swb"; on-click = "sleep 0.1 && ${swaync-client} -t"; 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 config.rose-pine.enable #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-notifications, #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; } '' ]; }; }; }