summaryrefslogtreecommitdiff
path: root/herbstluftwm/popups.sh
blob: d1dde297bbb9d6c26ede28cc9fb9438297ad08f3 (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
#!/bin/bash

source ${HOME}/.config/herbstluftwm/fn.sh

dzen_bg="$(get_xresources foreground)"
dzen_fg="$(get_xresources background)"

calendary() {
    (
        cal
    ) | dzen2 -p -bg "${dzen_bg}" -fg "${dzen_fg}" -x "1195" -y "27" -w "165" -h "20" -l "5" -sa "c" -ta "c" \
        -title-name "popup_sysinfo" -e 'onstart=uncollapse;button1=exit;button3=exit'
}

position(){
    pos=$(mpc | awk 'NR==2' | awk '{print $4}' | sed 's/(//' | sed 's/%)//')
    bar=$(echo $pos | gdbar -w $1 -h 3.5 -fg "$(get_xresources color12)" -bg "$(get_xresources color8)")
    echo -n "$bar"
    return
}

music() {
    set -e

    popup_width=220
    padding=10

    while :
    do
    echo "^p(10)$(mpc current -f %artist%)
^p($padding)$(mpc current -f %title%) 
^p($padding)$(mpc current -f %album%)

^p($padding)^ca(1,mpc prev)Prev^ca()   ^ca(1,mpc toggle)Play/Pause^ca()   ^ca(1,mpc stop)Stop^ca()   ^ca(1,mpc next)Next^ca()
^p($padding)$(position $(($popup_width - $padding)) )" 2> /dev/null
    sleep 1
    done | dzen2 -p -bg "${dzen_bg}" -fg "${dzen_fg}" -y 27 -x 1087 -l 5 -u -w $(($popup_width + $padding)) -ta l -title-name "popup_mpd" -e 'onstart=uncollapse;button3=exit'
}

case $1 in
    cal)
        calendary
        ;;
    music)
        music
        ;;
    *)
        ;;
esac