From 1d4cf53541a83b4e52e83f92ba1445bea1790407 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Tue, 30 Jul 2024 19:36:16 -0400 Subject: [PATCH] waybar: rework modules + add dnd mode (#69) * waybar: add do not disturb * nix fmt * waybar: reformat and sort * waybar: add airplane mode icons * waybar: remove river buttons * waybar: remove sway close button * waybar: add tooltip to close button * waybar: remove unused hyprland and sway window widget configs * waybar: remove unused css * waybar/dnd: color red when active * waybar: simplify tooltips * nix fmt * waybar: update logout button icon * waybar: css cleanup --- homeManagerModules/apps/waybar/default.nix | 158 +++++++++++---------- 1 file changed, 80 insertions(+), 78 deletions(-) diff --git a/homeManagerModules/apps/waybar/default.nix b/homeManagerModules/apps/waybar/default.nix index 97270bc9..9c2a3a3f 100644 --- a/homeManagerModules/apps/waybar/default.nix +++ b/homeManagerModules/apps/waybar/default.nix @@ -25,11 +25,13 @@ modules-right = [ "tray" "group/hardware" + "group/session" ]; "hyprland/workspaces" = { "all-outputs" = true; "format" = "{icon} {name}"; + "format-icons" = { "default" = "󰝥"; "active" = "󰪥"; @@ -43,20 +45,15 @@ config.wayland.windowManager.hyprland.package "hyprctl"} dispatch submap reset''; }; - "hyprland/window" = { - "format" = ""; - "max-length" = 100; - "separate-outputs" = true; - "icon" = true; - }; - "sway/workspaces" = { "all-outputs" = true; "format" = "{icon} {name}"; + "format-icons" = { "default" = "󰝥"; "focused" = "󰪥"; }; + "sort-by" = "id"; }; @@ -64,51 +61,36 @@ "on-click" = ''${lib.getExe' config.wayland.windowManager.sway.package "swaymsg"} mode default''; }; - "sway/window" = { - "max-length" = 100; - }; - "sway/scratchpad" = { "format" = "{icon} {count}"; - "show-empty" = false; "format-icons" = ["" ""]; + "show-empty" = false; "tooltip" = true; "tooltip-format" = "{app}: {title}"; }; - "custom/sway-close" = { - "on-click" = ''${lib.getExe' - config.wayland.windowManager.sway.package "swaymsg"} kill''; - "format" = "󰅗"; - }; - "custom/hyprland-close" = { "on-click" = ''${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch killactive''; "format" = "󰅗"; - }; - - "river/window" = { - "max-length" = 100; - }; - - "river/tags" = { - "num-tags" = 4; + "tooltip-format" = "Close the focused window."; }; "clock" = { - "tooltip-format" = "{:%Y-%m-%d | %H:%M}"; - "interval" = 60; "format" = "{:%I:%M%p}"; + "interval" = 60; + "tooltip-format" = "{:%Y-%m-%d | %H:%M}"; }; "battery" = { - "states" = {"critical" = 20;}; "format" = "{icon}"; "format-icons" = ["󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"]; + "tooltip-format" = '' {capacity}%: {timeTo}. Draw: {power} watts.''; + + "states" = {"critical" = 20;}; }; "idle_inhibitor" = { @@ -122,25 +104,27 @@ "timeout" = 45; "tooltip-format-activated" = '' - Sleep inhibited. + Presentation mode enabled. System will not sleep.''; "tooltip-format-deactivated" = '' - Sleep uninhibited. + Presentation mode disabled. System will sleep normally.''; }; "bluetooth" = { "format" = ""; - "format-disabled" = ""; # an empty format will hide the module "format-connected" = " {num_connections}"; + "format-disabled" = ""; # an empty format will hide the module + "on-click" = lib.getExe' pkgs.blueberry "blueberry"; "tooltip-format" = "{controller_alias} {controller_address}"; + "tooltip-format-connected" = '' {controller_alias} {controller_address} {device_enumerate}''; + "tooltip-format-enumerate-connected" = "{device_alias} {device_address}"; - "on-click" = lib.getExe' pkgs.blueberry "blueberry"; }; "pulseaudio" = { @@ -155,55 +139,89 @@ "default" = ["" "" ""]; }; - "scroll-step" = 5; "ignored-sinks" = ["Easy Effects Sink"]; "on-click" = "${lib.getExe pkgs.pavucontrol} -t 3"; + "scroll-step" = 5; }; "network" = { - "format-wifi" = "{icon}"; + "format-disabled" = "󰀝"; + "format-disconnected" = "󰀦"; "format-ethernet" = "󰈀"; - "format-disconnected" = "⚠"; "format-icons" = ["󰤟" "󰤢" "󰤥" "󰤨"]; - "tooltip-format" = "{ifname} via {gwaddr} 󰊗"; - "tooltip-format-wifi" = "{essid} ({signalStrength}%) {icon}"; - "tooltip-format-ethernet" = "{ifname} "; - "tooltip-format-disconnected" = "Disconnected"; + "format-wifi" = "{icon}"; "on-click" = "${lib.getExe pkgs.networkmanager_dmenu} -i"; + "tooltip-format" = "{ifname} via {gwaddr} 󰊗"; + "tooltip-format-disconnected" = "Disconnected"; + "tooltip-format-ethernet" = "{ifname} "; + "tooltip-format-wifi" = "{essid} ({signalStrength}%) {icon}"; }; "tray" = {"spacing" = 15;}; + "custom/dnd" = let + mako-dnd = pkgs.writeShellScript "mako-dnd" '' + show() { + MAKO_MODE=$(${lib.getExe' pkgs.mako "makoctl"} mode) + if echo "$MAKO_MODE" | grep -q "do-not-disturb"; then + printf '{"text": "󰂛", "class": "on", "tooltip": "Notifications snoozed."}\n' + else + printf '{"text": "󰂚", "class": "off","tooltip": "Notifications enabled."}\n' + fi + } + + toggle() { + ${lib.getExe' pkgs.mako "makoctl"} mode -t do-not-disturb + ${lib.getExe' pkgs.procps "pkill"} -SIGRTMIN+2 .waybar-wrapped + } + + [ $# -gt 0 ] && toggle || show + ''; + in { + "exec" = "${mako-dnd}"; + "interval" = "once"; + "on-click" = "${mako-dnd} toggle"; + "return-type" = "json"; + "signal" = 2; + }; + "custom/logout" = { + "format" = "󰤆"; "on-click" = ''${lib.getExe config.programs.rofi.package} -i -show power-menu -modi "power-menu:${lib.getExe pkgs.rofi-power-menu} --choices=logout/lockscreen/suspend/shutdown/reboot"''; - "format" = "󰗽"; + "tooltip-format" = "Manage your session."; }; "custom/menu" = { - "on-click" = "${lib.getExe pkgs.nwg-drawer} -mt 5"; "format" = "󰀻"; + "on-click" = "${lib.getExe pkgs.nwg-drawer} -mt 5"; + "tooltip-format" = "Touch-friendly application menu."; }; "power-profiles-daemon" = { "format" = "{icon}"; + "format-icons" = { + "balanced" = "󰗑"; + "default" = "󱐌"; + "performance" = "󱐌"; + "power-saver" = "󰌪"; + }; + "tooltip-format" = '' Profile: {profile} Driver: {driver}''; "tooltip" = true; - - "format-icons" = { - "default" = "󱐌"; - "performance" = "󱐌"; - "balanced" = "󰗑"; - "power-saver" = "󰌪"; - }; }; "group/hardware" = { "orientation" = "horizontal"; - modules = ["pulseaudio" "bluetooth" "network" "power-profiles-daemon" "battery" "idle_inhibitor" "custom/logout"]; + modules = ["pulseaudio" "bluetooth" "network" "power-profiles-daemon" "battery"]; + }; + + "group/session" = { + "orientation" = "horizontal"; + modules = ["custom/dnd" "idle_inhibitor" "custom/logout"]; }; }; }; @@ -234,23 +252,6 @@ color: ${config.ar.home.theme.colors.primary}; } - #submap, - #mode { - padding: 0 15px; - margin: 0 5px; - color: #FFFFFF; - } - - #tags button { - padding: 0px 5px; - margin: 0 0px; - color: ${config.ar.home.theme.colors.text}; - } - - #tags button.focused { - color: ${config.ar.home.theme.colors.primary}; - } - #clock, #battery, #bluetooth, @@ -259,9 +260,9 @@ #pulseaudio, #wireplumber, #idle_inhibitor, + #custom-dnd, #custom-logout, #custom-menu, - #custom-sway-close, #tray { padding: 0 7.5px; margin: 0 5px; @@ -275,27 +276,28 @@ color: ${config.ar.home.theme.colors.primary}; } - #battery.critical:not(.charging) { + #battery.critical:not(.charging), + #custom-dnd.on { color: #e78284; } - #workspaces, - #mode, - #submap, - #scratchpad, - #tray, #clock, - #custom-menu, - #custom-sway-close, #custom-hyprland-close, - #hardware { + #custom-menu, + #hardware, + #mode, + #scratchpad, + #session, + #submap, + #tray, + #workspaces { border-radius: 10; background: rgba (36, 36, 36, 0.8); margin: 5px 10px 0px 10px; padding: 0px 10px 0px 10px; } - #clock, #custom-menu, #custom-sway-close, #custom-hyprland-close { + #clock, #custom-menu, #custom-hyprland-close { padding: 0px 20px 0px 20px; }