diff --git a/de/home/.config/eww/scripts/home/mcstatus b/de/home/.config/eww/scripts/home/mcstatus index bc8c5aa..81d6c8d 100755 --- a/de/home/.config/eww/scripts/home/mcstatus +++ b/de/home/.config/eww/scripts/home/mcstatus @@ -1,6 +1,8 @@ #!/usr/bin/env bash -mcstatus_cache="${HOME}/.cache/mcstatus.json" +cache_path="${HOME}/.cache/mcstatus" +mcstatus_cache="${cache_path}/mcstatus.json" +mkdir -p "${cache_path}" server_list=("mc.pogmom.me" "mc.pogmom.me") update_cache_json(){ @@ -8,10 +10,13 @@ update_cache_json(){ for s in "${server_list[@]}";do mcstatus "${s}" json | jq '. += {"address":"'"${s}"'"}' done | jq -n '[inputs]' | tee "${mcstatus_cache}" >/dev/null + jq -rc '.[] | "\(.address) \(.status.icon)"' ~/.cache/mcstatus.json | while read name icon;do + base64 --decode "${icon/*base64,/}" | tee "${cache_path}/${name}.png" + done } if [[ ! $(find "${mcstatus_cache}" -cmin -60 -print 2>/dev/null) ]]; then update_cache_json fi -cat "${mcstatus_cache}" +#cat "${mcstatus_cache}"