Improve eww status bar platform compatibility

This commit is contained in:
Kiana Sheibani 2024-05-12 22:31:04 -04:00
parent c28861f964
commit 7b998a9023

View file

@ -4,18 +4,18 @@
(deflisten window :initial "{}" (deflisten window :initial "{}"
"~/.config/eww/scripts/active-window") "~/.config/eww/scripts/active-window")
(defwidget bar_window [] (defwidget bar_window [class-limit title-limit]
(box :class "bar-window" (box :class "bar-window"
:orientation "v" :orientation "v"
:space-evenly false :space-evenly false
(label :class "detail" (label :class "detail"
:halign "start" :halign "start"
:valign "end" :valign "end"
:limit-width 60 :limit-width class-limit
:text {window.class ?: "Desktop"}) :text {window.class ?: "Desktop"})
(label :halign "start" (label :halign "start"
:valign "end" :valign "end"
:limit-width 55 :limit-width title-limit
:text {window.title ?: "Workspace ${current_workspace}"}))) :text {window.title ?: "Workspace ${current_workspace}"})))
;; Workspaces ;; Workspaces
@ -46,10 +46,10 @@
;; Time ;; Time
(defwidget bar_time [] (defwidget bar_time [width]
(box :class "bar-time segment" (box :class "bar-time segment"
:orientation "h" :orientation "h"
:width 195 :width width
:space-evenly false :space-evenly false
:spacing 6 :spacing 6
(label :halign "start" (label :halign "start"
@ -66,11 +66,11 @@
(deflisten mpris :initial "{}" (deflisten mpris :initial "{}"
"~/.config/eww/scripts/mpris-metadata") "~/.config/eww/scripts/mpris-metadata")
(defwidget bar_music [] (defwidget bar_music [width artist-limit title-limit]
(eventbox :onclick "playerctl play-pause" (eventbox :onclick "playerctl play-pause"
(box :class "bar-music segment" (box :class "bar-music segment"
:orientation "h" :orientation "h"
:width 195 :width width
:space-evenly false :space-evenly false
(box :class "progress" (box :class "progress"
(overlay (overlay
@ -96,16 +96,16 @@
:visible {(mpris.title ?: "") != "" && (mpris.status ?: "Stopped") != "Stopped"} :visible {(mpris.title ?: "") != "" && (mpris.status ?: "Stopped") != "Stopped"}
(label :class "bar-artist detail" (label :class "bar-artist detail"
:halign "start" :halign "start"
:limit-width 30 :limit-width artist-limit
:text {mpris.artist ?: ""}) :text {mpris.artist ?: ""})
(label :halign "bar-title" (label :halign "bar-title"
:limit-width 25 :limit-width title-limit
:text {mpris.title ?: ""}))))) :text {mpris.title ?: ""})))))
;; Scales (Volume + Brightness) ;; Scales (Volume + Brightness)
(defwidget bar_scale [?class reveal_name reveal value symbol onchange ?onclick] (defwidget bar_scale [?class reveal-name reveal value symbol onchange ?onclick]
(eventbox :onhover "${EWW_CMD} update ${reveal_name}=true" (eventbox :onhover "${EWW_CMD} update ${reveal_name}=true"
:onhoverlost "${EWW_CMD} update ${reveal_name}=false" :onhoverlost "${EWW_CMD} update ${reveal_name}=false"
(box :class "bar-scale ${class}" (box :class "bar-scale ${class}"
@ -134,7 +134,7 @@
(defwidget bar_volume [] (defwidget bar_volume []
(bar_scale :class "bar-volume ${volume.muted ? "muted" : ""}" (bar_scale :class "bar-volume ${volume.muted ? "muted" : ""}"
:reveal_name "volume_reveal" :reveal-name "volume_reveal"
:reveal volume_reveal :reveal volume_reveal
:value {volume.value} :value {volume.value}
:symbol {volume.muted ? "󰝟" : :symbol {volume.muted ? "󰝟" :
@ -151,7 +151,7 @@
(defwidget bar_brightness [] (defwidget bar_brightness []
(bar_scale :class "bar-brightness" (bar_scale :class "bar-brightness"
:reveal_name "brightness_reveal" :reveal-name "brightness_reveal"
:reveal brightness_reveal :reveal brightness_reveal
:value brightness :value brightness
:symbol "󰃠" :symbol "󰃠"
@ -223,8 +223,7 @@
(defwidget bar_bluetooth [] (defwidget bar_bluetooth []
(box :class "bar-bluetooth ${bluetooth == "{}" ? "disabled" : ""}" (box :class "bar-bluetooth ${bluetooth == "{}" ? "disabled" : ""}"
(label :limit-width 15 (label :text {bluetooth != "{}" ? "󰂯" : "󰂲"})))
:text {bluetooth != "{}" ? "󰂯" : "󰂲"})))
;; Separator ;; Separator
@ -242,14 +241,15 @@
:space-evenly false :space-evenly false
:halign "start" :halign "start"
:hexpand true :hexpand true
(bar_window))) (bar_window :class-limit 60
:title-limit 55)))
(defwidget bar_left_wing [] (defwidget bar_left_wing []
(box :orientation "h" (box :orientation "h"
:space-evenly false :space-evenly false
:halign "end" :halign "end"
:hexpand true :hexpand true
(bar_time))) (bar_time :width 195)))
(defwidget bar_center [] (defwidget bar_center []
(bar_workspaces)) (bar_workspaces))
@ -258,7 +258,9 @@
(box :orientation "h" (box :orientation "h"
:space-evenly false :space-evenly false
:hexpand true :hexpand true
(bar_music))) (bar_music :width 195
:artist-limit 30
:title-limit 25)))
(defwidget laptop_bar_right_edge [] (defwidget laptop_bar_right_edge []
(box :orientation "h" (box :orientation "h"
@ -290,6 +292,30 @@
(laptop_bar_right_edge)))) (laptop_bar_right_edge))))
(defwidget desktop_bar_left_edge []
(box :orientation "h"
:space-evenly false
:halign "start"
:hexpand true
(bar_window :class-limit 90
:title-limit 80)))
(defwidget desktop_bar_left_wing []
(box :orientation "h"
:space-evenly false
:halign "end"
:hexpand true
(bar_time)))
(defwidget desktop_bar_center []
(bar_workspaces))
(defwidget desktop_bar_right_wing []
(box :orientation "h"
:space-evenly false
:hexpand true
(bar_music)))
(defwidget desktop_bar_right_edge [] (defwidget desktop_bar_right_edge []
(box :orientation "h" (box :orientation "h"
:space-evenly false :space-evenly false
@ -309,13 +335,13 @@
(box :orientation "h" (box :orientation "h"
:space-evenly false :space-evenly false
:hexpand true :hexpand true
(bar_left_edge) (desktop_bar_left_edge)
(bar_left_wing)) (desktop_bar_left_wing))
(bar_center) (bar_center)
(box :orientation "h" (box :orientation "h"
:space-evenly false :space-evenly false
(bar_right_wing) (desktop_bar_right_wing)
(laptop_bar_right_edge)))) (desktop_bar_right_edge))))
(defwindow laptop_bar (defwindow laptop_bar