#!/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 () { case "$1" in tch) sd "^panel_position.*$" "panel_position = top center horizontal" ${T2CONFFILE};; bch) sd "^panel_position.*$" "panel_position = bottom center horizontal" ${T2CONFFILE};; tlh) sd "^panel_position.*$" "panel_position = top left horizontal" ${T2CONFFILE};; trh) sd "^panel_position.*$" "panel_position = top right horizontal" ${T2CONFFILE};; blh) sd "^panel_position.*$" "panel_position = bottom left horizontal" ${T2CONFFILE};; brh) sd "^panel_position.*$" "panel_position = bottom right horizontal" ${T2CONFFILE};; clv) sd "^panel_position.*$" "panel_position = center left vertical" ${T2CONFFILE};; crv) sd "^panel_position.*$" "panel_position = center right vertical" ${T2CONFFILE};; tlv) sd "^panel_position.*$" "panel_position = top left vertical" ${T2CONFFILE};; trv) sd "^panel_position.*$" "panel_position = top right vertical" ${T2CONFFILE};; blv) sd "^panel_position.*$" "panel_position = bottom left vertical" ${T2CONFFILE};; brv) sd "^panel_position.*$" "panel_position = bottom right vertical" ${T2CONFFILE};; esac restartt2 } width () { read WIDTH HEIGHT <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)" sd "^panel_size.*$" "panel_size = ${1} ${HEIGHT}" ${T2CONFFILE} sd "^panel_shrink.*$" "panel_shrink = 0" ${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 } autohide () { sd "^autohide .*$" "autohide = ${1}" ${T2CONFFILE} sd "^panel_margin.*$" "panel_margin = 0 0" ${T2CONFFILE} restartt2 } hideheight () { sd "^autohide_height.*$" "autohide_height = ${1}" ${T2CONFFILE} sd "^panel_margin.*$" "panel_margin = 0 0" ${T2CONFFILE} sd "^autohide .*$" "autohide = 1" ${T2CONFFILE} restartt2 } icontheme () { sd "^launcher_icon_theme.*$" "launcher_icon_theme = ${1}" ${T2CONFFILE} restartt2 } reset () { case "$LANG" in pl*) LNG=pl ;; *) LNG=en ;; esac cp "/usr/share/mabox/lang/${LNG}/.config/tint2/${1}" "$HOME/.config/tint2/" restartt2 } clockline1 () { sd "^time1_format.*$" "time1_format = ${1}" ${T2CONFFILE} restartt2 } clockline2 () { if [[ "$1" == "none" ]];then sd "^time2_format.*$" "time2_format =" ${T2CONFFILE} else sd "^time2_format.*$" "time2_format = ${1}" ${T2CONFFILE} fi 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" ;; autohide) autohide "$2" ;; hideheight) hideheight "$2" ;; icontheme) icontheme "$2" ;; clockline1) clockline1 "$2";; clockline2) clockline2 "$2";; reset) reset "$2" ;; *) : ;; esac