dotfiles/.config/eww/eww.yuck
2024-10-21 13:58:13 +02:00

156 lines
4.4 KiB
Text

; Brightness
(deflisten brightness :initial "128" "while :; do cat /sys/class/backlight/amdgpu_bl1/brightness; sleep 0.1; done")
(defvar brightness-icons '["", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]')
(defvar brightness-slide false)
; Battery
(defvar battery-icons '{"Full": {"10": "󰂄"}, "Charging": ["󰢟", "󰢜", "󰂆", "󰂇", "󰂈", "󰢝", "󰂉", "󰢞", "󰂊", "󰂋", "󰂅"], "Discharging": ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"]}')
; DateTime
(defpoll datetime :interval "1s" "date +'%a %e %b %X'")
(defpoll month :interval "1m" :initial "0" "date +'%m'")
(defpoll day :interval "1m" :initial "0" "date +'%d'")
(defpoll year :interval "1m" :initial "0" "date +'%Y'")
; Window Title
(deflisten window-title "~/.config/eww/scripts/get-window-title.sh")
; Workspaces
(deflisten workspaces :initial "[]" "~/.config/eww/scripts/get-workspaces.sh")
(deflisten active-workspace "~/.config/eww/scripts/get-active-workspace.sh")
; Notifications status
(deflisten nf-enabled :initial "true" "while :; do makoctl mode | grep -q dnd && echo true || echo false; sleep 0.1; done")
; Widgets
(defwidget bar-left []
(box :halign "start"
:space-evenly false
(workspaces)
(systray :spacing 8
:icon-size 16
:class "systray"
)
(nf-state)
)
)
(defwidget workspaces []
(eventbox :onscroll "~/.config/eww/scripts/change-active-workspace.sh {} ${active-workspace}"
(box :spacing 0
(for workspace in workspaces
(eventbox :onclick "hyprctl dispatch workspace ${workspace}"
:class "workspace ${workspace == active-workspace ? "active" : ""}"
(label :text "${workspace}")
)
)
)
)
)
(defwidget nf-state []
(eventbox :onclick "makoctl mode -t dnd"
(label :text "${nf-enabled ? "󰂚" : "󰂛"} NF"
:class "${nf-enabled ? "" : "disabled"}"
)
)
)
(defwidget bar-middle []
(label :limit-width 2
:text "${window-title}"
)
)
(defwidget bar-right []
(box :halign "end"
:space-evenly false
(brightness)
(battery :percent {EWW_BATTERY.BAT0.capacity}
:status {EWW_BATTERY.BAT0.status}
)
(ram)
(cpu-temp)
(label :text " ${round(EWW_CPU.avg, 0)}%"
:tooltip " ${arraylength(EWW_CPU.cores)} cores available"
)
(tooltip
(calendar :day {day}
:month {month}
:year {year}
)
(label :text "󰥔 ${datetime}")
)
)
)
(defwidget brightness []
(eventbox :onhover "${EWW_CMD} update brightness-slide=true"
:onhoverlost "${EWW_CMD} update brightness-slide=false"
(box :space-evenly false
(label :text "${brightness-icons[round(brightness / 18.2, 0)]} ${round(brightness /255 * 100, 0)}%")
(revealer :transition "slideleft"
:reveal {brightness-slide}
(scale :value {brightness}
:min 0
:max 255
:onchange "echo {} > /sys/class/backlight/amdgpu_bl1/brightness"
)
)
)
)
)
(defwidget battery [percent status]
(label :text "${battery-icons[status][round(percent / 10, 0)]} ${percent}%"
:tooltip "${percent}% (${status})"
:class "${percent <= 30 ? percent <= 15 ? 'crit' : 'alert' : ''}"
)
)
(defwidget ram []
(label :text " ${round(EWW_RAM.used_mem / 1073741824, 2)}GiB"
:tooltip " ${round(EWW_RAM.used_mem / 1073741824, 2)}GiB out of ${round(EWW_RAM.total_mem / 1073741824, 2)}GiB used"
)
)
(defwidget threshold [val unit alert-val crit-val icon alert-icon crit-icon]
(label :text "${val < alert-val ? icon : (val < crit-val ? alert-icon : crit-icon)} ${round(val, 0)}${unit}"
:class "${val < alert-val ? '' : (val < crit-val ? 'alert' : 'crit')}"
)
)
(defwidget cpu-temp []
(threshold :val {EWW_TEMPS.K10TEMP_TCTL}
:unit "°C"
:alert-val 65
:crit-val 75
:icon "󱃃"
:alert-icon "󰔏"
:crit-icon "󰸁"
)
)
; Bar
(defwidget bar []
(box
(bar-left)
(bar-middle)
(bar-right)
)
)
(defwindow bar :monitor 0
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:anchor "top center"
)
:stacking "fg"
:exclusive true
(bar)
)