summaryrefslogtreecommitdiff
path: root/.local/bin/barpos
blob: 29e2512bfc8688a7ed8ab41587e2707339922477 (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/bash

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 -ir "s|^bottom = .*$|bottom = true|" $BAR_CFG
}

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

main "$@"