summaryrefslogtreecommitdiff
path: root/bin/.bin/lemonconf
blob: cb5e505939d8979d294b25a9c232ea860da9f516 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Outputs a configuration for lemonbar

vol(){
    vol=$(pulsemixer --get-volume | awk '{print $1}')
    mute=$(pulsemixer --get-mute)
    if [ "$mute" == 1 ]; then
        echo -e "%{F#787878}vol%{F-} muted "
    elif [ "$mute" == 0 ]; then
	    echo -e "%{F#787878}vol%{F-} $vol% "
    fi
}

bat() {
	power=$(cat /sys/class/power_supply/BAT0/capacity)
    status=$(cat /sys/class/power_supply/BAT0/status)
    if [ "$status" == "Charging" ]; then
        echo -e "%{F#787878}bat%{F-} +$power% "
    elif [ "$status" == "Discharging" ]; then
        echo -e "%{F#787878}bat%{F-} $power% "
    fi
}

dte() {
  dte=$(date +"%a, %b %d")
  echo -e "%{F#787878}date%{F-} $dte "
}

tie() {
  tme=$(date +"%I:%M %P")
  echo -e "%{F#787878}time%{F-} $tme "
}

groups() {
    cur=`xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}'`
    tot=`xprop -root _NET_NUMBER_OF_DESKTOPS | awk '{print $3}'`

    for w in `seq 0 $((cur - 1))`; do line="${line}  "; done
    line="${line}  "
    for w in `seq $((cur + 2)) $tot`; do line="${line}  "; done
    echo $line
}

workspaces() {
    all=$(bspc query -D)
    occupied=$(bspc query -D -d .occupied)
    current=$(bspc query -D -d .focused)
    result=""
    padding=" "
    while IFS= read -r line; do
        # Get the name of the current desktop
        name=""
        if [[ "$occupied" == *"$line"* ]];
        then
            name=""
        fi
        
        if [[ "$current" == *"$line"* ]];
        then
            name=""
        fi
        
        result="$result$padding"
        result="$result$name"
        result="$result$padding"
    done <<< "$all"
    echo -e "$result"
}

while true; do
    echo "    $(vol)  $(bat)  $(tie)  $(dte)  %{F#787878}%{r}$(workspaces)%{F-}    "
    xdo above -t $(xdo id -n root) $(xdo id -n lemonbar)
	sleep 3
done