From fc52f05130fd33b21d0a5ae235945a9fc4439f7b Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Wed, 23 Mar 2022 22:39:32 +0100 Subject: [PATCH] t2ctl --- bin/t2ctl | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 bin/t2ctl diff --git a/bin/t2ctl b/bin/t2ctl new file mode 100755 index 0000000..519fa75 --- /dev/null +++ b/bin/t2ctl @@ -0,0 +1,77 @@ +#!/bin/bash +# t2ctl - basic tint2 panel config actions +# t2ctl variable value config_file +# + +# panel_position = vertical_position horizontal_position orientation +# panel_size = width height +# panel_shrink = boolean (0 or 1) +# panel_margin = horizontal_margin vertical_margin + +T2CONFFILE="${3}" +#T2CONFFILE="$HOME/.config/tint2/mabox2111.tint2rc" + +restartt2 () { +killall -SIGUSR1 tint2 +} + +pos () { + echo "$1" + sd "^panel_position.*$" "panel_position = ${1} center horizontal" ${T2CONFFILE} + restartt2 +} +width () { + read WIDTH HEIGHT <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)" + sd "^panel_size.*$" "panel_size = ${1} ${HEIGHT}" ${T2CONFFILE} + restartt2 +} + +height () { + read WIDTH HEIGHT <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)" + sd "^panel_size.*$" "panel_size = ${WIDTH} ${1}" ${T2CONFFILE} + restartt2 +} + +marginhor () { + read HOR VERT <<< "$(grep panel_margin ${T2CONFFILE} | cut -d'=' -f2)" + sd "^panel_margin.*$" "panel_margin = ${1} ${VERT}" ${T2CONFFILE} + restartt2 +} +marginver () { + read HOR VERT <<< "$(grep panel_margin ${T2CONFFILE} | cut -d'=' -f2)" + sd "^panel_margin.*$" "panel_margin = ${HOR} ${1}" ${T2CONFFILE} + restartt2 +} +paddinghor () { + read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)" + sd "^panel_padding.*$" "panel_padding = ${1} ${PVERT} ${SPACING}" ${T2CONFFILE} + restartt2 +} +paddingver () { + read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)" + sd "^panel_padding.*$" "panel_padding = ${PHOR} ${1} ${SPACING}" ${T2CONFFILE} + restartt2 +} +spacing () { + read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)" + sd "^panel_padding.*$" "panel_padding = ${PHOR} ${PVERT} ${1}" ${T2CONFFILE} + restartt2 +} +shrink () { + sd "^panel_shrink.*$" "panel_shrink = ${1}" ${T2CONFFILE} + restartt2 +} + + +case "$1" in + position) pos "$2";; + width) width "$2" ;; + height) height "$2" ;; + shrink) shrink "$2" ;; + marginh) marginhor "$2" ;; + marginv) marginver "$2" ;; + paddingh) paddinghor "$2" ;; + paddingv) paddingver "$2" ;; + spacing) spacing "$2" ;; + *) : ;; +esac