#!/bin/bash
# jgdeskgrid - configure DeskGrid from menu
#
case $LANG in
pl*)
REMOVE="Usuń to menu z panelu"
title="DesktopGrid - ustaw swoje okna na siatce"
help='\n\nUżyj Ctrl+Shift+Keypad_Keys aby umieszczać okna na siatce\nCtrl+Shift+LeftMouseClick w odpowiednim miejscu okna - aby przemieścić je w wybranym kierunku.\nZobacz: filmik na YT\n\nJeśli potrzebujesz większej kontroli nad pozycją i rozmiarem okien na siatce - użyj super + LeftMouseClick na wybranym oknie a następnie zaznacz prostokąt na ekranie - aby umieścić okno w danej pozycji.\nZobacz: filmik na YT\n\nKonfigurowalne usatwienia:\n- odstęp\n- odstęp zewnętrzny'
ABOUT="O DesktopGrid"
SHOW_IMGHELPER="Pokaż siatkę na pulpicie"
QUICK_TILE="Trener szybkiego tilingu"
CONFIGURATION="Konfiguracja"
LCOLUMNS="Kolumny"
LROWS="Wiersze"
LGAP="Odstęp"
OUTER_GAP="Zewnętrzny odstęp"
NOTIFY="Powiadomienia"
EDITCONF="Edytuj plik konfiguracyjny"
LEFTPANEL="Lewy panel"
;;
es*)
REMOVE="Eliminar este menú del panel"
title="DesktopGrid - arrange your windows on the grid"
help='\n\nUse Ctrl+Shift+Keypad_Keys to move windows on the grid\nCtrl+Shift+LeftMouseClick on appropriate area of the window to snap it in a given direction.\nSee: video on YT\n\n If you need even more control of windows size and position on the grid - use super + LeftMouseClick on window and then draw rectangle on the screen to select new window size and position.\nSee: deskgrid preview on YT\n\nConfigurable settings:\n- gap\n- show_outer_gap'
ABOUT="About DesktopGrid"
SHOW_IMGHELPER="Show image helper"
QUICK_TILE="Quick tiling trainer"
CONFIGURATION="Configuration"
LCOLUMNS="Columns"
LROWS="Rows"
LGAP="Gap between windows"
OUTER_GAP="Show outer gap"
NOTIFY="Notifications"
EDITCONF="Edit config file"
LEFTPANEL="Left panel"
;;
*)
REMOVE="Remove this menu from panel"
title="DesktopGrid - arrange your windows on the grid"
help='\n\nUse Ctrl+Shift+Keypad_Keys to move windows on the grid\nCtrl+Shift+LeftMouseClick on appropriate area of the window to snap it in a given direction.\nSee: video on YT\n\n If you need even more control of windows size and position on the grid - use super + LeftMouseClick on window and then draw rectangle on the screen to select new window size and position.\nSee: deskgrid preview on YT\n\nConfigurable settings:\n- gap\n- show_outer_gap'
ABOUT="About DesktopGrid"
SHOW_IMGHELPER="Show image helper"
QUICK_TILE="Quick tiling trainer"
CONFIGURATION="Configuration"
LCOLUMNS="Columns"
LROWS="Rows"
LGAP="Gap between windows"
OUTER_GAP="Show outer gap"
NOTIFY="Notifications"
EDITCONF="Edit config file"
LEFTPANEL="Left panel"
;;
esac
CONFIG_DIR="$HOME/.config/deskgrid"
CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg"
mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then
cat < ${CONFIG_FILE}
# Gap between windows in pixels (reasonable values: 0 8 16 24)
gap=16
# Grid columns (12 16 24)
columns=12
# Grid rows (6 12 16)
rows=12
#Notifications true or false
notifications=true
# Outer gap (disable if you use WM margins)
show_outer_gap=true
# Only for clicksnap action
activate_window=false
EOF
fi
source <(grep = $CONFIG_FILE)
GAP=${gap:-16}
COL=${columns:-12}
ROWS=${rows:-12}
me="jgdeskgrid -s"
out+=("^sep(DesktopGrid)")
out+=(" $ABOUT,notify-send.sh -u critical -i mbcc '$title' '$help' -o '$SHOW_IMGHELPER:drawgrid' -o '$EDITCONF:xdg-open ~/.config/deskgrid/deskgrid.cfg'")
out+=(" $SHOW_IMGHELPER,drawgrid")
out+=(" $QUICK_TILE,yhtml /usr/share/mabox/help/Quick_tiling.html 'Mabox Quick tiling trainer - Ctrl + Shift + click'")
out+=("^sep($CONFIGURATION)")
out+=("$LGAP [ $GAP ],^checkout(gap)")
[[ "$show_outer_gap" == "true" ]] && out+=(" $OUTER_GAP,mb-setvar show_outer_gap=false $CONFIG_FILE;$me") || out+=(" $OUTER_GAP,mb-setvar show_outer_gap=true $CONFIG_FILE;$me")
[[ "$notifications" == "true" ]] && out+=(" $NOTIFY,mb-setvar notifications=false $CONFIG_FILE;$me") || out+=(" $NOTIFY,mb-setvar notifications=true $CONFIG_FILE;$me")
out+=("^sep()")
out+=(" $EDITCONF,xdg-open $CONFIG_FILE")
out2+=("^tag(gap)")
for i in 0 4 8 10 16 20 24 32 40; do out2+=("$(printf "%3s,%s" "$i" "mb-setvar gap=${i} $CONFIG_FILE;$me")");done
### RUN
if [[ "$1" == "-s" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
out+=("^sep()")
out+=(" ⮜ $LEFTPANEL,mb-jgtools places")
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
MENU_PADDING_TOP=${jgtools_padding:-0}
MENU_HALIGN="left"
jgmenu_icon_size=0
JGWIDTH=40
menu_margin_x=${submenu_spacing:-0}
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
cat < ${MENU_ITEMS}
$(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()"
printf '%s\n' "$REMOVE,mb-setvar places_jgdeskgrid=false;mb-jgtools places"
fi
printf '%s\n' "${out2[@]}"