pointfichiers/bar/eww/bar/widget.yuck

253 lines
7 KiB
Text
Raw Normal View History

2024-01-25 14:39:08 +01:00
; Static vars
(defvar GIGA 1073741824)
(defvar network-icon '{
"disconnected": "󰲛",
"ethernet": "󰈀",
"wifi-terrible": "󰤯",
"wifi-bad": "󰤟",
"wifi-mediocre": "󰤢",
"wifi-good": "󰤥",
"wifi-excellent": "󰤨",
"tethering": "󰕓"
}')
2024-01-25 14:39:08 +01:00
(defpoll time :interval "10s"
`date +" %H:%M  %a, %b %d"`)
(defpoll power_profile :interval "10s" :initial "" "~/.config/eww/scripts/power_profile")
(defpoll gpu_status :initial "active" :interval "2s" "cat /sys/bus/pci/devices/0000:01:00.0/power/runtime_status")
(defpoll power_now :initial "0" :interval "5s" "cat /sys/class/power_supply/BAT0/power_now")
(defpoll energy_now :initial "0" :interval "5s" "cat /sys/class/power_supply/BAT0/energy_now")
2024-01-25 14:39:08 +01:00
(defpoll refresh_rate :interval "10s" :initial "165" "~/.config/eww/scripts/refresh_rate")
2024-03-05 19:47:48 +01:00
(defpoll vpn_status :interval "60s" :initial '{"connected": false}' "~/.config/eww/scripts/vpn_status")
2024-01-25 14:39:08 +01:00
(deflisten connectivity :initial '{"state": "disconnected"}' "~/.config/eww/scripts/get-connectivity wlan0")
2024-01-25 14:39:08 +01:00
(deflisten bluetoothinfo :initial '{"count": 0}' "~/.config/eww/scripts/get-bluetooth-info")
(deflisten hypr :initial '{"spaces": [], "current": 0, "title": ""}' "~/.config/eww/scripts/hypr/hyprstatus")
2024-01-25 14:39:08 +01:00
(deflisten volume :initial "{}" "~/.config/eww/scripts/get-volume")
(defwidget container [?nopadding]
(box
:class "container"
:style "padding: ${nopadding == true ? "0px" : "0px 10px 0px 10px"}"
:orientation "horizontal"
:halign "end"
:space-evenly false
(children))
)
(defwidget time []
(label
:class "time"
:text time)
)
2024-03-05 19:47:48 +01:00
(defwidget vpn []
(button
:onclick `~/.config/eww/scripts/vpn_status toggle`
:timeout "10s"
(label
:class "vpn ${vpn_status.connected ? "connected" : "disconnected"}"
:text "${vpn_status.connected ? "󰯄 " : "󰦞 "}")
)
)
2024-01-25 14:39:08 +01:00
(defwidget connectivity []
(eventbox
:onclick "bash -c 'iwgtk &> /dev/null &'"
(label
:class "connectivity"
:text "${
connectivity.state == "wireless"
? network-icon["wifi-${connectivity.wifi.signal}"]
: network-icon[connectivity.state]
} ${
connectivity.state == "disconnected" ? "No network" :
connectivity.state == "ethernet" ? "Ethernet" :
connectivity.state == "wireless" ? connectivity.wifi.ssid :
connectivity.state == "tethering" ? "USB tethering" : ''
}"
:limit-width 14)
)
2024-01-25 14:39:08 +01:00
)
(defwidget bluetooth []
(eventbox
:onclick "bash -c 'blueman-manager &> /dev/null &'"
(label
:class "bluetooth"
:text " ${bluetoothinfo.count > 0 ? bluetoothinfo.count : bluetoothinfo.power}")
)
)
(defwidget workspaces [monitor]
(eventbox :onscroll "bash ~/.config/eww/scripts/hypr/change-active-workspace {} ${hypr.current}" :class "workspaces"
2024-01-25 14:39:08 +01:00
(box :space-evenly true
(label :text "${hypr.spaces}${hypr.current}" :visible false)
(for workspace in {hypr.spaces}
2024-01-25 14:39:08 +01:00
(eventbox :onclick "hyprctl dispatch workspace ${workspace.id}" :visible "${workspace.monitor == monitor}"
(box :class "workspace-entry ${workspace.id == hypr.current ? "current" : ""}"
2024-01-25 14:39:08 +01:00
(label :text "${workspace.id}")
)
)
)
)
)
)
(defwidget activewindow []
(label
:text "${hypr.title ?: "..."}"
:limit-width 64)
2024-01-25 14:39:08 +01:00
)
(defwidget ram []
(label
:text "󰍛 ${round(EWW_RAM.used_mem/GIGA, 1)}G/${round(EWW_RAM.total_mem/GIGA, 1)}G"
:class "${EWW_RAM.used_mem >= EWW_RAM.total_mem * 0.9 ? "critical" : EWW_RAM.used_mem >= EWW_RAM.total_mem * 0.6 ? "warning" : ""}")
)
(defwidget cpu []
(label
:text "󰻠 ${round(EWW_CPU.avg, 0)}%"
:class "${EWW_CPU.avg >= 90 ? "critical" : EWW_CPU.avg >= 60 ? "warning" :""}")
)
(defwidget temp []
(label
:text " ${EWW_TEMPS.ACPITZ_TEMP1}°C"
:class "${EWW_TEMPS.ACPITZ_TEMP1 >= 90 ? "critical" : EWW_TEMPS.ACPITZ_TEMP1 >= 70 ? "warning" : ""}")
)
(defvar PP_STATE '{"Quiet": "normal", "Balanced": "warning", "Performance": "critical"}')
(defwidget powerprofile []
(button :onclick "~/.config/eww/scripts/power_profile next"
(label
:text "󰈐 ${power_profile}"
:class "${PP_STATE[power_profile]}")
)
)
(defvar GPU_ICON '{"active": "󰍹", "suspended": "󰶐", "resuming": "󱄄", "suspending": "󱄄"}')
(defvar GPU_STATE '{"active": "warning", "suspended": "normal", "resuming": "warning", "suspending": "normal"}')
2024-01-25 14:39:08 +01:00
(defwidget gpustatus []
(label
:text "${GPU_ICON[gpu_status]} "
:class "${GPU_STATE[gpu_status]}")
)
(defwidget refreshrate []
(button :onclick "~/.config/eww/scripts/refresh_rate toggle"
(label
:text "${refresh_rate}Hz"
:class "${refresh_rate == "60" ? "normal" : "warning"}")
)
)
(defwidget battery []
(label
:text "${EWW_BATTERY.BAT0.status == "Discharging" ?
" ${EWW_BATTERY.BAT0.capacity}% (${round(energy_now/power_now, 0)}h${round((energy_now/power_now - round(energy_now/power_now - 0.5, 0)) * 60, 0)} at ${round(power_now/1000000, 2)}W)" :
" ${EWW_BATTERY.BAT0.capacity}%"
}"
:class "${EWW_BATTERY.BAT0.status == "Discharging" ? EWW_BATTERY.BAT0.capacity <= 15 || power_now/1000000 > 25 ? "critical" : EWW_BATTERY.BAT0.capacity <= 40 || power_now/1000000 > 15 ? "warning" : "normal" : "normal"}")
2024-01-25 14:39:08 +01:00
)
(defwidget volume []
(eventbox
:onclick "pamixer -t"
:onscroll "echo {} | sed 's/up/-i/g; s/down/-d/g' | xargs -I{} pamixer {} 1"
(label
2024-04-24 10:19:35 +02:00
:text "${volume.speaker == "Muted" ? "󰝟" : ""} ${volume.speaker}"
2024-01-25 14:39:08 +01:00
:class "volume"
)
)
)
(defwidget mic []
(eventbox
:onclick "pamixer --default-source -t"
:onscroll "echo {} | sed 's/up/-i/g; s/down/-d/g' | xargs -I{} pamixer --default-source {} 1"
(label
:text "${volume.mic == "Muted" ? "" : ""} ${volume.mic}"
:class "mic"
)
)
)
(defwidget leftstuff [monitor]
(box
:space-evenly false
(container
(time)
(label :text "") ; Else container spacing rule doesn't apply
2024-01-25 14:39:08 +01:00
(connectivity)
(label :text "") ; Else container spacing rule doesn't apply
(bluetooth)
2024-03-05 19:47:48 +01:00
(vpn)
2024-01-25 14:39:08 +01:00
)
(container
:nopadding true
(workspaces :monitor monitor)
)
)
)
(defwidget centerstuff []
(container
(activewindow)
)
)
(defwidget rightstuff []
(box
:space-evenly false
:halign "end"
(container
(ram)
(cpu)
(temp)
)
(container
2024-01-25 14:39:08 +01:00
(powerprofile)
(box :space-evenly false
(gpustatus)
(refreshrate)
)
(battery)
)
(container
(volume)
(label :text "") ; Else container spacing rule doesn't apply
(mic)
2024-04-24 10:17:30 +02:00
(systray :orientation "h" :spacing 6 :class "systray")
2024-01-25 14:39:08 +01:00
)
)
)
(defwidget barwidget [monitor]
(centerbox
:class "bar"
:orientation "horizontal"
(leftstuff :monitor monitor)
(centerstuff)
(rightstuff)
)
)
(defwindow bar [?monitor]
:namespace "eww.bar"
:monitor "${monitor ?: 0}"
:geometry (geometry
:x "0%"
:y "8px"
:width "100%"
:height "38px"
:anchor "top center")
:stacking "fg"
:focusable false
:exclusive true
(barwidget :monitor "${monitor ?: 0}")
)