dotfiles/.config/eww/eww.yuck

180 lines
5.2 KiB
Text
Raw Normal View History

2024-10-21 16:49:00 +02:00
; Brightness
(defpoll brightness :initial "128" :interval "1m" "cat /sys/class/backlight/amdgpu_bl1/brightness")
2024-10-21 09:34:11 +02:00
(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'")
2024-10-21 16:49:00 +02:00
(defpoll month :interval "1m" :initial "1" "date +'%m'")
(defpoll day :interval "1m" :initial "1" "date +'%d'")
2024-10-21 13:57:40 +02:00
(defpoll year :interval "1m" :initial "0" "date +'%Y'")
2024-10-21 09:34:11 +02:00
; Network
(defpoll network :initial '{"if": "lo"}' :interval "2s" "~/.config/eww/scripts/get-network.sh")
2024-10-21 16:49:00 +02:00
; Notifications status
(defpoll nf-enabled :initial "true" :interval "1m" "makoctl mode | grep -q dnd && echo false || echo true")
2024-10-21 16:49:00 +02:00
; Packages updates
(deflisten packages-updates :initial '{"count": "-", "class": " "}' "~/.config/eww/scripts/pkg-updates.sh")
2024-10-21 09:58:57 +02:00
; Window Title
2024-10-21 13:57:40 +02:00
(deflisten window-title "~/.config/eww/scripts/get-window-title.sh")
2024-10-21 09:58:57 +02:00
2024-10-21 11:14:08 +02:00
; Workspaces
2024-10-21 13:57:40 +02:00
(deflisten workspaces :initial "[]" "~/.config/eww/scripts/get-workspaces.sh")
2024-10-21 11:14:08 +02:00
(deflisten active-workspace "~/.config/eww/scripts/get-active-workspace.sh")
2024-10-21 09:34:11 +02:00
; Widgets
(defwidget bar-left []
(box :halign "start"
:space-evenly false
2024-10-21 11:14:08 +02:00
(workspaces)
(systray :spacing 8
:icon-size 16
:class "systray"
)
2024-10-21 13:57:40 +02:00
(nf-state)
2024-10-21 16:49:00 +02:00
(packages-updates)
(network)
2024-10-21 11:14:08 +02:00
)
)
(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}")
)
)
)
2024-10-21 09:34:11 +02:00
)
)
2024-10-21 13:57:40 +02:00
(defwidget nf-state []
(eventbox :onclick "~/.config/eww/scripts/toggle-nf-state.sh"
2024-10-21 13:57:40 +02:00
(label :text "${nf-enabled ? "󰂚" : "󰂛"} NF"
:class "${nf-enabled ? "" : "disabled"}"
)
)
)
2024-10-21 11:14:08 +02:00
2024-10-21 16:49:00 +02:00
(defwidget packages-updates []
(label :text "󰏖 ${packages-updates.count}"
:class "${packages-updates.class}"
:tooltip "${packages-updates.tooltip}"
)
)
(defwidget network []
(tooltip
(label :text "IPv4: ${network.ip4}\\nIPv6: ${network.ip6}${network.type == "wifi" ? "\\nRate: ${network.rate}\\nSignal strength: ${network.signal}" : ""}")
(label :text "${network.icon} ${network.name} ${network.if == "null" ? "" : "󰜮 ${EWW_NET[network.if].NET_DOWN} 󰜷 ${EWW_NET[network.if].NET_UP}"}")
)
)
2024-10-21 16:49:00 +02:00
2024-10-21 09:58:57 +02:00
(defwidget bar-middle []
(label :limit-width 2
:text "${window-title}"
)
)
2024-10-21 11:14:08 +02:00
2024-10-21 09:34:11 +02:00
(defwidget bar-right []
(box :halign "end"
:space-evenly false
2024-10-21 13:57:40 +02:00
(brightness)
2024-10-21 09:34:11 +02:00
(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}")
)
)
)
2024-10-21 13:57:40 +02:00
(defwidget brightness []
2024-10-21 09:34:11 +02:00
(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 "~/.config/eww/scripts/set-brightness.sh {}"
2024-10-21 09:34:11 +02:00
)
)
)
)
)
(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)
2024-10-21 09:58:57 +02:00
(bar-middle)
2024-10-21 09:34:11 +02:00
(bar-right)
)
)
(defwindow bar :monitor 0
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:anchor "top center"
)
:stacking "fg"
:exclusive true
(bar)
)