dotfiles/de/home/.config/eww/eww.yuck
2025-03-04 21:30:01 -08:00

394 lines
11 KiB
Text

(defwidget bar []
(centerbox :orientation "h"
(leftgroup)
(music)
(rightgroup)))
(defwidget leftgroup []
(box :class "leftgroup" :orientation "h" :space-evenly false :halign "start"
(powermenu)
(profile)
(workspaces :array workspacesArray)
(windowtitle)))
(defwidget rightgroup []
(box :class "rightgroup" :orientation "h" :space-evenly false :halign "end"
(idleinhibit)
(volume)
(network)
(vpn)
(bluetooth)
(battery)
(sysdisk)
(sysmem)
(clock)
(tray)))
(deflisten workspacesArray :initial "${[1]}"
`~/.config/eww/scripts/getWorkspaces.sh`)
(defwidget workspaces [array]
(box :class "workspaces"
:orientation "h"
:space-evenly true
:halign "start"
(for entry in array
(button :onclick `swaymsg workspace "${entry.name}"`
:class {entry.focused ? "focused" : ""}
`${replace(entry.name,".*:","")}`))))
(defpoll active_profile :initial false
:interval "1s"
"sp-profile-icon")
(defwidget profile []
(button :onclick "sp-profiles next"
:class "profile"
{active_profile}))
(deflisten active_window_name :initial ""
:interval "1s"
"scripts/activewindow")
(defwidget windowtitle []
(box :class "active_window"
{active_window_name}))
(defwidget clock []
(button :onclick 'notify-send "test"'
{formattime(EWW_TIME,"%b %d, %Y | %H:%M")}))
(defpoll inhibit_active :initial false
:interval "1s"
"scripts/inhibit-status")
(defwidget idleinhibit []
(button :onclick {inhibit_active ? 'killall eww-idle-inhibit' : 'systemd-inhibit --what="idle" --mode="block" scripts/eww-idle-inhibit'}
:class {inhibit_active ? "active" : ""}
{inhibit_active ? "" : ""}))
(defwidget revealer-on-hover [revealvar revealvar-name ?class ?duration ?transition]
(box
:class "${class} revealer-on-hover"
:orientation "h"
:space-evently false
(eventbox
:onhover "${EWW_CMD} update ${revealvar-name}=true"
:onhoverlost "${EWW_CMD} update ${revealvar-name}=false"
(box
:space-evenly false
(children :nth 0)
(revealer
:reveal revealvar
:transition {transition ?: "slideright"}
:duration {duration ?: "500ms"}
(children :nth 1))))))
(defvar reveal_powermenu false)
(defwidget powermenu []
(revealer-on-hover
:revealvar reveal_powermenu
:revealvar-name "reveal_powermenu"
(button :onclick 'sp-powermenu'
"")
(powermenu_children)))
(defwidget powermenu_children []
(box :class "reveal_children"
:orientation "h"
:space-evenly false
:halign "center"
(button :onclick 'sp-powermenu'
"")
(button :onclick 'sp-powermenu'
"")
(button :onclick 'sp-powermenu'
"")
(button :onclick 'sp-powermenu'
"")))
(defpoll wireless_active :initial false
:interval "1s"
"scripts/network-status wireless")
(defpoll wired_active :initial false
:interval "1s"
"scripts/network-status wired")
(defvar reveal_network false)
(defwidget network []
(revealer-on-hover
:revealvar reveal_network
:revealvar-name "reveal_network"
(button :onclick 'nm-connection-editor'
:class {wireless_active || wired_active ? "active" : ""}
"")
(network_children)))
(defwidget network_children []
(box :class "reveal_children"
:orientation "h"
:space-evenly false
:halign "center"
(button :onclick {wireless_active ? 'scripts/network-updown wifi down' : 'scripts/network-updown wifi up'}
:class {wireless_active ? "active" : ""}
"")
(button :onclick {wired_active ? 'scripts/network-updown ethernet down' : 'scripts/network-updown ethernet up'}
:class {wired_active ? "active" : ""}
"🖧")))
(defvar reveal_bluetooth false)
(defpoll bluetooth_active :initial true
:interval "5s"
'scripts/bt-status')
(defwidget bluetooth []
(revealer-on-hover
:revealvar reveal_bluetooth
:revealvar-name "reveal_bluetooth"
(button :onclick 'blueman-manager'
:class {bluetooth_active ? "active" : ""}
"")
(bluetooth_children :array btDeviceArray)))
(defpoll btDeviceArray :initial "${[1]}"
:interval "5s"
'scripts/bt-devices')
(defwidget bluetooth_children [array]
(box :class "reveal_children"
:orientation "h"
:space-evenly true
:halign "start"
(for device in array
(button :onclick {(device.connected == "yes") ? 'bluetoothctl disconnect "${device.address}"' : 'bluetoothctl connect "${device.address}"'}
:class {(device.connected == "yes") ? "active" : ""}
"${device.icon}"))))
(defvar reveal_volume false)
(defwidget volume []
(revealer-on-hover
:revealvar reveal_volume
:revealvar-name "reveal_volume"
(button :onclick 'pavucontrol-qt --tab 3'
{(volume_level == 0) ? "" : ((volume_level > 50) ? "" : "")})
(volume_children)))
(defpoll volume_level :initial 0
:interval "1s"
"scripts/volume-status")
(defwidget volume_children []
(box :class "reveal_children"
:orientation "h"
:space-evenly false
:halign "center"
(scale
:min 0
:max 100
:value {volume_level}
:orientation "h"
:onchange "wpctl set-volume @DEFAULT_AUDIO_SINK@ {}%;paplay 'volume.ogg'")))
(defvar reveal_battery false)
(defwidget battery []
(revealer-on-hover
:revealvar reveal_battery
:revealvar-name "reveal_battery"
(button :onclick 'pavucontrol-qt --tab 3'
{(EWW_BATTERY.BAT0.status == "Charging") ? " ${EWW_BATTERY.BAT0.capacity}%" : " ${EWW_BATTERY.BAT0.capacity}%"})
(battery_children)))
(defpoll battery_level :initial 0
:interval "1s"
"scripts/battery-status")
(defwidget battery_children []
(box :class "reveal_children"
:orientation "h"
:space-evenly false
:halign "center"
(progress
:height 10
:valign "center"
:value {EWW_BATTERY.BAT0.capacity}
:orientation "h")))
(defvar reveal_tray false)
(defwidget tray []
(revealer-on-hover
:revealvar reveal_tray
:revealvar-name "reveal_tray"
{reveal_tray ? "" : ""}
(tray_children)))
(defwidget tray_children []
(box :class "tray_children"
:orientation "h"
:space-evenly false
:halign "center"
(systray
:orientation "h"
:space-evenly true
:spacing 10
:prepend-new true)))
(defpoll vpn_active :initial false
:interval "5s"
"scripts/vpn-status")
(defvar reveal_vpn false)
(defwidget vpn []
(revealer-on-hover
:revealvar reveal_vpn
:revealvar-name "reveal_vpn"
(button :onclick 'notify-send "test"'
:class {vpn_active ? "active" : ""}
{vpn_active ? "" : ""})
(vpn_children)))
(defpoll home_vpn_active :initial false
:interval "5s"
"scripts/vpn-status Home")
(defpoll proton_vpn_active :initial false
:interval "5s"
"scripts/vpn-status Proton")
(defwidget vpn_children []
(box :class "reveal_children"
:orientation "h"
:space-evenly false
:halign "center"
(button :onclick 'scripts/nmcli-vpn "HomeVPN"'
:class {home_vpn_active ? "active" : ""}
{home_vpn_active ? "" : ""})
(button :onclick 'scripts/nmcli-vpn "Proton SE-NL"'
:class {proton_vpn_active ? "active" : ""}
{proton_vpn_active ? "" : ""})))
(defvar reveal_sysmem false)
(defwidget sysmem []
(revealer-on-hover
:revealvar reveal_sysmem
:revealvar-name "reveal_sysmem"
(metric :label " "
:value {EWW_RAM.used_mem_perc}
:onchange "")
(sysmem_children)))
(defwidget sysmem_children []
(box :class "reveal_children"
:orientation "h"
:space-evenly false
:halign "center"
(metric :label " "
:value {round((EWW_RAM.total_mem - EWW_RAM.free_mem) / EWW_RAM.total_mem,2) * 100}
:onchange "")
(metric :label " "
:value {round((EWW_RAM.total_swap - EWW_RAM.free_swap) / EWW_RAM.total_swap,2) * 100}
:onchange "")))
(defvar reveal_sysdisk false)
(defwidget sysdisk []
(revealer-on-hover
:revealvar reveal_sysdisk
:revealvar-name "reveal_sysdisk"
(metric :label "/home "
:value {EWW_DISK["/home"].used_perc}
:onchange "")
(sysdisk_children)))
(defwidget sysdisk_children []
(box :class "reveal_children"
:orientation "h"
:space-evenly false
:halign "center"
(metric :label "/ "
:value {EWW_DISK["/"].used_perc}
:onchange "")
(metric :label "/boot "
:value {EWW_DISK["/boot"].used_perc}
:onchange "")))
(defwidget music []
(box :class "music"
:orientation "h"
:space-evenly false
:halign "center"
{music != "" ? "🎵${music}" : ""}))
(defwidget metric [label value onchange]
(box :orientation "h"
:class "metric"
:space-evenly false
(box :class "label" label)
(circular-progress
:active {onchange != ""}
:value value
:start-at 0
:thickness 10
:clockwise true
:onchange onchange)))
(deflisten music :initial ""
"playerctl --follow metadata --format '{{ artist }} - {{ title }}' || true")
(defpoll volume :interval "1s"
"scripts/getvol")
(defpoll time :interval "10s"
"date '+%H:%M %b %d, %Y'")
(defwindow bar
:windowtype "dock"
:exclusive true
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:height "30px"
:anchor "top center")
:reserve (struts :side "top" :distance "4%")
(bar))
(defwidget widgets []
(box :class "widgets"
:orientation "v"
:spacing 25
:width 300
:space-evenly false
(rat)
(weather :json weather_status)))
(defpoll rat_image :interval "60s"
'scripts/randomrat')
;(defvar rat_image "/home/penelope/Pictures/Phone/Albums/Rattos/20211109_042550_IMG_9873.JPG")
(defwidget rat []
(box
:class "rat"
:orientation "h"
:width 300
:height 300
:style "background-image: url('${rat_image}');"))
(defpoll weather_status :interval "600s"
'curl wttr.in/Eugene?format=j1')
(defwidget weather [json]
(box
:class "weather"
:orientation "v"
:width 300
:height 125
:space-evenly true
; :spacing 20
"Eugene, OR | ${json.current_condition[0].weatherDesc[0].value}"
"${json.weather[0].mintempF}°F / ${json.weather[0].maxtempF}°F"
"${json.current_condition[0].temp_F}°F (feels like ${json.current_condition[0].FeelsLikeF}°F)"
"${json.current_condition[0].humidity}% humidity"))
(defwindow widgets
:windowtype "normal"
:exclusive false
:geometry (geometry :x "10px"
:y "10px"
:width "10px"
:height "10px"
:anchor "top left")
:stacking "bg"
(widgets))