tint2 quickactions

master
Daniel Napora 2022-03-23 22:40:13 +01:00
parent a4c1235b0f
commit af8ad52321
1 changed files with 108 additions and 25 deletions

View File

@ -1,5 +1,6 @@
#!/bin/bash
#TODO Handle more than one tint
#TODO Reset to defaults
TINT2PATH="$HOME/.config/tint2"
TINT2RC="$TINT2PATH/tint2rc"
@ -16,7 +17,7 @@ case $LANG in
APPS="Programy (Launcher)"
LAUNCHERS="Dodaj/usuń programy..."
TINT2_EDITOR="Wybierz pliki Tint2 do edycji..."
TINT2_CONFIGURE="Konfiguracja"
TINT2_CONFIGURE="Konfiguracja panelu tint2"
CHOOSE_TINT2="Wybierz Tint2..."
RESTART_TINT2="Restartuj Tint2"
RELOAD_TINT2="Przeładuj Tint2"
@ -48,7 +49,7 @@ case $LANG in
APPS="Launchers"
LAUNCHERS="Add/Remove Launchers..."
TINT2_EDITOR="Choose Tint2 to edit"
TINT2_CONFIGURE="Configure"
TINT2_CONFIGURE="Configure tint2 panel"
CHOOSE_TINT2="Choose Tint2..."
RESTART_TINT2="Restart Tint2"
RELOAD_TINT2="Reload Tint2"
@ -57,10 +58,108 @@ case $LANG in
TRAY_HWMON="Systray HW monitor"
;;
esac
getvalues () {
read POS REST <<< "$(grep panel_position ${TINT} | cut -d'=' -f2)"
read W H <<< "$(grep panel_size ${TINT} | cut -d'=' -f2)"
read HOR VERT <<< "$(grep panel_margin ${TINT} | cut -d'=' -f2)"
read PHOR PVERT SPACING <<< "$(grep panel_padding ${TINT} | cut -d'=' -f2)"
read SHRINK <<< "$(grep panel_shrink ${TINT} | cut -d'=' -f2)"
}
qactions () {
out+=("<tt>$(printf "%-20s %20s" "POSITION" "[ <b>$POS</b> ]")</tt>,^checkout(ppos$i)")
out+=("<tt>$(printf "%-20s %20s" "WIDTH" "[ <b>$W</b> ]")</tt>,^checkout(pwidth$i)")
out+=("<tt>$(printf "%-20s %20s" "HEIGHT" "[ <b>$H</b> ]")</tt>,^checkout(pheight$i)")
out+=("<tt>$(printf "%-20s %20s" "MARGIN" "[ <b>$HOR $VERT</b> ]")</tt>,^checkout(pmargin$i)")
out+=("<tt>$(printf "%-20s %20s" "PADDING" "[ <b>$PHOR $PVERT $SPACING</b> ]")</tt>,^checkout(ppadding$i)")
out+=("<tt>$(printf "%-20s %20s" "COMPACT" "[ <b>$SHRINK</b> ]")</tt>,^checkout(pcompact$i)")
out+=("^sep()")
out+=("RESET")
out+=("^sep()")
out2+=("^tag(ppos$i)")
out2+=("^sep(POSITION)")
out2+=("TOP,t2ctl position top ${TINT};$me")
out2+=("BOTTOM,t2ctl position bottom ${TINT};$me")
out2+=("^tag(pwidth$i)")
out2+=("^sep(WIDTH)")
out2+=("100%,t2ctl width 100% ${TINT};$me")
out2+=("95%,t2ctl width 95% ${TINT};$me")
out2+=("90%,t2ctl width 90% ${TINT};$me")
out2+=("80%,t2ctl width 80% ${TINT};$me")
out2+=("75%,t2ctl width 75% ${TINT};$me")
out2+=("60%,t2ctl width 60% ${TINT};$me")
out2+=("")
out2+=("^tag(pheight$i)")
out2+=("^sep(HEIGHT)")
out2+=("24,t2ctl height 24 ${TINT};$me")
out2+=("28,t2ctl height 28 ${TINT};$me")
out2+=("32,t2ctl height 32 ${TINT};$me")
out2+=("40,t2ctl height 40 ${TINT};$me")
out2+=("^tag(pmargin$i)")
out2+=("^sep(HORIZONTAL)")
out2+=("0,t2ctl marginh 0 ${TINT};$me")
out2+=("1,t2ctl marginh 1 ${TINT};$me")
out2+=("2,t2ctl marginh 2 ${TINT};$me")
out2+=("4,t2ctl marginh 4 ${TINT};$me")
out2+=("")
out2+=("^sep(VERTICAL$i)")
out2+=("0,t2ctl marginv 0 ${TINT};$me")
out2+=("1,t2ctl marginv 1 ${TINT};$me")
out2+=("2,t2ctl marginv 2 ${TINT};$me")
out2+=("4,t2ctl marginv 4 ${TINT};$me")
out2+=("^tag(ppadding$i)")
out2+=("^sep(HORIZONTAL)")
out2+=("0,t2ctl paddingh 0 ${TINT};$me")
out2+=("1,t2ctl paddingh 1 ${TINT};$me")
out2+=("2,t2ctl paddingh 2 ${TINT};$me")
out2+=("4,t2ctl paddingh 4 ${TINT};$me")
out2+=("")
out2+=("^sep(VERTICAL)")
out2+=("0,t2ctl paddingv 0 ${TINT};$me")
out2+=("1,t2ctl paddingv 1 ${TINT};$me")
out2+=("2,t2ctl paddingv 2 ${TINT};$me")
out2+=("4,t2ctl paddingv 4 ${TINT};$me")
out2+=("^sep(SPACING)")
out2+=("0,t2ctl spacing 0 ${TINT};$me")
out2+=("1,t2ctl spacing 1 ${TINT};$me")
out2+=("2,t2ctl spacing 2 ${TINT};$me")
out2+=("4,t2ctl spacing 4 ${TINT};$me")
out2+=("^tag(pcompact$i)")
out2+=("^sep(COMPACT)")
out2+=("no (0),t2ctl shrink 0 ${TINT};$me")
out2+=("yes (1),t2ctl shrink 1 ${TINT};$me")
}
if [ "$(pidof tint2)" ];then
i=0
out+=("^sep($TINT2_CONFIGURE)")
while read -r pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
TINT=${cmd##* }
TINT2=${TINT#$HOME/.config/tint2/}
if [[ $TINT = tint2 ]];then
TINT="$TINT2RC"
TINT2="$DEFAULT_TINT2RC"
fi
((i=i+1))
getvalues
qactions
out+=("$CONFIGURE <i>$TINT2</i>,tint2conf $TINT")
out+=("$EDIT_TINT2 <i>$TINT2</i>,geany $TINT")
fi
done < <(pgrep -a tint2)
fi
out+=("^sep($APPS)")
out+=("$LAUNCHERS,jgtint2launcher")
if command -v phwmon.py &>/dev/null; then
PHWRUN="mabox-obstart phwmon"
@ -78,33 +177,16 @@ PHWRUN="mabox-obstart phwmon"
[[ $phwmon_swap = false ]] && out+=("<i><s>Swap</s></i>,mb-setvar phwmon_swap=true;$PHWRUN;$me") || out+=("Swap,mb-setvar phwmon_swap=false;$PHWRUN;$me")
[[ $phwmon_net = false ]] && out+=("<i><s>Network usage</s></i>,mb-setvar phwmon_net=true;$PHWRUN;$me") || out+=("Network usage,mb-setvar phwmon_net=false;$PHWRUN;$me")
[[ $phwmon_io = false ]] && out+=("<i><s>Disk IO</s></i>,mb-setvar phwmon_io=true;$PHWRUN;$me") || out+=("Disk IO,mb-setvar phwmon_io=false;$PHWRUN;$me")
if [ "$(pidof tint2)" ];then
out+=("^sep($TINT2_CONFIGURE)")
while read -r pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
TINT=${cmd##* }
TINT2=${TINT#$HOME/.config/tint2/}
if [[ $TINT = tint2 ]];then
TINT="$TINT2RC"
TINT2="$DEFAULT_TINT2RC"
fi
out+=("$CONFIGURE <i>$TINT2</i>,tint2conf $TINT")
out+=("$EDIT_TINT2 <i>$TINT2</i>,geany $TINT")
fi
done < <(pgrep -a tint2)
fi
#out+=("^sep($EDIT_TINT2)")
# out+=("^sep()")
out+=("^sep($TITLE)")
out+=("$CHOOSE_TINT2,$TZEN")
out+=("$RESTART_TINT2,mb-tint2restart")
out+=("$RELOAD_TINT2,killall -SIGUSR1 tint2")
#out+=("^sep($EDIT_TINT2)")
# out+=("^sep()")
fi
if [ $1 == "-s" ]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
@ -141,8 +223,9 @@ exit 0
fi
printf '%s\n' "${out[@]}"
printf '%s\n' "${out2[@]}"
if [ $1 == "-r" ]; then
if [ "$1" == "-r" ]; then
printf '%s\n' "^sep()"
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_tint2pipe=false;mb-jgtools places"
fi