dotfiles/de/home/.config/eww/modules/home/mcstatus.yuck
2025-11-05 17:30:03 -08:00

75 lines
2 KiB
Text

(defpoll servers_status :initial '[{"online": true,"kind":"Java","players":{"online":0,"max":0,"list":null},"version":{"name":"version","protocol":0},"motd":"Message of the day","ping":0,"address":"ip.addre.ss"}]'
:interval "21600s"
'scripts/home/mcstatus')
(defvar reveal_mcstatus true)
(defwidget mcstatus_revealer []
(revealer-on-press
:revealvar reveal_mcstatus
:revealvar-name "reveal_mcstatus"
(button
:width 300
:class "revealer-title"
"Minecraft Servers ${reveal_mcstatus ? '' : ''}")
(mcstatus :json servers_status)))
(defwidget mcstatus [json]
(box
:class 'minecraft'
:orientation 'v'
:space-evenly false
(box
:orientation 'v'
:space-evenly true
(for server in json
(box
:class 'server'
:orientation 'h'
:space-evenly false
(box
(box
:class 'icon'
:valign 'center'
:width 75
:height 75
:style 'background-image: url("${server.icon_path}");'
)
)
(box
:class 'details'
:space-evenly false
:orientation 'v'
(label
:class 'title'
:text "${server.address}"
)
(label
:xalign 0
:text "${server.players.online}/${server.players.max} players online"
)
(label
:class 'motd'
:text "${server.motd}"
:wrap true
:wrap-mode 'word'
; :truncate true
)
(label
:xalign 0
:text " ${round(server.ping,0)}ms"
)
)
)
)
)
(button
:class 'button'
:onclick 'eww poll servers_status'
:onrightclick 'rm ~/.cache/mcstatus/mcstatus.json;eww poll servers_status'
:tooltip 'right-click to bypass cache'
(label
:text "reload now"
)
)
)
)