summaryrefslogtreecommitdiff
path: root/.config/waybar/rat.sh
blob: 04cb579b6c0d3969332fe7cf3cb3adbbb999442f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash

SHARE=$HOME/.local/share/rat

return_json () {
    echo '{"text": "'"$1"'", "class": "'"$2"'"}'
}

get_time () {
    endtime=$(cat $SHARE/data)
    remaining=$(($endtime-$(date +%s)))
    timer=$(date -u -d @$remaining +%T)
    timer=${timer#00:}
    timer=${timer#0}
    return_json $timer ""
}

get_program () {
    name=$(cat $SHARE/data)
    return_json $name ""
}

status=$(cat $SHARE/status)

case $status in
    0) return_json caged "" ;;
    1) get_time ;;
    2) return_json waiting waiting ;;
    3) get_program ;;
    4) return_json working "" ;;
esac