config/eww/bar/eww.yuck

268 lines
5.9 KiB
Plaintext
Raw Normal View History

(defvar eww "eww --config $HOME/.config/eww/bar")
2024-05-31 14:33:53 -07:00
(defwindow vbar
:exclusive true
:monitor 0
:windowtype "dock"
:geometry (geometry
:x "0%"
:y "0%"
:width "20px"
:height "100%"
:anchor "center left"
)
:reserve (struts :side "left" :distance "20px")
2024-05-31 14:33:53 -07:00
(centerbox
:orientation "v"
(box :orientation "v" :space-evenly false :valign "start"
;(box :class "launcher" :valign "start" :width "10px" :height "10px" "☯")
(label
:class "launcher" :valign "start" :width "20px" :height "20px"
:unindent true
:tooltip active-window-title
:text "☯")
2024-05-31 14:33:53 -07:00
(widget-workspaces)
)
(widget-media)
;(widget-weather :orientation "v")
(box :orientation "v" :space-evenly false :valign "end"
(widget-tray)
(widget-audio)
(widget-cpu)
(widget-memory)
(widget-clock)
)
;(widget_status)
))
2024-05-31 14:33:53 -07:00
(defwindow hbar
:exclusive true
:monitor 0
:windowtype "dock"
:geometry (geometry
:x "0%"
:y "0%"
:width "90%"
:height "20px"
:anchor "top center"
)
:reserve (struts :side "top" :distance "20px")
(centerbox :orientation "h"
(box :orientation "h")
(box :orientation "h")
(box :orientation "h" :space-evenly false :halign "end"
(widget-cpu)
(widget-memory)
)
))
2024-05-31 14:33:53 -07:00
(defwidget widget-workspaces []
(box
:class "workspaces"
:orientation "v"
:space-evenly true
:valign "start" :spacing 10
:halign "center"
(for workspace in workspaces
(button
:class "${workspace.class}"
:onclick "scripts/workspace.sh ${workspace.id}"
"${workspace.text}"))
))
(deflisten workspaces :initial "[]"
"scripts/compositor-control workspaces")
(deflisten active-window-title :initial ""
"scripts/compositor-control active-title")
; Weather
2024-05-31 14:33:53 -07:00
(defwidget widget-weather [orientation]
(box
:class "weather"
:orientation orientation
:space-evenly false
:valign "start"
:halign "center"
:spacing 10
(button :onclick "scripts/popup weather" "W")
))
2024-05-31 14:33:53 -07:00
(defpoll weather-text :initial "" :interval "180s"
"curl --max-time 2 wttr.in")
(defwindow weather
:geometry (geometry :x "70px"
:y "50%"
:width "270px"
:height "60px")
2024-05-31 14:33:53 -07:00
(box weather-text))
2024-05-31 14:33:53 -07:00
(defwidget widget-media []
(box
:class "media"
:orientation "v"
:space-evenly false
:valign "center"
(circular-progress
:class "media"
:width 20
:height 20
:thickness 5
;:tooltip {music_listener_position}
:tooltip "${music_position} / ${music_length}"
:value {100.0 * music_position / (music_length / 1000000.0)}
:visible {music_listener != "" && music_length != 1}
2024-05-31 14:33:53 -07:00
)
; Add play and pause buttons here?
2024-05-31 14:33:53 -07:00
(label
:angle 270
2024-05-31 14:33:53 -07:00
:xalign 0.5
:yalign 0.5
:justify "center"
:text {music_listener != "" ? "『${music_listener}』" : "『』"})
2024-05-31 14:33:53 -07:00
))
(deflisten music_listener :initial ""
"playerctl --follow metadata --format '{{ artist }} / {{album}} / {{ title }}' || true")
(deflisten music_listener_position :initial ""
2024-05-31 14:33:53 -07:00
"playerctl --follow metadata --format '{{duration(position)}} / {{duration(mpris:length)}}' || true")
(defpoll music_position :interval "1s"
"playerctl position")
(deflisten music_length :initial 1
"playerctl --follow metadata mpris:length")
2024-05-31 14:33:53 -07:00
(defwidget widget-audio []
(eventbox
:class "audio"
2024-05-31 14:33:53 -07:00
:onhover "${eww} update show_audio=true"
:onhoverlost "${eww} update show_audio=false"
(box
:class "audio"
:orientation "v"
:space-evenly "false"
:spacing "2"
(revealer :transition "slideup" :reveal show_audio
(scale
:class "audio-scale"
:value current-volume
:orientation "v"
:flipped true
:marks true
2024-05-31 14:33:53 -07:00
:tooltip "Volume: ${current-volume}%"
:max 101
:min 0
:onchange "amixer -D pulse sset Master {}%" ))
(button
:class "audio"
2024-05-31 14:33:53 -07:00
:onclick "scripts/popup audio"
:tooltip "Volume: ${current-volume}%"
2024-05-31 14:33:53 -07:00
:class "volume-icon" ""))))
(defpoll current-volume :interval "1s" "amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'")
(defvar show_audio false)
(defwidget widget-cpu []
(circular-progress
:class "cpu"
:width 20
:height 20
:thickness 4
:tooltip {EWW_CPU.cores}
:value {EWW_CPU.avg}
))
(defwidget widget-memory []
(circular-progress
:class "memory"
:width 20
:height 20
:thickness 4
:tooltip "${EWW_RAM.used_mem} / ${EWW_RAM.total_mem}"
:value {EWW_RAM.used_mem_perc}
))
(defwidget widget-tray []
(systray
:class "systray"
:orientation "v"
:space-evenly true
:icon-size 20
:prepend-new true
))
(defwidget widget-clock []
(box
:class "clock"
:orientation "v"
:valign "end"
:spacing 1
2024-05-31 14:33:53 -07:00
:width 25
(box :class "icon" "")
"${clock.m}" "${clock.d}"
2024-05-31 14:33:53 -07:00
(box :class "icon" "")
"${clock.H}" "${clock.M}"
))
(defpoll clock :initial "{}" :interval "10s"
"date '+{\"H\":\"%H\", \"M\":\"%M\", \"d\":\"%d\", \"m\":\"%m\", \"b\":\"%b\", \"Y\":\"%Y\"}'")
; Calendar
(defwindow calendar
:geometry (geometry :x "70px"
:y "65%"
:width "270px"
:height "60px")
2024-05-31 14:33:53 -07:00
(cal))
(defwidget cal []
(box :class "cal"
:orientation "v"
(box :class "cal-inner-box"
(calendar :class "cal"
:day calendar_day
:month calendar_month
:year calendar_year))))
(defpoll calendar_day :interval "10h"
"date '+%d'")
(defpoll calendar_month :interval "10h"
"scripts/calendar")
(defpoll calendar_year :interval "10h"
"date '+%Y'")
; Unused widgets
2024-05-31 14:33:53 -07:00
;(defwidget widget_status []
; (box
; :class "status"
; :orientation "v"
; :space-evenly false
; :valign "end"
; (metric :label ""
; :value volume
; :onchange "amixer -D pulse sset Master {}%")
; (metric :label ""
; :value {EWW_RAM.used_mem_perc}
; :onchange "")
; (widget_clock)))
(defwidget metric [label value onchange]
(box
:orientation "v"
:class "metric"
:space-evenly false
(box :class "label" label)
(circular-progress :value value)
;(scale
; :min 0 :max 101
; :active {onchange != ""}
; :orientation "v"
; :value value
; :onchange onchange)
))
(defpoll volume :initial 0 :interval "1s"
"scripts/get-volume.sh")