#!/bin/sh BAR_CFG="$XDG_CONFIG_HOME/polybar/config.ini" main () { if [ -z "$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 "$@"