From 698d8ed7dbb692ce0b963ae836f7ac24499d6363 Mon Sep 17 00:00:00 2001 From: Alexander Wainwright Date: Mon, 30 Mar 2026 21:51:28 +1000 Subject: [PATCH] Waybar to own file, fix icons, add colour file --- alex/colours/catppuchin-mocha.nix | 17 +++ alex/sway.nix | 221 ++--------------------------- alex/waybar.nix | 224 ++++++++++++++++++++++++++++++ 3 files changed, 250 insertions(+), 212 deletions(-) create mode 100644 alex/colours/catppuchin-mocha.nix create mode 100644 alex/waybar.nix diff --git a/alex/colours/catppuchin-mocha.nix b/alex/colours/catppuchin-mocha.nix new file mode 100644 index 0000000..1ab7898 --- /dev/null +++ b/alex/colours/catppuchin-mocha.nix @@ -0,0 +1,17 @@ +{ + # Catppuccin Mocha Palette + base = "#1e1e2e"; + mantle = "#181825"; + surface0 = "#313244"; + surface1 = "#45475a"; + text = "#cdd6f4"; + lavender = "#b4befe"; + blue = "#89b4fa"; + sapphire = "#74c7ec"; + red = "#f38ba8"; + peach = "#fab387"; + yellow = "#f9e2af"; + green = "#a6e3a1"; + mauve = "#cba6f7"; + overlay0 = "#6c7086"; +} diff --git a/alex/sway.nix b/alex/sway.nix index c1f54ae..fc7b31e 100644 --- a/alex/sway.nix +++ b/alex/sway.nix @@ -18,6 +18,10 @@ let overlay0 = "#6c7086"; in { + imports = [ + ./waybar.nix + ]; + home.packages = with pkgs; [ swaybg swayidle @@ -64,7 +68,7 @@ in line-clear-color = base; line-wrong-color = base; bs-hl-color = red; - grace = 2; + grace = 6; grace-no-mouse = true; grace-no-touch = true; datestr = "%a, %B %e"; @@ -154,6 +158,7 @@ in keybindings = let modifier = "Mod4"; in lib.mkOptionDefault { + "${modifier}+Caps_Lock" = "input * xkb_switch_layout next"; "${modifier}+Return" = "exec wezterm"; "${modifier}+d" = "exec fuzzel"; "${modifier}+space" = "floating toggle"; @@ -212,7 +217,8 @@ in services.swayidle = let - lock = "${pkgs.swaylock-effects}/bin/swaylock --daemonize"; + lock = "${pkgs.swaylock-effects}/bin/swaylock -f"; + lockNow = "${pkgs.swaylock-effects}/bin/swaylock -f --grace 0"; # modify "display" function based on your window manager # Sway display = status: "${pkgs.sway}/bin/swaymsg 'output * power ${status}'"; @@ -244,7 +250,7 @@ in { event = "before-sleep"; # adding duplicated entries for the same event may not work - command = (display "off") + "; " + lock; + command = lockNow + "; " + (display "off"); } { event = "after-resume"; @@ -286,213 +292,4 @@ in }; }; }; - - programs.waybar = { - enable = true; - settings = { - mainBar = { - layer = "top"; - position = "top"; - height = 30; - margin-top = 5; - margin-left = 10; - margin-right = 10; - spacing = 4; - - modules-left = [ "sway/workspaces" "sway/mode" ]; - modules-center = [ "clock" ]; - modules-right = [ "pulseaudio" "network" "cpu" "memory" "battery" "tray" ]; - - "sway/workspaces" = { - disable-scroll = true; - all-outputs = true; - }; - - "clock" = { - format = "{:%a %d %b %H:%M:%S}"; - tooltip-format = "{:%Y %B}\n{calendar}"; - interval = 1; - }; - - "cpu" = { - format = "{usage}% "; - }; - - "memory" = { - format = "{}% "; - tooltip-format = "RAM: {used}GiB / {total}GiB ({percentage}%)\nSwap: {swapUsed}GiB / {swapTotal}GiB ({swapPercentage}%)"; - }; - - "battery" = { - states = { - warning = 30; - critical = 15; - }; - format = "{capacity}% {icon}"; - format-charging = "{capacity}% "; - format-plugged = "{capacity}% "; - format-icons = ["" "" "" "" ""]; - }; - - "network" = { - format-wifi = "{essid} ({signalStrength}%) "; - format-ethernet = "{ipaddr}/{cidr} 󰈀"; - tooltip-format = "{ifname} via {gwaddr} 󱂇"; - format-linked = "{ifname} (No IP) 󰈀"; - format-disconnected = "Disconnected ⚠"; - format-alt = "{ifname}: {ipaddr}/{cidr}"; - }; - - "pulseaudio" = { - format = "{volume}% {icon} {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 = "pavucontrol"; - }; - }; - }; - - style = '' - * { - font-family: "JetBrainsMono Nerd Font"; - font-size: 13px; - } - - window#waybar { - background-color: transparent; - color: ${text}; - transition-property: background-color; - transition-duration: .5s; - } - - window#waybar > box { - background-color: ${base}; - border-radius: 15px; - opacity: 1.0; - padding: 0 3px 0 13px; - } - - button { - box-shadow: inset 0 -3px transparent; - border: none; - border-radius: 0; - } - - button:hover { - background: inherit; - box-shadow: inset 0 -3px ${text}; - } - - #workspaces button { - padding: 0 5px; - background-color: transparent; - color: ${text}; - } - - #workspaces button:hover { - background: rgba(0, 0, 0, 0.2); - } - - #workspaces button.focused { - background-color: ${surface1}; - box-shadow: inset 0 -3px ${lavender}; - } - - #workspaces button.urgent { - background-color: ${red}; - } - - #mode { - background-color: ${surface0}; - border-bottom: 3px solid ${text}; - } - - #clock, - #battery, - #cpu, - #memory, - #disk, - #temperature, - #backlight, - #network, - #pulseaudio, - #custom-media, - #tray, - #mode, - #idle_inhibitor, - #mpd { - padding: 0 10px; - color: ${text}; - background-color: ${surface0}; - border-radius: 10px; - margin: 5px 2px; - } - - #clock { - background-color: ${mauve}; - color: ${base}; - } - - #battery { - background-color: ${green}; - color: ${base}; - } - - #battery.charging, #battery.plugged { - color: ${base}; - background-color: ${green}; - } - - #battery.critical:not(.charging) { - background-color: ${red}; - color: ${text}; - animation-name: blink; - animation-duration: 0.5s; - animation-timing-function: linear; - animation-iteration-count: infinite; - animation-direction: alternate; - } - - #cpu { - background-color: ${peach}; - color: ${base}; - } - - #memory { - background-color: ${yellow}; - color: ${base}; - } - - #network { - background-color: ${sapphire}; - color: ${base}; - } - - #pulseaudio { - background-color: ${blue}; - color: ${base}; - } - - #pulseaudio.muted { - background-color: ${overlay0}; - color: ${text}; - } - - #tray { - background-color: ${surface0}; - } - ''; - }; } diff --git a/alex/waybar.nix b/alex/waybar.nix new file mode 100644 index 0000000..1932516 --- /dev/null +++ b/alex/waybar.nix @@ -0,0 +1,224 @@ +{ config, pkgs, lib, ... }: +let + palette = import ./colours/catppuchin-mocha.nix; +in +{ + programs.waybar = { + enable = true; + settings = { + mainBar = { + layer = "top"; + position = "top"; + height = 30; + margin-top = 10; + margin-bottom = 0; + margin-left = 10; + margin-right = 10; + spacing = 4; + + modules-left = if (config.programs.niri or {}).enable or false then + [ "niri/workspaces" ] + else + [ "sway/workspaces" "sway/mode" ]; + modules-center = [ "clock" ]; + modules-right = [ "pulseaudio" "network" "cpu" "memory" "battery" "tray" ]; + + "sway/workspaces" = { + disable-scroll = true; + all-outputs = true; + }; + + "niri/workspaces" = { + disable-scroll = true; + all-outputs = true; + }; + + "clock" = { + format = "{:%a %d %b %H:%M:%S}"; + tooltip-format = "{:%Y %B}\n{calendar}"; + interval = 1; + }; + + "cpu" = { + format = "{usage}% "; + }; + + "memory" = { + format = "{}% "; + tooltip-format = "RAM: {used}GiB / {total}GiB ({percentage}%)\nSwap: {swapUsed}GiB / {swapTotal}GiB ({swapPercentage}%)"; + }; + + "battery" = { + states = { + warning = 30; + critical = 15; + }; + format = "{capacity}% {icon} icon"; + format-full = "{capacity}% {icon} full"; + format-charging = "{capacity}%  charged"; + format-plugged = "{capacity}% "; + format-icons = ["" "" "" "" ""]; + }; + + "network" = { + format-wifi = "{essid} ({signalStrength}%) "; + format-ethernet = "{ipaddr}/{cidr} 󰈀"; + tooltip-format = "{ifname} via {gwaddr} 󱂇"; + format-linked = "{ifname} (No IP) 󰈀"; + format-disconnected = "Disconnected ⚠"; + format-alt = "{ifname}: {ipaddr}/{cidr}"; + }; + + "pulseaudio" = { + format = "{volume}% {icon} {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 = "pavucontrol"; + }; + }; + }; + + style = '' + * { + font-family: "Symbols Nerd Font Mono", "Lilex Nerd Font", "JetBrainsMono Nerd Font"; + font-size: 13px; + } + + window#waybar { + background-color: transparent; + color: ${palette.text}; + transition-property: background-color; + transition-duration: .5s; + } + + window#waybar > box { + background-color: ${palette.base}; + border-radius: 15px; + opacity: 1.0; + padding: 0 3px 0 13px; + } + + button { + box-shadow: inset 0 -3px transparent; + border: none; + border-radius: 0; + } + + button:hover { + background: inherit; + box-shadow: inset 0 -3px ${palette.text}; + } + + #workspaces button { + padding: 0 5px; + background-color: transparent; + color: ${palette.text}; + } + + #workspaces button:hover { + background: rgba(0, 0, 0, 0.2); + } + + #workspaces button.focused { + background-color: ${palette.surface1}; + box-shadow: inset 0 -3px ${palette.lavender}; + } + + #workspaces button.urgent { + background-color: ${palette.red}; + } + + #mode { + background-color: ${palette.surface0}; + border-bottom: 3px solid ${palette.text}; + } + + #clock, + #battery, + #cpu, + #memory, + #disk, + #temperature, + #backlight, + #network, + #pulseaudio, + #custom-media, + #tray, + #mode, + #idle_inhibitor, + #mpd { + padding: 0 10px; + color: ${palette.text}; + background-color: ${palette.surface0}; + border-radius: 10px; + margin: 5px 2px; + } + + #clock { + background-color: ${palette.mauve}; + color: ${palette.base}; + } + + #battery { + background-color: ${palette.green}; + color: ${palette.base}; + } + + #battery.charging, #battery.plugged { + color: ${palette.base}; + background-color: ${palette.green}; + } + + #battery.critical:not(.charging) { + background-color: ${palette.red}; + color: ${palette.text}; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; + } + + #cpu { + background-color: ${palette.peach}; + color: ${palette.base}; + } + + #memory { + background-color: ${palette.yellow}; + color: ${palette.base}; + } + + #network { + background-color: ${palette.sapphire}; + color: ${palette.base}; + } + + #pulseaudio { + background-color: ${palette.blue}; + color: ${palette.base}; + } + + #pulseaudio.muted { + background-color: ${palette.overlay0}; + color: ${palette.text}; + } + + #tray { + background-color: ${palette.surface0}; + } + ''; + }; +}