{ lib, config, pkgs, inputs, system, ... }: with lib; let cfg = config.modules.desktop.waybar; in { options.modules.desktop.waybar = { enable = mkEnableOption "Enable Waybar, a highly customizable wayland bar for wlroots compositors."; package = mkOption { type = types.package; default = inputs.waybar.packages.${system}.default; example = "pkgs.waybar"; }; }; config = mkIf cfg.enable { hm.wayland.windowManager.hyprland.settings.exec-once = [ "${lib.getExe cfg.package}" ]; hm.programs.waybar = { enable = true; package = cfg.package; style = builtins.concatStringsSep "\n" [ "@import \"${inputs.waybar-catppuccin}/themes/mocha.css\";" (lib.readFile ../../config/waybar.css) ]; settings = { mainBar = { layer = "top"; position = "top"; spacing = 4; height = 30; margin-top = 6; margin-left = 6; margin-right = 6; margin-bottom = 0; modules-left = [ "hyprland/workspaces" "hyprland/window" ]; modules-center = [ "clock" ]; modules-right = [ "group/status" "tray" "group/power" ]; "group/status" = { orientation = "inherit"; modules = [ "pulseaudio" "cpu" "memory" #"network" ]; }; "group/power" = { orientation = "inherit"; drawer = { transition-duration = 200; children-class = "not-power"; transition-left-to-right = false; }; modules = [ "custom/power" "custom/lock" "custom/reboot" "custom/quit" ]; }; "custom/quit" = { format = ""; tooltip = true; tooltip-format = "Exit Hyprland"; on-click = "${config.modules.desktop.hyprland.package}/bin/hyprctl dispatch exit"; }; "custom/lock" = { format = ""; tooltip = true; tooltip-format = "Lock the system"; on-click = "${lib.getExe config.modules.desktop.hyprlock.package}"; }; "custom/reboot" = { format = "↻"; tooltip = true; tooltip-format = "Reboot"; on-click = "reboot"; }; "custom/power" = { format = "⏻"; tooltip = true; tooltip-format = "Power off"; on-click = "shutdown now"; }; "hyprland/workspaces" = { format = "{icon}"; format-icons = { "1" = ""; "2" = ""; "3" = ""; "4" = ""; urgent = ""; default = "•"; }; persistent-workspaces = { "1" = []; "2" = []; "3" = []; "4" = []; }; }; "hyprland/window" = { format = "{}"; icon = true; icon-size = 16; rewrite = { "(.*) — Mozilla Firefox" = "$1"; # the dash here is SLIGHTLY different. Wow "(.*) - Visual Studio Code" = "$1"; "(.*\\.nix\\s.*)" = " $1"; "(\\S+\\.html\\s.*)" = " $1"; "(\\S+\\.css\\s.*)" = " $1"; "(\\S+\\.js\\s.*)" = " $1"; "(\\S+\\.ts\\s.*)" = " $1"; "(\\S+\\.go\\s.*)" = " $1"; "(\\S+\\.lua\\s.*)" = " $1"; "(\\S+\\.java\\s.*)" = " $1"; "(\\S+\\.rb\\s.*)" = " $1"; "(\\S+\\.php\\s.*)" = " $1"; "(\\S+\\.jsonc?\\s.*)" = " $1"; "(\\S+\\.md\\s.*)" = " $1"; "(\\S+\\.txt\\s.*)" = " $1"; "(\\S+\\.cs\\s.*)" = "󰌛 $1"; "(\\S+\\.c\\s.*)" = " $1"; "(\\S+\\.cpp\\s.*)" = " $1"; "(\\S+\\.zig\\s.*)" = " $1"; "(\\S+\\.rs\\s.*)" = " $1"; "(\\S+\\.hs\\s.*)" = " $1"; ".*Discord \\| (.*)" = "$1"; }; separate-outputs = true; }; pulseaudio = { format = "{icon} {volume}%"; format-bluetooth = "{icon} {volume}%"; format-muted = "婢 {volume}%"; format-icons = { headphone = ""; hands-free = ""; headset = ""; phone = ""; portable = ""; car = ""; default = ["" "" ""]; }; scroll-step = 1; on-click = "${lib.getExe pkgs.pavucontrol}"; ignored-sinks = ["Easy Effects Sink"]; }; cpu = { interval = 4; format = " {usage}% {avg_frequency}GHz"; }; memory = { interval = 4; format = " {percentage}%"; tooltip-format = "{used:0.1f}GiB/{avail:0.1f}GiB used\n{swapUsed:0.1f}GiB/{swapAvail:0.1f}GiB swap"; }; clock = { format = "{:%H:%M}"; format-alt = "{:%a %b %d %R}"; tooltip-format = "{calendar}"; calendar = { mode = "year"; mode-mon-col = 3; weeks-pos = "right"; on-scroll = 1; on-click-right = "mode"; format = { months = "{}"; days = "{}"; weeks = "W{}"; weekdays = "{}"; today = "{}"; }; actions = { on-click-right = "mode"; on-click-forward = "tz_up"; on-click-backward = "tz_down"; on-scroll-up = "shift_up"; on-scroll-down = "shift_down"; }; }; }; power-profiles-daemon = { format = "{icon}"; tooltip-format = "Power profile: {profile}\nDriver: {driver}"; tooltip = true; format-icons = { default = ""; performance = " perf"; balanced = " balance"; power-saver = " save"; }; }; }; }; }; }; }