aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 01:34:27 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 03:50:32 +0530
commit530299d97926d45939f831dc3ea5e444d2839d08 (patch)
tree6822c9697980708a34b029dde58ed6eecc086517 /modules/desktop
parentb6a7712005ee69028ec6c63510a031f73eaacaf1 (diff)
downloadhome-manager-config-530299d97926d45939f831dc3ea5e444d2839d08.tar.gz
home-manager-config-530299d97926d45939f831dc3ea5e444d2839d08.zip
desktop: separated the bar.yuck file into its own module
Diffstat (limited to 'modules/desktop')
-rw-r--r--modules/desktop/eww/bar.yuck84
-rw-r--r--modules/desktop/eww/yuck.nix114
2 files changed, 112 insertions, 86 deletions
diff --git a/modules/desktop/eww/bar.yuck b/modules/desktop/eww/bar.yuck
new file mode 100644
index 0000000..52dba32
--- /dev/null
+++ b/modules/desktop/eww/bar.yuck
@@ -0,0 +1,84 @@
+(defpoll time :interval "10s" "date '+%H:%M'")
+(defpoll date :interval "60s" "date '+%d/%m'")
+(defpoll full_date :interval "60s" "date '+%A, %d %B %Y'")
+(deflisten workspaces :initial "[]" "@@workspaces-script@@")
+(deflisten active-windows :initial "[]" "@@windows-script@@")
+(deflisten system_stats
+ :initial "{\"cpu\":{\"percent\":0,\"per_core\":[],\"freq_mhz\":null,\"load_avg\":null,\"tooltip\":\"CPU: 0%\"},\"ram\":{\"percent\":0,\"used\":\"0B\",\"total\":\"0B\",\"available\":\"0B\",\"swap_percent\":0,\"swap_used\":\"0B\",\"swap_total\":\"0B\",\"speed_mhz\":null,\"tooltip\":\"RAM: 0%\"},\"net\":{\"status\":\"down\",\"tooltip\":\"Network Offline\",\"routes\":[]},\"sound\":{\"percent\":0,\"mute\":true,\"sink\":null,\"tooltip\":\"Volume: unknown\"}}"
+ "@@systemstats-script@@")
+
+(defwindow bar
+ :monitor 0
+ :geometry (geometry
+ :x "0px"
+ :y "0px"
+ :width "60px"
+ :height "100%"
+ :anchor "top right")
+ :stacking "fg"
+ :focusable "none"
+ :reserve (struts :distance "60px" :side "right")
+ (bar-content))
+
+(defwidget bar-content []
+ (box :orientation "v"
+ :space-evenly false
+ :class "bar-container"
+ :vexpand true
+ (workspaces-widget)
+ (windows-widget)
+ (system-widget)))
+
+(defwidget workspaces-widget []
+ (box :orientation "v" :space-evenly false :spacing 4 :halign "fill" :class "workspaces"
+ (for ws in workspaces
+ (eventbox :onclick "niri msg action focus-workspace ${ws.idx}"
+ :cursor "pointer" :halign "fill"
+ :tooltip "${ws.tooltip}"
+ (box :class "workspace-button ${ws.is_active ? 'active' : ''}" :halign "fill"
+ (overlay :halign "fill"
+ (image :class "workspace-icon"
+ :path "${ws.icon != '' ? ws.icon : '@@icon-unknown@@'}"
+ :image-width 20 :image-height 20)
+ (label :class "workspace-idx" :text "${ws.idx}" :halign "end" :valign "end")))))))
+
+(defwidget windows-widget []
+ (box :orientation "v" :space-evenly false :spacing 4 :halign "center" :class "windows" :vexpand true
+
+ (for w in active-windows
+ (eventbox :onclick "niri msg action focus-window --id ${w.id}"
+ :cursor "pointer"
+ :halign "fill"
+ :tooltip "${w.app_id}: ${w.title != '' ? ' ' : ''}${w.title}"
+ (box :halign "fill" :class "window-button ${w.is_focused ? 'focused' : ''}"
+ (image :class "window-icon" :path "${w.icon != '' ? w.icon : '@@icon-unknown@@'}" :image-width 20 :image-height 20))))))
+
+(defwidget system-widget []
+ (box :orientation "v" :space-evenly false :spacing 6 :halign "fill" :class "system"
+ (box :orientation "v" :class "system-item" :halign "fill" :space-evenly false :spacing 4
+ :tooltip "${system_stats.net.tooltip}"
+ (image :class "system-icon"
+ :path "${system_stats.net.status == 'down' ? '@@icon-offline@@' : system_stats.net.routes[0].type == 'wifi' ? '@@icon-wifi@@' : system_stats.net.routes[0].type == 'ethernet' ? '@@icon-ethernet@@' : '@@icon-offline@@'}"
+ :image-width 24 :image-height 24)
+ (label :class "system-label small"
+ :text "${system_stats.net.status == 'down' ? '-' : system_stats.net.routes[0].tx}")
+ (label :class "system-label small"
+ :text "${system_stats.net.status == 'down' ? '-' : system_stats.net.routes[0].rx}"))
+ (box :orientation "v" :class "system-item" :space-evenly false :spacing 4
+ :tooltip "${system_stats.cpu.tooltip}"
+ (image :class "system-icon" :path "@@icon-cpu@@" :image-width 24 :image-height 24)
+ (label :class "system-label" :text "${system_stats.cpu.percent}%"))
+ (box :orientation "v" :class "system-item" :space-evenly false :spacing 4
+ :tooltip "${system_stats.ram.tooltip}"
+ (image :class "system-icon" :path "@@icon-ram@@" :image-width 24 :image-height 24)
+ (label :class "system-label" :text "${system_stats.ram.percent}%"))
+ (eventbox :onclick "pamixer --toggle-mute" :cursor "pointer" :halign "fill"
+ (box :orientation "v" :space-evenly false :spacing 4 :class "system-item"
+ :tooltip "${system_stats.sound.tooltip}"
+ (image :class "system-icon" :path "@@icon-audio@@" :image-width 24 :image-height 24)
+ (label :class "system-label" :text "${system_stats.sound.mute ? '-' : (system_stats.sound.percent + '%')}")))
+ (box :orientation "v" :class "system-item" :space-evenly false :spacing 4
+ :tooltip "${full_date} ${time} (${date})"
+ (image :class "system-icon" :path "@@icon-calendar@@" :image-width 24 :image-height 24)
+ (label :class "system-label small" :text time)
+ (label :class "system-label small" :text date))))
diff --git a/modules/desktop/eww/yuck.nix b/modules/desktop/eww/yuck.nix
index 6a7cbf4..db49e99 100644
--- a/modules/desktop/eww/yuck.nix
+++ b/modules/desktop/eww/yuck.nix
@@ -89,91 +89,33 @@
'';
};
in
- ''
- (defpoll time :interval "10s" "date '+%H:%M'")
- (defpoll date :interval "60s" "date '+%d/%m'")
- (defpoll full_date :interval "60s" "date '+%A, %d %B %Y'")
- (deflisten workspaces :initial "[]" "${lib.getExe workspaces}")
- (deflisten active-windows :initial "[]" "${lib.getExe activate-windows}")
- (deflisten system_stats
- :initial "{\"cpu\":{\"percent\":0,\"per_core\":[],\"freq_mhz\":null,\"load_avg\":null,\"tooltip\":\"CPU: 0%\"},\"ram\":{\"percent\":0,\"used\":\"0B\",\"total\":\"0B\",\"available\":\"0B\",\"swap_percent\":0,\"swap_used\":\"0B\",\"swap_total\":\"0B\",\"speed_mhz\":null,\"tooltip\":\"RAM: 0%\"},\"net\":{\"status\":\"down\",\"tooltip\":\"Network Offline\",\"routes\":[]},\"sound\":{\"percent\":0,\"mute\":true,\"sink\":null,\"tooltip\":\"Volume: unknown\"}}"
- "${lib.getExe system-stats}")
-
- (defwindow bar
- :monitor 0
- :geometry (geometry
- :x "0px"
- :y "0px"
- :width "60px"
- :height "100%"
- :anchor "top right")
- :stacking "fg"
- :focusable "none"
- :reserve (struts :distance "60px" :side "right")
- (bar-content))
-
- (defwidget bar-content []
- (box :orientation "v"
- :space-evenly false
- :class "bar-container"
- :vexpand true
- (workspaces-widget)
- (windows-widget)
- (system-widget)))
-
- (defwidget workspaces-widget []
- (box :orientation "v" :space-evenly false :spacing 4 :halign "fill" :class "workspaces"
- (for ws in workspaces
- (eventbox :onclick "niri msg action focus-workspace ''${ws.idx}"
- :cursor "pointer" :halign "fill"
- :tooltip "''${ws.tooltip}"
- (box :class "workspace-button ''${ws.is_active ? 'active' : '''}" :halign "fill"
- (overlay :halign "fill"
- (image :class "workspace-icon"
- :path "''${ws.icon != ''' ? ws.icon : '${../../../assets/icons/unknown.svg}'}"
- :image-width 20 :image-height 20)
- (label :class "workspace-idx" :text "''${ws.idx}" :halign "end" :valign "end")))))))
-
- (defwidget windows-widget []
- (box :orientation "v" :space-evenly false :spacing 4 :halign "center" :class "windows" :vexpand true
-
- (for w in active-windows
- (eventbox :onclick "niri msg action focus-window --id ''${w.id}"
- :cursor "pointer"
- :halign "fill"
- :tooltip "''${w.app_id}: ''${w.title != ''' ? ' ' : '''}''${w.title}"
- (box :halign "fill" :class "window-button ''${w.is_focused ? 'focused' : '''}"
- (image :class "window-icon" :path "''${w.icon != ''' ? w.icon : '${../../../assets/icons/unknown.svg}'}" :image-width 20 :image-height 20))))))
-
- (defwidget system-widget []
- (box :orientation "v" :space-evenly false :spacing 6 :halign "fill" :class "system"
- (box :orientation "v" :class "system-item" :halign "fill" :space-evenly false :spacing 4
- :tooltip "''${system_stats.net.tooltip}"
- (image :class "system-icon"
- :path "''${system_stats.net.status == 'down' ? '${../../../assets/icons/bar/offline.svg}' : system_stats.net.routes[0].type == 'wifi' ? '${../../../assets/icons/bar/wifi.svg}' : system_stats.net.routes[0].type == 'ethernet' ? '${../../../assets/icons/bar/ethernet.svg}' : '${../../../assets/icons/bar/offline.svg}'}"
- :image-width 24 :image-height 24)
- (label :class "system-label small"
- :text "''${system_stats.net.status == 'down' ? '-' : system_stats.net.routes[0].tx}")
- (label :class "system-label small"
- :text "''${system_stats.net.status == 'down' ? '-' : system_stats.net.routes[0].rx}"))
- (box :orientation "v" :class "system-item" :space-evenly false :spacing 4
- :tooltip "''${system_stats.cpu.tooltip}"
- (image :class "system-icon" :path "${../../../assets/icons/bar/cpu.svg}" :image-width 24 :image-height 24)
- (label :class "system-label" :text "''${system_stats.cpu.percent}%"))
- (box :orientation "v" :class "system-item" :space-evenly false :spacing 4
- :tooltip "''${system_stats.ram.tooltip}"
- (image :class "system-icon" :path "${../../../assets/icons/bar/ram.svg}" :image-width 24 :image-height 24)
- (label :class "system-label" :text "''${system_stats.ram.percent}%"))
- (eventbox :onclick "pamixer --toggle-mute" :cursor "pointer" :halign "fill"
- (box :orientation "v" :space-evenly false :spacing 4 :class "system-item"
- :tooltip "''${system_stats.sound.tooltip}"
- (image :class "system-icon" :path "${../../../assets/icons/bar/audio.svg}" :image-width 24 :image-height 24)
- (label :class "system-label" :text "''${system_stats.sound.mute ? '-' : (system_stats.sound.percent + '%')}")))
- (box :orientation "v" :class "system-item" :space-evenly false :spacing 4
- :tooltip "''${full_date} ''${time} (''${date})"
- (image :class "system-icon" :path "${../../../assets/icons/bar/calendar.svg}" :image-width 24 :image-height 24)
- (label :class "system-label small" :text time)
- (label :class "system-label small" :text date))))
- '';
+ builtins.replaceStrings
+ [
+ "@@workspaces-script@@"
+ "@@windows-script@@"
+ "@@systemstats-script@@"
+ "@@icon-unknown@@"
+ "@@icon-offline@@"
+ "@@icon-wifi@@"
+ "@@icon-ethernet@@"
+ "@@icon-cpu@@"
+ "@@icon-ram@@"
+ "@@icon-audio@@"
+ "@@icon-calendar@@"
+ ]
+ [
+ (lib.getExe workspaces)
+ (lib.getExe activate-windows)
+ (lib.getExe system-stats)
+ (toString ../../../assets/icons/unknown.svg)
+ (toString ../../../assets/icons/bar/offline.svg)
+ (toString ../../../assets/icons/bar/wifi.svg)
+ (toString ../../../assets/icons/bar/ethernet.svg)
+ (toString ../../../assets/icons/bar/cpu.svg)
+ (toString ../../../assets/icons/bar/ram.svg)
+ (toString ../../../assets/icons/bar/audio.svg)
+ (toString ../../../assets/icons/bar/calendar.svg)
+ ]
+ (builtins.readFile ./bar.yuck);
};
}