From 4ba3b8f959a1041d66b545ab4140747f2a6b7822 Mon Sep 17 00:00:00 2001 From: Dmitriy Kholkin Date: Sat, 7 Jun 2025 21:09:26 +0300 Subject: [PATCH] feat: add waybar and mako modules --- modules/home/roles/default.nix | 2 + modules/home/workspace/wayland/mako.nix | 32 +++ modules/home/workspace/wayland/waybar.nix | 259 ++++++++++++++++++++++ 3 files changed, 293 insertions(+) create mode 100644 modules/home/workspace/wayland/mako.nix create mode 100644 modules/home/workspace/wayland/waybar.nix diff --git a/modules/home/roles/default.nix b/modules/home/roles/default.nix index 1234096..d01b2ab 100644 --- a/modules/home/roles/default.nix +++ b/modules/home/roles/default.nix @@ -74,6 +74,8 @@ in ataraxia.programs.vscode.enable = mkDefault true; ataraxia.wayland.enable = mkDefault true; ataraxia.wayland.hyprland.enable = mkDefault true; + ataraxia.wayland.mako.enable = mkDefault true; + ataraxia.wayland.waybar.enable = mkDefault true; }; in mkMerge [ diff --git a/modules/home/workspace/wayland/mako.nix b/modules/home/workspace/wayland/mako.nix new file mode 100644 index 0000000..da92269 --- /dev/null +++ b/modules/home/workspace/wayland/mako.nix @@ -0,0 +1,32 @@ +{ config, lib, ... }: +let + inherit (lib) mkDefault mkEnableOption mkIf; + inherit (config.theme) colors fonts icons; + + cfg = config.ataraxia.wayland.mako; +in +{ + options.ataraxia.wayland.mako = { + enable = mkEnableOption "Enable mako"; + }; + + config = mkIf cfg.enable { + services.mako = { + enable = true; + settings = { + default-timeout = 10000; + font = "${fonts.sans.family} ${toString fonts.size.normal}"; + height = 80; + icon-path = "${icons.package}/share/icons/${icons.name}"; + layer = "overlay"; + max-icon-size = 24; + max-visible = 10; + width = 500; + backgroundColor = mkDefault "#${colors.color0}AA"; + textColor = mkDefault "#${colors.color5}"; + borderColor = mkDefault "#${colors.color13}AA"; + progressColor = mkDefault "over #${colors.color11}"; + }; + }; + }; +} diff --git a/modules/home/workspace/wayland/waybar.nix b/modules/home/workspace/wayland/waybar.nix new file mode 100644 index 0000000..db043d8 --- /dev/null +++ b/modules/home/workspace/wayland/waybar.nix @@ -0,0 +1,259 @@ +{ + config, + lib, + ... +}: +let + inherit (lib) mkEnableOption mkIf; + inherit (config.theme) fonts; + cfg = config.ataraxia.wayland.waybar; +in +{ + options.ataraxia.wayland.waybar = { + enable = mkEnableOption "Enable waybar"; + laptopWidgets = mkEnableOption "Enable laptop widgets (e.g. battery)"; + }; + + config = mkIf cfg.enable { + programs.waybar = { + enable = true; + # style = builtins.readFile ./style.css; + systemd.enable = true; + systemd.target = "graphical-session.target"; + settings = { + mainBar = { + layer = "top"; + position = "top"; + # margin = "8 8 0 8"; + modules-left = + [ + "hyprland/workspaces" + # "wireplumber" + ] + ++ lib.optionals cfg.laptopWidgets [ + "battery" + "backlight" + ]; + modules-center = [ "hyprland/window" ]; + modules-right = [ + "tray" + "disk" + "cpu" + # "temperature" + "memory" + "clock" + ]; + backlight = { + device = "intel_backlight"; + format = "{percent}% {icon}"; + format-icons = [ + "" + "" + "" + "" + "" + "" + "" + ]; + # min-length = 7; + }; + battery = { + interval = 60; + states = { + warning = 30; + critical = 15; + }; + format = "{icon} {capacity}%"; + format-charging = "󱐌 {capacity}%"; + format-icons = [ + "" + "" + "" + "" + "" + ]; + on-update = "$HOME/.config/waybar/scripts/check_battery.sh"; + }; + clock = { + format = "{:%a, %d %b, %H:%M}"; + tooltip-format = "{calendar}"; + calendar = { + mode = "month"; + mode-mon-col = 3; + weeks-pos = "right"; + on-scroll = 1; + format = { + months = "{}"; + days = "{}"; + weeks = "W{}"; + weekdays = "{}"; + today = "{}"; + }; + }; + actions = { + on-click-right = "mode"; + on-click-middle = "shift_reset"; + on-scroll-up = "shift_up"; + on-scroll-down = "shift_down"; + }; + }; + cpu = { + interval = 4; + format = "      {usage}%"; + }; + disk = { + interval = 60; + format = "      {free}"; + path = "/home"; + }; + "hyprland/window" = { + max-length = 64; + }; + "hyprland/workspaces" = { + format = "{icon}"; + on-click = "activate"; + disable-scroll = true; + format-icons = { + "10" = "0"; + "Messengers" = "Msg"; + "Music" = "Mus"; + }; + }; + memory = { + format = "     {used}GiB"; + interval = 4; + }; + temperature = { + # "hwmon-path" = "/sys/class/hwmon/hwmon0/temp1_input"; + critical-threshold = 80; + format = "\uf4f5     {temperatureC}°C"; + format-critical = "{temperatureC}°C"; + interval = 4; + }; + tray = { + icon-size = 12; + spacing = 6; + }; + wireplumber = { + scroll-step = 5; + format = "{icon} {volume}%"; + format-muted = "\ueee8   Muted"; + format-bluetooth = "\uf282 {volume}%"; + on-click-right = "blueman-manager"; + format-icons = [ + "\uf026 " + "\uf027 " + "\uf028 " + ]; + on-click = "pavucontrol"; + }; + }; + }; + style = + let + accent = "lavender"; + in + '' + /* @import "catppuccin.css"; */ + + * { + font-family: "${fonts.mono.family}", feather; + font-weight: 500; + font-size: ${toString fonts.size.small}pt; + color: @text; + } + + /* main waybar */ + window#waybar { + padding: 0; + margin: 0; + /* background: rgba(26, 27, 38, 0.7); */ + background: @base; + } + + /* when hovering over modules */ + tooltip { + background: @base; + border-radius: 5%; + } + + #workspaces button { + padding: 2px; + } + + /* Sets active workspace to have a solid line on the bottom */ + #workspaces button.active { + border-bottom: 2px solid @${accent}; + border-radius: 0; + margin-top: 2px; + transition: all 0.5s ease-in-out; + } + + /* More workspace stuff for highlighting on hover */ + #workspaces button.focused { + color: @subtext0; + } + + #workspaces button.urgent { + color: #f7768e; + } + + #workspaces button:hover { + background: @crust; + color: @text; + } + + /* Sets background, padding, margins, and borders for (all) modules */ + #workspaces, + #clock, + #window, + #temperature, + #disk, + #cpu, + #memory, + #network, + #wireplumber, + #tray, + #backlight, + #battery { + /* background: rgba(26, 27, 38, 0); */ + background: @base; + padding: 0 10px; + border: 0; + } + + #workspaces { + padding-right: 0px; + } + + /* Hide window module when not focused on window or empty workspace */ + window#waybar.empty #window { + padding: 0; + margin: 0; + opacity: 0; + } + + /* Set up rounding to make these modules look like separate pills */ + #tray { + color: @${accent}; + border-radius: 12px; + margin-right: 4px; + } + + #window { + border-radius: 12px; + } + + /* close right side of bar */ + #temperature { + border-radius: 12px 0 0 12px; + } + + /* close left side of bar */ + #battery { + border-radius: 0 12px 12px 0; + } + ''; + }; + }; +}