File: status.sh

package info (click to toggle)
xmobar 0.29.4-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,260 kB
  • sloc: haskell: 5,669; sh: 96; makefile: 49
file content (54 lines) | stat: -rwxr-xr-x 1,174 bytes parent folder | download | duplicates (5)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash

STATUSPIPE="/tmp/xmobar_status_jrk"

function isMuted () {
    # retrieve mute status
    # return an arbitrary string for true or nothing at all
    echo
}

function getPercent () {
    # somehow retrieve the percent value as plain int (e.g. "66")
    echo "66"
}

function percentBar () {
    local i=1                   res=
          normal=47             high=80
          fgColor='#657b83'     mutedColor='#cb4b16'
          lowColor='#859900'    midColor='#b58900'
          highColor='#cb4b16'

          bar="$(echo -ne "\u2588")"
          percent="$( getPercent )"
          muted="$( isMuted )"

    if [ -n "$muted" ]; then
        res="<fc=$mutedColor>"
    else
        res="<fc=$lowColor>"
    fi

    while [ $i -lt $percent ]; do
        if   [ $i -eq $normal -a -z "$muted" ]; then
            res+="</fc><fc=$midColor>"
        elif [ $i -eq $high   -a -z "$muted" ]; then
            res+="</fc><fc=$highColor>"
        fi

        res+=$bar
        i=$((i+1))
    done

    res+="</fc><fc=$fgColor>"

    while [ $i -lt 100 ]; do
        res+='-'
        i=$((i+1))
    done

    echo "$res</fc>"
}

echo "$( percentBar )" > "$STATUSPIPE"