mabox-pipemenus/usr/bin/jgdeskgrid

163 lines
6.5 KiB
Plaintext
Raw Normal View History

2021-05-21 23:15:53 +02:00
#!/bin/bash
2024-02-25 23:07:28 +01:00
# jgdeskgrid - configure SuperClick / DeskGrid from menu
2021-05-21 23:15:53 +02:00
#
2021-05-22 02:00:30 +02:00
case $LANG in
pl*)
REMOVE="Usuń to menu z panelu"
2024-02-25 23:07:28 +01:00
title="SuperClick - ustaw swoje okna na siatce"
2024-08-22 12:01:02 +02:00
help='\n<b>Super + LewyKlikMyszy</b> w odpowiednim miejscu okna - aby przemieścić je w wybranym kierunku.\n\n<i>Działa też z klawiatury...</i>\nUżyj <b>Super + Keypad_Keys</b> aby umieszczać okna na siatce\n\n\nnKonfigurowalne usatwienia:\n- odstęp\n- odstęp zewnętrzny'
2024-02-25 23:07:28 +01:00
ABOUT="O SuperClick"
2024-08-22 12:01:02 +02:00
TRAINER="Ćwicz z trenerem"
2024-02-25 23:07:28 +01:00
QUICK_TILE="Trener SuperClick"
2021-05-31 15:00:35 +02:00
CONFIGURATION="Konfiguracja"
LGAP="Odstęp"
OUTER_GAP="Zewnętrzny odstęp"
NOTIFY="Powiadomienia"
2024-08-22 12:01:02 +02:00
CFG_MENU="Menu konfiguracji"
2021-05-31 15:00:35 +02:00
EDITCONF="Edytuj plik konfiguracyjny"
2021-06-03 14:06:57 +02:00
LEFTPANEL="Lewy panel"
2021-05-22 02:00:30 +02:00
;;
es*)
REMOVE="Eliminar este menú del panel"
2024-02-25 23:07:28 +01:00
title="SuperClick - arrange your windows quickly"
2024-08-22 12:01:02 +02:00
help='\n\n<b>Super + LeftMouseClick</b> on appropriate area of the window to snap it in a given direction.\n\n<i>Works also with keyboard...</i>\nUse <b>Super + Keypad_Keys</b> to move windows on the grid\n\nConfigurable settings:\n- gap\n- show_outer_gap'
2024-02-25 23:07:28 +01:00
ABOUT="About SuperClick"
2024-08-22 12:01:02 +02:00
TRAINER="Practice with trainer"
2024-02-25 23:07:28 +01:00
QUICK_TILE="SuperClick trainer"
2021-06-01 02:01:25 +02:00
CONFIGURATION="Configuration"
LGAP="Gap between windows"
OUTER_GAP="Show outer gap"
NOTIFY="Notifications"
2024-08-22 12:01:02 +02:00
CFG_MENU="Config Menu"
2021-06-01 02:01:25 +02:00
EDITCONF="Edit config file"
2021-06-03 14:06:57 +02:00
LEFTPANEL="Left panel"
2021-05-22 02:00:30 +02:00
;;
*)
REMOVE="Remove this menu from panel"
2024-02-25 23:07:28 +01:00
title="SuperClick - arrange your windows quickly"
2024-08-22 12:01:02 +02:00
help='\n\n<b>Super + LeftMouseClick</b> on appropriate area of the window to snap it in a given direction.\n\n<i>Works also with keyboard...</i>\nUse <b>Super + Keypad_Keys</b> to move windows on the grid\n\nConfigurable settings:\n- gap\n- show_outer_gap'
2024-02-25 23:07:28 +01:00
ABOUT="About SuperClick"
2024-08-22 12:01:02 +02:00
TRAINER="Practice with trainer"
2024-02-25 23:07:28 +01:00
QUICK_TILE="SuperClick trainer"
2021-05-31 15:00:35 +02:00
CONFIGURATION="Configuration"
LGAP="Gap between windows"
OUTER_GAP="Show outer gap"
NOTIFY="Notifications"
2024-08-22 12:01:02 +02:00
CFG_MENU="Config Menu"
2021-05-31 15:00:35 +02:00
EDITCONF="Edit config file"
2021-06-03 14:06:57 +02:00
LEFTPANEL="Left panel"
2021-05-31 15:00:35 +02:00
;;
2021-05-22 02:00:30 +02:00
esac
2021-05-21 23:15:53 +02:00
2024-02-25 23:07:28 +01:00
CONFIG_FILE="$HOME/.config/superclick.cfg"
2021-05-21 23:15:53 +02:00
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Gap between windows in pixels (reasonable values: 0 8 16 24)
gap=16
# Outer gap (disable if you use WM margins)
show_outer_gap=true
2024-08-22 12:01:02 +02:00
# Only for mouse action
2021-05-21 23:15:53 +02:00
activate_window=false
EOF
fi
source <(grep = $CONFIG_FILE)
GAP=${gap:-16}
2021-06-01 02:01:25 +02:00
me="jgdeskgrid -s"
2021-05-31 15:00:35 +02:00
2024-08-22 12:01:02 +02:00
#out+=("^sep(SuperClick)")
out+=("<big>󱇙</big> $ABOUT,notify-send.sh -u critical -i mbcc '$title' '$help' -o '$TRAINER:superclick trainer' -o '$CFG_MENU:jgdeskgrid -s' -o '$EDITCONF:xdg-open $CONFIG_FILE'")
2024-02-25 23:07:28 +01:00
out+=("<big>󰋁</big> $QUICK_TILE,superclick trainer")
2024-08-22 12:01:02 +02:00
#out+=("<big>󰕰</big> $SHOW_IMGHELPER,drawgrid")
2021-05-31 15:00:35 +02:00
out+=("^sep($CONFIGURATION)")
2023-05-19 00:17:14 +02:00
2021-05-31 15:00:35 +02:00
out+=("$LGAP [ <b>$GAP</b> ],^checkout(gap)")
2023-05-19 00:17:14 +02:00
[[ "$show_outer_gap" == "true" ]] && out+=("<big></big> $OUTER_GAP,mb-setvar show_outer_gap=false $CONFIG_FILE;$me") || out+=("<big></big> $OUTER_GAP,mb-setvar show_outer_gap=true $CONFIG_FILE;$me")
2024-08-22 12:01:02 +02:00
#[[ "$notifications" == "true" ]] && out+=("<big></big> $NOTIFY,mb-setvar notifications=false $CONFIG_FILE;$me") || out+=("<big></big> $NOTIFY,mb-setvar notifications=true $CONFIG_FILE;$me")
2023-05-19 00:17:14 +02:00
2021-05-21 23:15:53 +02:00
out+=("^sep()")
2023-05-19 00:17:14 +02:00
out+=("<big></big> $EDITCONF,xdg-open $CONFIG_FILE")
2021-05-21 23:15:53 +02:00
2021-05-22 02:00:30 +02:00
out2+=("^tag(gap)")
2022-02-13 00:02:42 +01:00
for i in 0 4 8 10 16 20 24 32 40; do out2+=("$(printf "<tt>%3s</tt>,%s" "$i" "mb-setvar gap=${i} $CONFIG_FILE;$me")");done
2021-05-21 23:15:53 +02:00
### RUN
if [[ "$1" == "-s" ]]; then
2021-09-24 01:40:09 +02:00
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
2021-06-01 02:01:25 +02:00
. $HOME/.config/mabox/mabox.conf
2021-06-03 14:06:57 +02:00
out+=("^sep()")
2024-02-25 23:07:28 +01:00
out+=("  $LEFTPANEL,mb-jgtools places")
2021-06-03 14:06:57 +02:00
if [[ $panels_heightpos == "top" ]]; then
MENU_VALIGN="top"
MENU_MARGIN_Y=${panels_topmargin:-0}
elif [[ $panels_heightpos == "bottom" ]]; then
MENU_VALIGN="bottom"
MENU_MARGIN_Y=${panels_topmargin:-0}
else
MENU_VALIGN="center"
fi
2021-06-01 02:01:25 +02:00
MENU_PADDING_TOP=${jgtools_padding:-0}
MENU_HALIGN="left"
2021-05-21 23:15:53 +02:00
jgmenu_icon_size=0
2021-06-01 02:01:25 +02:00
JGWIDTH=40
menu_margin_x=${submenu_spacing:-0}
2021-05-21 23:15:53 +02:00
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
2024-08-22 12:01:02 +02:00
JGWIDTH=$((jgtools_padding + 270 + jgtools_padding))
MENU_PADDING_TOP=$((jgtools_padding + 152))
read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | tail -1 | cut -d'=' -f2)
THUMBDIR="$HOME/.cache/colorizer/thumbs"
mkdir -p ${THUMBDIR}
NAME=${WALLPATH////_}
if [[ "${NAME}" =~ ^_home_.* ]]; then
n=${#HOME}
((n++))
NAME=${NAME:${n}}
fi
THUMB="${THUMBDIR}/${NAME}.png"
if [[ ! -f "$THUMB" ]]
then
convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB}
fi
2021-05-21 23:15:53 +02:00
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
2024-08-22 12:01:02 +02:00
@icon,,$((jgtools_padding)),$((jgtools_padding)),270,150,4,left,top,,,${THUMB}
@rect,,$((jgtools_padding + 2)),$((jgtools_padding + 2)),86,46,0,left,top,#FFFFFF 20,#222222 30,
@rect,,$((jgtools_padding + 92)),$((jgtools_padding + 2)),86,46,0,left,top,#FFFFFF 20,#222222 30,
@rect,,$((jgtools_padding + 182)),$((jgtools_padding + 2)),86,46,0,left,top,#FFFFFF 60,#FFFFFF 40,
@text,,$((jgtools_padding + 222)),$((jgtools_padding + 2)),86,46,0,left,top,#FFFFFF 100,#FFFFFF 30,<span size='20800' font_family='Ubuntu'><big></big></span>
@rect,,$((jgtools_padding + 2)),$((jgtools_padding + 52)),86,46,0,left,top,#FFFFFF 20,#222222 30,
#@rect,,$((jgtools_padding + 92)),$((jgtools_padding + 52)),86,46,0,left,top,#FFFFFF 20,#222222 30,
@rect,,$((jgtools_padding + 182)),$((jgtools_padding + 52)),86,46,0,left,top,#FFFFFF 20,#222222 30,
@rect,,$((jgtools_padding + 2)),$((jgtools_padding + 102)),86,46,0,left,top,#FFFFFF 20,#222222 30,
@rect,,$((jgtools_padding + 92)),$((jgtools_padding + 102)),86,46,0,left,top,#FFFFFF 20,#222222 30,
@rect,,$((jgtools_padding + 182)),$((jgtools_padding + 102)),86,46,0,left,top,#FFFFFF 20,#222222 30,
@rect,,$((jgtools_padding + 135)),$((jgtools_padding + 122)),135,22,0,left,top,#222222 20,#222222 70,
@text,,$((jgtools_padding + 168)),$((jgtools_padding + 118)),130,30,0,left,top,#EEEEEE,${WINCLR},<span size='10400' font_family='Ubuntu'><b>SuperClick</b></span>
2021-05-21 23:15:53 +02:00
$(printf '%s\n' "${out[@]}")
$(printf '%s\n' "${out2[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
printf '%s\n' "${out[@]}"
if [[ $1 == "-r" ]]; then
printf '%s\n' "^sep()"
2021-05-23 10:20:13 +02:00
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_jgdeskgrid=false;mb-jgtools places"
2021-05-21 23:15:53 +02:00
fi
printf '%s\n' "${out2[@]}"