From 3f3079b99bdd1585299c93df68975ddd21dff7ce Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Fri, 17 Nov 2023 11:40:02 -0800 Subject: [PATCH] split status bar on multi-monitor hosts --- modules/ewwbar/eww-config/eww.yuck | 45 +------ modules/ewwbar/eww-config/status_bars.yuck | 138 +++++++++++++++++++++ modules/ewwbar/eww-config/windows.yuck | 12 -- modules/hyprland/default.nix | 12 +- modules/hyprland/displays.nix | 1 + 5 files changed, 149 insertions(+), 59 deletions(-) create mode 100644 modules/ewwbar/eww-config/status_bars.yuck delete mode 100644 modules/ewwbar/eww-config/windows.yuck diff --git a/modules/ewwbar/eww-config/eww.yuck b/modules/ewwbar/eww-config/eww.yuck index ff689d4..4bb186a 100644 --- a/modules/ewwbar/eww-config/eww.yuck +++ b/modules/ewwbar/eww-config/eww.yuck @@ -1,47 +1,4 @@ -(defwidget bar [] - (centerbox :orientation "h" - (workspaces :current-idx current-workspace) - ;; (music) - (center-clock) - (info) - )) -(deflisten current-workspace :initial "1" "bash ./scripts/get-active-workspace") -(defwidget workspaces [current-idx] - (box - :halign "start" - :hexpand false - :class "bar-main" - :space-evenly true - :spacing "12" - :css "* {margin-left: 20px; margin-right: 20px;}" - (box - :class {current-idx == "1" ? "active-workspace" : "regular"} - (label :text "")) - (box - :class {current-idx == "2" ? "active-workspace" : "regular"} - (label :text "")) - (box - :class {current-idx == "3" ? "active-workspace" : "regular"} - (label :text "")) - (box - :class {current-idx == "4" ? "active-workspace" : "regular"} - (label :text "")) - (box - :class {current-idx == "5" ? "active-workspace" : "regular"} - (label :text "")) - (box - :class {current-idx == "6" ? "active-workspace" : "regular"} - (label :text "")) - (box - :class {current-idx == "7" ? "active-workspace" : "regular"} - (label :text "")) - (box - :class {current-idx == "8" ? "active-workspace" : "regular"} - (label :text "")) - (box - :class {current-idx == "9" ? "active-workspace" : "regular"} - (label :text "")))) (defwidget info [] (box @@ -154,7 +111,7 @@ (defpoll volume :interval "1s" {"pw-volume status | jaq '.percentage // -1'" ?: 500}) -(include "windows.yuck") +(include "status_bars.yuck") (include "./modules/center-clock.yuck") (defvar open_vol_osd false) diff --git a/modules/ewwbar/eww-config/status_bars.yuck b/modules/ewwbar/eww-config/status_bars.yuck new file mode 100644 index 0000000..186f9ce --- /dev/null +++ b/modules/ewwbar/eww-config/status_bars.yuck @@ -0,0 +1,138 @@ +(defwidget bar_full [] + (centerbox :orientation "h" + (full_workspaces :current-idx current-workspace) + (center-clock) + (info) +)) + +(deflisten current-workspace :initial "1" "bash ./scripts/get-active-workspace") +(defwidget full_workspaces [current-idx] + (box + :halign "start" + :hexpand false + :class "bar-main" + :space-evenly true + :spacing "12" + :css "* {margin-left: 20px; margin-right: 20px;}" + (box + :class {current-idx == "1" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "2" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "3" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "4" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "5" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "6" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "7" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "8" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "9" ? "active-workspace" : "regular"} + (label :text "")))) + +(defwidget bar_left [] + (centerbox :orientation "h" + (left_screen_workspaces :current-idx current-workspace) + (center-clock) + (info) +)) + +(defwidget left_screen_workspaces [current-idx] + (box + :halign "start" + :hexpand false + :class "bar-main" + :space-evenly true + :spacing "12" + :css "* {margin-left: 20px; margin-right: 20px;}" + (box + :class {current-idx == "1" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "3" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "5" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "7" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "9" ? "active-workspace" : "regular"} + (label :text "")))) + +(defwidget bar_right [] + (centerbox :orientation "h" + (right_screen_workspaces :current-idx current-workspace) + (center-clock) + (info) +)) + +(defwidget right_screen_workspaces [current-idx] + (box + :halign "start" + :hexpand false + :class "bar-main" + :space-evenly true + :spacing "12" + :css "* {margin-left: 20px; margin-right: 20px;}" + (box + :class {current-idx == "2" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "4" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "6" ? "active-workspace" : "regular"} + (label :text "")) + (box + :class {current-idx == "8" ? "active-workspace" : "regular"} + (label :text "")))) + +(defwindow full_screen_bar + :monitor 0 + :exclusive true + :windowtype "dock" + :geometry (geometry :x "0%" + :y "0%" + :width "90%" + :height "10px" + :anchor "top center") + :reserve (struts :side "top" :distance "4%") + (bar_full)) + +(defwindow left_screen_bar + :monitor 0 + :exclusive true + :windowtype "dock" + :geometry (geometry :x "0%" + :y "0%" + :width "90%" + :height "10px" + :anchor "top center") + :reserve (struts :side "top" :distance "4%") + (bar_left)) + +(defwindow right_screen_bar + :monitor 1 + :exclusive true + :windowtype "dock" + :geometry (geometry :x "0%" + :y "0%" + :width "90%" + :height "10px" + :anchor "top center") + :reserve (struts :side "top" :distance "4%") +(bar_right)) diff --git a/modules/ewwbar/eww-config/windows.yuck b/modules/ewwbar/eww-config/windows.yuck deleted file mode 100644 index c33355e..0000000 --- a/modules/ewwbar/eww-config/windows.yuck +++ /dev/null @@ -1,12 +0,0 @@ - -(defwindow bar - :monitor 1 - :exclusive true - :windowtype "dock" - :geometry (geometry :x "0%" - :y "0%" - :width "90%" - :height "10px" - :anchor "top center") - :reserve (struts :side "top" :distance "4%") - (bar)) diff --git a/modules/hyprland/default.nix b/modules/hyprland/default.nix index 3c6d9fd..2bdca9f 100644 --- a/modules/hyprland/default.nix +++ b/modules/hyprland/default.nix @@ -6,6 +6,9 @@ let monitor_config = import ./monitors.nix { hostname = hostname; }; + two_monitor_hosts = [ + "NicksNixDesktop" + ]; in { @@ -44,10 +47,13 @@ in exec-once = [ "${pkgs.swww}/bin/swww init & sleep 0.5 & ${pkgs.swww}/bin/swww /home/nixolas/Downloads/RecountERD.png" - "eww open-many bar logout restart shutdown reboot_windows dash_music dash_computer_status" + "eww open-many logout restart shutdown reboot_windows dash_music dash_computer_status" "eww open dash_clock_bg;eww open dash_clock" # the order here matters - - ]; + ] ++ pkgs.lib.optionals (builtins.elem hostname two_monitor_hosts ) [ + "eww open-many left_screen_bar right_screen_bar" + ] ++ pkgs.lib.optionals (! builtins.elem hostname two_monitor_hosts ) [ + "eww open full_screen_bar" + ]; input = { kb_layout = "us"; diff --git a/modules/hyprland/displays.nix b/modules/hyprland/displays.nix index f8f2fd0..b4412bd 100644 --- a/modules/hyprland/displays.nix +++ b/modules/hyprland/displays.nix @@ -24,6 +24,7 @@ in "3,monitor:DP-2" "5,monitor:DP-2" "7,monitor:DP-2" + "9,monitor:DP-2" ] else [ ];