(defwidget bar [] (centerbox :orientation "h" (leftstuff) (music) (rightstuff))) (defwidget rightstuff [] (box :class "rightstuff" :orientation "h" :space-evenly false :halign "end" (eventbox :onclick "pamixer -t" :onscroll "scripts/scroll_volume {}" (metric :label {muted ? "🔇" : volume > 90 ? "🔊" : volume > 0 ? "🔉" : "🔈"} :value volume :onchange "pamixer --set-volume {}")) (metric :label "" :value {EWW_RAM.used_mem_perc} :onchange "") (metric :label "💾" :value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)} :onchange "") time ;systray ; when this lands, anyway )) (defwidget leftstuff [] (box :class "leftstuff" :orientation "h" :space-evenly false :halign "start" (workspaces) (scratches))) (defwidget workspaces [] (eventbox :onscroll "swaymsg workspace $(echo {} | sed -e 's/up/prev/' -e 's/down/next/')" (box :class "workspaces" :orientation "h" :halign "start" :spacing 0 (for w in { workspaces.workspaces } (button :width 20 :onclick "swaymsg workspace ${w?.name ?: '??'}" :class {w?.class} {w?.name ?: '??'} ))))) (defwidget scratches [] (eventbox :class "scratches" :onscroll "swaymsg scratchpad show" (overlay (button :width 40 :onclick "swaymsg scratchpad show" "" ) (label :text {workspaces.exposed_scratch_count > 0 ? "📂" : "📁"} :class "folder ${workspaces.exposed_scratch_count > 0 ? "open" : "closed"}" :yalign 1) (label :text `${jq(workspaces, '[.exposed_scratch_count, .scratches[].window_count]|add')}` :yalign 0.1 )))) (defwidget music [] (box :class "music" :orientation "h" :space-evenly false :halign "center" {music != "" ? "🎵${music}" : ""})) (defwidget metric [label value onchange] (box :orientation "h" :class "metric" :space-evenly false (box :class "label" label) (scale :min 0 :max 101 :active {onchange != ""} :value value :onchange onchange))) (deflisten music :initial "" "playerctl --follow metadata --format '{{ artist }} - {{ title }}' || true") (deflisten volume "scripts/track_volume") (deflisten muted "scripts/track_mute") (deflisten workspace :initial "1" `scripts/track_workspace`) (deflisten workspaces :initial `{"workspaces":[],"scratches":[]}` `scripts/track_workspaces`) (defpoll time :interval "1s" "date '+%H:%M:%S %b %d, %Y'") (defwindow bar :monitor 0 :windowtype "dock" :geometry (geometry :x "0%" :y "0%" :width "100%" :height "30px" :anchor "top center") :exclusive true :reserve (struts :side "top" :distance "30px") (bar))