summaryrefslogtreecommitdiff
path: root/.local/bin/barpos
blob: d84709dbdc6e004d9e35e29d76e81b0f9adf4b79 (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
#!/bin/sh

BAR_CFG="$XDG_CONFIG_HOME/polybar/config.ini"

main () {
    if [ ! -n "$1" ]; then
        toggle ; exit 0
    fi

    case "$1" in
        t|top) 
            top ;;
        b|bottom) 
            bottom ;;
        *) 
            echo "usage: barpos [top|bottom]" ;;
    esac
}

toggle () {
    if grep -Eq "^bottom = true$" $BAR_CFG; then
        top
    else
        bottom
    fi
}

bottom () {
    sed -Ei "s|^bottom = .*$|bottom = true|" $BAR_CFG
}

top () {
    sed -Ei "s|^bottom = .*$|bottom = false|" $BAR_CFG
}

main "$@"