270 lines
8.6 KiB
Bash
Executable File
270 lines
8.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# t2ctl - basic tint2 panel config actions
|
|
# t2ctl variable value config_file
|
|
#
|
|
|
|
|
|
|
|
T2CONFFILE="${3}"
|
|
T2COLORFILE="$HOME/.config/tint2/*_mb.tint2rc"
|
|
#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
|
|
}
|
|
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}
|
|
}
|
|
|
|
height () {
|
|
read WIDTH HEIGHT <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "^panel_size.*$" "panel_size = ${WIDTH} ${1}" ${T2CONFFILE}
|
|
}
|
|
|
|
marginhor () {
|
|
read HOR VERT <<< "$(grep panel_margin ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "^panel_margin.*$" "panel_margin = ${1} ${VERT}" ${T2CONFFILE}
|
|
}
|
|
marginver () {
|
|
read HOR VERT <<< "$(grep panel_margin ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "^panel_margin.*$" "panel_margin = ${HOR} ${1}" ${T2CONFFILE}
|
|
}
|
|
paddinghor () {
|
|
read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "^panel_padding.*$" "panel_padding = ${1} ${PVERT} ${SPACING}" ${T2CONFFILE}
|
|
}
|
|
paddingver () {
|
|
read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "^panel_padding.*$" "panel_padding = ${PHOR} ${1} ${SPACING}" ${T2CONFFILE}
|
|
}
|
|
spacing () {
|
|
read PHOR PVERT SPACING <<< "$(grep panel_padding ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "^panel_padding.*$" "panel_padding = ${PHOR} ${PVERT} ${1}" ${T2CONFFILE}
|
|
}
|
|
shrink () {
|
|
sd "^panel_shrink.*$" "panel_shrink = ${1}" ${T2CONFFILE}
|
|
}
|
|
autohide () {
|
|
sd "^autohide .*$" "autohide = ${1}" ${T2CONFFILE}
|
|
sd "^panel_margin.*$" "panel_margin = 0 0" ${T2CONFFILE}
|
|
}
|
|
hideheight () {
|
|
sd "^autohide_height.*$" "autohide_height = ${1}" ${T2CONFFILE}
|
|
sd "^panel_margin.*$" "panel_margin = 0 0" ${T2CONFFILE}
|
|
sd "^autohide .*$" "autohide = 1" ${T2CONFFILE}
|
|
}
|
|
icontheme () {
|
|
sd "^launcher_icon_theme.*$" "launcher_icon_theme = ${1}" ${T2CONFFILE}
|
|
}
|
|
|
|
reset () {
|
|
case "$LANG" in
|
|
pl*) LNG=pl ;;
|
|
*) LNG=en ;;
|
|
esac
|
|
cp "/usr/share/mabox/lang/${LNG}/.config/tint2/${1}" "$HOME/.config/tint2/"
|
|
}
|
|
clockline1 () {
|
|
sd "^time1_format.*$" "time1_format = ${1}" ${T2CONFFILE}
|
|
}
|
|
clockline2 () {
|
|
if [[ "$1" == "none" ]];then
|
|
sd "^time2_format.*$" "time2_format =" ${T2CONFFILE}
|
|
else
|
|
sd "^time2_format.*$" "time2_format = ${1}" ${T2CONFFILE}
|
|
fi
|
|
}
|
|
tb_icon(){
|
|
sd "^task_icon .*$" "task_icon = 1" ${T2CONFFILE}
|
|
sd "^task_text.*$" "task_text = 0" ${T2CONFFILE}
|
|
read W H <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "^task_maximum_size.*$" "task_maximum_size = ${H} ${H}" ${T2CONFFILE}
|
|
}
|
|
tb_text(){
|
|
sd "^task_text.*$" "task_text = 1" ${T2CONFFILE}
|
|
sd "^task_icon .*$" "task_icon = 0" ${T2CONFFILE}
|
|
read TB_WIDTH TB_HEIGHT <<< "$(grep 'task_maximum_size' ${TINT} | cut -d'=' -f2)"
|
|
if [[ "$TB_WIDTH" < 100 ]];then
|
|
sd "^task_maximum_size.*$" "task_maximum_size = 100 100" ${T2CONFFILE}
|
|
fi
|
|
}
|
|
tb_both(){
|
|
sd "^task_icon .*$" "task_icon = 1" ${T2CONFFILE}
|
|
sd "^task_text.*$" "task_text = 1" ${T2CONFFILE}
|
|
read TB_WIDTH TB_HEIGHT <<< "$(grep 'task_maximum_size' ${TINT} | cut -d'=' -f2)"
|
|
if [[ "$TB_WIDTH" < 100 ]];then
|
|
sd "^task_maximum_size.*$" "task_maximum_size = 100 100" ${T2CONFFILE}
|
|
fi
|
|
}
|
|
tb_centered(){
|
|
sd "^task_centered.*$" "task_centered = ${1}" ${T2CONFFILE}
|
|
}
|
|
tb_width(){
|
|
case "$1" in
|
|
icon)
|
|
read W H <<< "$(grep panel_size ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "^task_maximum_size.*$" "task_maximum_size = ${H} ${H}" ${T2CONFFILE};;
|
|
*)sd "^task_maximum_size.*$" "task_maximum_size = ${1} ${1}" ${T2CONFFILE};;
|
|
esac
|
|
}
|
|
tb_tooltip_none(){
|
|
case "$1" in
|
|
1)
|
|
sd "^task_tooltip.*$" "task_tooltip = 0" ${T2CONFFILE}
|
|
sd "^task_thumbnail.*$" "task_thumbnail = 0" ${T2CONFFILE}
|
|
;;
|
|
0)
|
|
sd "^task_tooltip.*$" "task_tooltip = 1" ${T2CONFFILE}
|
|
sd "^task_thumbnail.*$" "task_thumbnail = 0" ${T2CONFFILE}
|
|
;;
|
|
esac
|
|
}
|
|
tb_tooltip(){
|
|
case "$1" in
|
|
1)
|
|
sd "^task_tooltip.*$" "task_tooltip = 1" ${T2CONFFILE}
|
|
sd "^task_thumbnail.*$" "task_thumbnail = 0" ${T2CONFFILE}
|
|
;;
|
|
0)
|
|
sd "^task_tooltip.*$" "task_tooltip = 0" ${T2CONFFILE}
|
|
sd "^task_thumbnail.*$" "task_thumbnail = 0" ${T2CONFFILE}
|
|
;;
|
|
esac
|
|
}
|
|
tb_thumbnail(){
|
|
case "$1" in
|
|
1)
|
|
sd "^task_thumbnail.*$" "task_thumbnail = 1" ${T2CONFFILE}
|
|
sd "^task_tooltip.*$" "task_tooltip = 1" ${T2CONFFILE}
|
|
;;
|
|
0)
|
|
sd "^task_thumbnail.*$" "task_thumbnail = 1" ${T2CONFFILE}
|
|
;;
|
|
esac
|
|
}
|
|
mleft(){
|
|
sd "^mouse_left.*$" "mouse_left = ${1}" ${T2CONFFILE}
|
|
}
|
|
mright(){
|
|
sd "^mouse_right.*$" "mouse_right = ${1}" ${T2CONFFILE}
|
|
}
|
|
mmiddle(){
|
|
sd "^mouse_middle.*$" "mouse_middle = ${1}" ${T2CONFFILE}
|
|
}
|
|
mup(){
|
|
sd "^mouse_scroll_up.*$" "mouse_scroll_up = ${1}" ${T2CONFFILE}
|
|
}
|
|
mdown(){
|
|
sd "^mouse_scroll_down.*$" "mouse_scroll_down = ${1}" ${T2CONFFILE}
|
|
}
|
|
mousereset(){
|
|
sd "^mouse_left.*$" "mouse_left = toggle_iconify" ${T2CONFFILE}
|
|
sd "^mouse_right.*$" "mouse_right = toggle" ${T2CONFFILE}
|
|
sd "^mouse_middle.*$" "mouse_middle = close" ${T2CONFFILE}
|
|
sd "^mouse_scroll_up.*$" "mouse_scroll_up = iconify" ${T2CONFFILE}
|
|
sd "^mouse_scroll_down.*$" "mouse_scroll_down = toggle_iconify" ${T2CONFFILE}
|
|
}
|
|
clock1_fontsize(){
|
|
read -a FL1 <<< "$(grep "time1_font" ${T2CONFFILE} | cut -d'=' -f2)"
|
|
L1_FONT="${FL1[@]::${#FL1[@]}-1}" # this is crazy... all array elements but last
|
|
sd "^time1_font.*$" "time1_font = ${L1_FONT} ${1}" ${T2CONFFILE}
|
|
}
|
|
clock2_fontsize(){
|
|
read -a FL2 <<< "$(grep "time2_font" ${T2CONFFILE} | cut -d'=' -f2)"
|
|
L2_FONT="${FL2[@]::${#FL2[@]}-1}" # this is crazy... all array elements but last
|
|
sd "^time2_font.*$" "time2_font = ${L2_FONT} ${1}" ${T2CONFFILE}
|
|
}
|
|
clockcolor(){
|
|
read CLR OPA <<< "$(grep "clock_font_color" ${T2CONFFILE} | cut -d'=' -f2)"
|
|
sd "clock_font_color.*$" "clock_font_color = ${1} $OPA" ${T2CONFFILE}
|
|
}
|
|
|
|
panel_background_id(){
|
|
sd "panel_background_id.*$" "panel_background_id = ${1}" ${T2COLORFILE}
|
|
}
|
|
|
|
button_background_id(){
|
|
sd "button_background_id.*$" "button_background_id = ${1}" ${T2COLORFILE}
|
|
sd "execp_background_id.*$" "execp_background_id = ${1}" ${T2COLORFILE}
|
|
}
|
|
task_background_id(){
|
|
sd "task_background_id.*$" "task_background_id = ${1}" ${T2COLORFILE}
|
|
}
|
|
systray_background_id(){
|
|
sd "systray_background_id.*$" "systray_background_id = ${1}" ${T2COLORFILE}
|
|
}
|
|
|
|
|
|
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";;
|
|
tb_icon)tb_icon "$2";;
|
|
tb_text)tb_text "$2";;
|
|
tb_both)tb_both "$2";;
|
|
tb_centered)tb_centered "$2";;
|
|
tb_width)tb_width "$2";;
|
|
tb_tooltip_none)tb_tooltip_none "$2";;
|
|
tb_tooltip)tb_tooltip "$2";;
|
|
tb_thumbnail)tb_thumbnail "$2";;
|
|
mleft)mleft "$2";;
|
|
mright)mright "$2";;
|
|
mmiddle)mmiddle "$2";;
|
|
mup)mup "$2";;
|
|
mdown)mdown "$2";;
|
|
mousereset)mousereset;;
|
|
reset) reset "$2" ;;
|
|
clock1_fontsize) clock1_fontsize "$2";;
|
|
clock2_fontsize) clock2_fontsize "$2";;
|
|
clockcolor) clockcolor "$2";;
|
|
panel_background_id)panel_background_id "$2";;
|
|
button_background_id)button_background_id "$2";;
|
|
task_background_id)task_background_id "$2";;
|
|
systray_background_id)systray_background_id "$2";;
|
|
|
|
*) : ;;
|
|
esac
|
|
restartt2
|