dotfiles/bin/polybar/aw_afk.sh

16 lines
631 B
Bash
Executable file

#!/usr/bin/env bash
# [[file:../../Desktop.org::*aw-afk][aw-afk:1]]
afk_event=$(curl -s -X GET "http://localhost:5600/api/0/buckets/aw-watcher-afk_$(hostname)/events?limit=1" -H "accept: application/json")
status=$(echo ${afk_event} | jq -r '.[0].data.status')
afk_time=$(echo "${afk_event}" | jq -r '.[0].duration' | xargs -I ! date -u -d @! +"%H:%M")
uptime=$(date -ud @$(uptime -r | awk '{print $2}') +%H:%M)
res="${afk_time} / ${uptime}"
if [[ $status == 'afk' ]]; then
# echo "%{u#cc3333}%{+u} [AFK] $res %{u-}"
echo "[AFK] $res"
else
# echo "%{u#375cd8}%{+u} $res %{u-}"
echo "$res"
fi
# aw-afk:1 ends here