guest@dotshare [~/groups/info/dzen2] $ ls veggiebar/ | cat

veggiebar (scrot, raw, dl) (+2 likes)

poony Nov 08, 2014 (info/dzen2)

SCROT

 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
#!/bin/bash
pkill -f "dzen2 -p -title-name status_bar"
length=1366
height=10
font="-lucy-tewi2a-medium-r-normal--11-90-75-75-p-58-iso10646-1"

bg=#0a0a0a
fg=$(cat ~/.Xdefaults |grep -i color7 |tail -c 8)
fg2=$(cat ~/.Xdefaults |grep -i color8 |tail -c 8)
red=$(cat ~/.Xdefaults |grep -i color9 |tail -c 8)
darkred=$(cat ~/.Xdefaults |grep -i color1: |tail -c 8)
yellow=$(cat ~/.Xdefaults |grep -i color3 |tail -c 8)
blue=$(cat ~/.Xdefaults |grep -i color6 |tail -c 8)
green=$(cat ~/.Xdefaults |grep -i color10 |tail -c 8)
magenta=$(cat ~/.Xdefaults |grep -i color13 |tail -c 8)
black=$(cat ~/.Xdefaults |grep -i color8 |tail -c 8)

load() {
    mem=$(free -m|awk 'NR==3 {print $3}')
    cpu=$(bc <<< $(ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'))
    echo -ne "^p(_RIGHT)^p(-310)^fg($blue)⭦ ^fg($fg)$mem^fg($yellow)   ⭥ ^fg($fg)$cpu\r"
}

clock() {
    timea=$(date +'%l:%M %p')
    timeb=$(date +'%a %_d')
    echo "^p(_RIGHT)^p(-113)^fg($magenta)⭧ ^fg($fg)$timea ^fg($fg2)$timeb"

}

music() {
    songa=$(mpc current -f "%artist%")
    songb=$(mpc current -f "%title%")
    if [[ -z $songb ]]; then
        songb=$(mpc current -f "%file%"|cut -d "/" -f2|sed 's/.mp3$//')
    fi
    if [[ -z $(mpc current)  ]]; then
        songa=""; songb=""
    fi
    if [[ $(mpc | sed -n 's/^.*m:\so\(\w\).*$/\1/p') = "f" ]]; then
        muscolor=$black
    else
        muscolor=$darkred
    fi
    echo -ne "^p(_LEFT)^fg($muscolor)⭯ ^fg($fg)$songa ^fg($fg2)$songb\r"
}

volume() {
    sound=$(amixer get Master | sed -n 's/.*\[\([a-z]\+\)\]$/\1/p')
    vol=$(echo "`amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p'`/10" | bc)
    on=$(eval printf %${vol}s | sed 's/\s/☷/g')
    off=$(eval printf %$(echo "10 - $vol" | bc)s | sed 's/\s/☷/g')
    if [ "$sound" = "off" ]; then
        echo -ne "^p(_RIGHT)^p(-210)^fg($green)◂⋑ ^fg($darkred)$on^fg($black)$off\r"
    else
        echo -ne "^p(_RIGHT)^p(-210)^fg($green)◂⋑ ^fg($fg)$on^fg($black)$off\r"
    fi
}

while true; do
    volume
    music
    load
    clock
    sleep 1
done |
dzen2 -p -title-name status_bar -fn $font -bg $bg -ta l -geometry ${length}x$height+0+0 -e \
    'button1=exec:urxvt -title todo -name todo -geometry 45x25+$((768 / 2 + 150))+60 -e \
    vim $HOME/todo.patch;button3=exec:kill $(pgrep -n vim)' & disown

CLICK TO VIEW

x

Notes

A simple status bar for dzen2, using the colors found in .Xdefaults

[ * ] Icons are from the font tewi (https://github.com/lucy/tewi-font)
[ * ] Volume bars turn red when muted
[ * ] Music icon lights up while random mode is on in MPD
[ * ] Opens a Todo list in vim when the statusbar is clicked (set to ~/todo.patch) and closes it when right clicked

Comments

aimL0W said about 2 years ago

Great!!