config/eww/bar/eww.yuck

256 lines
5.8 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"
2024-06-02 07:11:20 -07:00
:height "99%"
: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)
(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/compositor-control set-workspace ${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"
2024-06-02 07:11:20 -07:00
(eventbox
:onclick "playerctl play-pause"
(circular-progress
:class { media-status == "Paused" ? "media-paused" : "media-playing" }
:width 20
:height 20
:thickness 5
:tooltip {media-position-text}
:value {100.0 * media-position / (media-length / 1000000.0)}
:visible {media-current != "" && media-length != 1}
))
2024-05-31 14:33:53 -07:00
(label
2024-06-02 07:11:20 -07:00
:class { media-status == "Paused" ? "media-text-paused" : "media-text-playing" }
:angle 270
2024-05-31 14:33:53 -07:00
:xalign 0.5
:yalign 0.5
:justify "center"
2024-06-02 07:11:20 -07:00
:text {media-current != "" ? "『${media-current}』" : "『』"})
2024-05-31 14:33:53 -07:00
))
2024-06-02 07:11:20 -07:00
(deflisten media-current :initial ""
2024-05-31 14:33:53 -07:00
"playerctl --follow metadata --format '{{ artist }} / {{album}} / {{ title }}' || true")
2024-06-02 07:11:20 -07:00
(deflisten media-position-text :initial ""
2024-05-31 14:33:53 -07:00
"playerctl --follow metadata --format '{{duration(position)}} / {{duration(mpris:length)}}' || true")
2024-06-02 07:11:20 -07:00
(defpoll media-position :interval "1s"
"playerctl position")
2024-06-02 07:11:20 -07:00
(deflisten media-length :initial 1
"playerctl --follow metadata mpris:length")
2024-06-02 07:11:20 -07:00
(deflisten media-status :initial "Stopped"
"playerctl --follow status")
2024-05-31 14:33:53 -07:00
(defwidget widget-audio []
(eventbox
:class "audio"
2024-06-02 07:11:20 -07:00
:onhover "${eww} update show-audio=true"
:onhoverlost "${eww} update show-audio=false"
2024-05-31 14:33:53 -07:00
(box
:class "audio"
:orientation "v"
:space-evenly "false"
:spacing "2"
2024-06-02 07:11:20 -07:00
(revealer :transition "slideup" :reveal show-audio
2024-05-31 14:33:53 -07:00
(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 {}%" ))
2024-06-02 07:11:20 -07:00
(label
:class "audio-icon"
:width 20 :height 20
:xalign 0.5 :yalign 0.5
:noindent true
:tooltip "Volume: ${current-volume}%"
2024-06-02 07:11:20 -07:00
:text { current-volume == 0 ? "" : (current-volume > 80 ? "" : "") }))))
2024-05-31 14:33:53 -07:00
(defpoll current-volume :interval "1s" "amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'")
2024-06-02 07:11:20 -07:00
(defvar show-audio false)
2024-05-31 14:33:53 -07:00
(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-06-02 07:11:20 -07:00
:width 20
(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'")
(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")