mabox-pipemenus/usr/bin/jgdeskgrid

151 lines
6.3 KiB
Plaintext
Raw Normal View History

2021-05-21 23:15:53 +02:00
#!/bin/bash
# jgdeskgrid - configure DeskGrid from menu
#
2021-05-22 02:00:30 +02:00
case $LANG in
pl*)
REMOVE="Usuń to menu z panelu"
2021-05-31 15:00:35 +02:00
title="DesktopGrid - ustaw swoje okna na siatce"
2022-02-15 22:11:33 +01:00
help='\n\nUżyj <b>Ctrl+Shift+Keypad_Keys</b> aby umieszczać okna na siatce\n<b>Ctrl+Shift+LeftMouseClick</b> w odpowiednim miejscu okna - aby przemieścić je w wybranym kierunku.\nZobacz: <a href="https://youtu.be/UzgUYYXnRww">filmik na YT</a>\n\nJeśli potrzebujesz większej kontroli nad pozycją i rozmiarem okien na siatce - użyj <b>super + LeftMouseClick</b> na wybranym oknie a następnie zaznacz prostokąt na ekranie - aby umieścić okno w danej pozycji.\nZobacz: <a href="https://youtu.be/Ba_lV-M0I2o">filmik na YT</a>\n\nKonfigurowalne usatwienia:\n- odstęp\n- odstęp zewnętrzny'
2021-05-31 15:00:35 +02:00
ABOUT="O DesktopGrid"
2021-06-01 14:17:48 +02:00
SHOW_IMGHELPER="Pokaż siatkę na pulpicie"
2022-02-24 03:03:33 +01:00
QUICK_TILE="Trener szybkiego tilingu"
2021-05-31 15:00:35 +02:00
CONFIGURATION="Konfiguracja"
LCOLUMNS="Kolumny"
LROWS="Wiersze"
LGAP="Odstęp"
OUTER_GAP="Zewnętrzny odstęp"
NOTIFY="Powiadomienia"
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"
2021-06-01 02:01:25 +02:00
title="DesktopGrid - arrange your windows on the grid"
2022-02-15 22:11:33 +01:00
help='\n\nUse <b>Ctrl+Shift+Keypad_Keys</b> to move windows on the grid\n<b>Ctrl+Shift+LeftMouseClick</b> on appropriate area of the window to snap it in a given direction.\nSee: <a href="https://youtu.be/UzgUYYXnRww">video on YT</a>\n\n If you need even more control of windows size and position on the grid - use <b>super + LeftMouseClick</b> on window and then draw rectangle on the screen to select new window size and position.\nSee: <a href="https://youtu.be/Ba_lV-M0I2o">deskgrid preview on YT</a>\n\nConfigurable settings:\n- gap\n- show_outer_gap'
2021-06-01 02:01:25 +02:00
ABOUT="About DesktopGrid"
SHOW_IMGHELPER="Show image helper"
2022-02-24 03:03:33 +01:00
QUICK_TILE="Quick tiling trainer"
2021-06-01 02:01:25 +02:00
CONFIGURATION="Configuration"
LCOLUMNS="Columns"
LROWS="Rows"
LGAP="Gap between windows"
OUTER_GAP="Show outer gap"
NOTIFY="Notifications"
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"
2021-05-31 15:00:35 +02:00
title="DesktopGrid - arrange your windows on the grid"
2022-02-15 22:11:33 +01:00
help='\n\nUse <b>Ctrl+Shift+Keypad_Keys</b> to move windows on the grid\n<b>Ctrl+Shift+LeftMouseClick</b> on appropriate area of the window to snap it in a given direction.\nSee: <a href="https://youtu.be/UzgUYYXnRww">video on YT</a>\n\n If you need even more control of windows size and position on the grid - use <b>super + LeftMouseClick</b> on window and then draw rectangle on the screen to select new window size and position.\nSee: <a href="https://youtu.be/Ba_lV-M0I2o">deskgrid preview on YT</a>\n\nConfigurable settings:\n- gap\n- show_outer_gap'
2021-05-31 15:00:35 +02:00
ABOUT="About DesktopGrid"
SHOW_IMGHELPER="Show image helper"
2022-02-24 03:03:33 +01:00
QUICK_TILE="Quick tiling trainer"
2021-05-31 15:00:35 +02:00
CONFIGURATION="Configuration"
LCOLUMNS="Columns"
LROWS="Rows"
LGAP="Gap between windows"
OUTER_GAP="Show outer gap"
NOTIFY="Notifications"
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
CONFIG_DIR="$HOME/.config/deskgrid"
2021-05-23 13:19:01 +02:00
CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg"
2022-02-13 00:02:42 +01:00
mkdir -p $CONFIG_DIR
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
# Grid columns (12 16 24)
2021-05-23 13:19:01 +02:00
columns=12
2021-05-21 23:15:53 +02:00
# Grid rows (6 12 16)
2022-02-13 00:02:42 +01:00
rows=12
2021-05-21 23:15:53 +02:00
#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}
2021-06-01 02:01:25 +02:00
COL=${columns:-12}
2022-02-13 00:02:42 +01:00
ROWS=${rows:-12}
2021-05-21 23:15:53 +02:00
2021-06-01 02:01:25 +02:00
me="jgdeskgrid -s"
2021-05-31 15:00:35 +02:00
out+=("^sep(DesktopGrid)")
2021-06-01 14:17:48 +02:00
out+=("$ABOUT,notify-send.sh -u critical -i mbcc '$title' '$help' -o '$SHOW_IMGHELPER:drawgrid' -o '$EDITCONF:geany ~/.config/deskgrid/deskgrid.cfg'")
2021-05-31 15:00:35 +02:00
out+=("$SHOW_IMGHELPER,drawgrid")
2022-02-24 03:03:33 +01:00
out+=("$QUICK_TILE,yhtml /usr/share/mabox/help/Quick_tiling.html 'Mabox Quick tiling trainer - Ctrl + Shift + click'")
2021-05-31 15:00:35 +02:00
out+=("^sep($CONFIGURATION)")
2022-02-13 00:02:42 +01:00
#out+=("$LCOLUMNS [ <b>$COL</b> ],^checkout(columns)")
#out+=("$LROWS [ <b>$ROWS</b> ],^checkout(rows)")
2021-05-31 15:00:35 +02:00
out+=("$LGAP [ <b>$GAP</b> ],^checkout(gap)")
out+=("$OUTER_GAP [ <b>$show_outer_gap</b> ],^checkout(outer)")
out+=("$NOTIFY [ <b>$notifications</b> ],^checkout(notify)")
2021-05-21 23:15:53 +02:00
out+=("^sep()")
2021-06-01 02:01:25 +02:00
out+=("$EDITCONF,geany $CONFIG_FILE")
2021-05-21 23:15:53 +02:00
2022-02-13 00:02:42 +01:00
#out2+=("^tag(columns)")
#for i in 8 12 16 24 32; do out2+=("$(printf "<tt>%3s</tt>,%s" "$i" "mb-setvar columns=${i} $CONFIG_FILE;$me")");done
#out2+=("^tag(rows)")
#for i in 6 8 12 16 24; do out2+=("$(printf "<tt>%3s</tt>,%s" "$i" "mb-setvar rows=${i} $CONFIG_FILE;$me")");done
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-22 02:00:30 +02:00
out2+=("^tag(outer)")
out2+=("$(printf "<tt>%3s</tt>,%s" "true" "mb-setvar show_outer_gap=true $CONFIG_FILE;$me")")
out2+=("$(printf "<tt>%3s</tt>,%s" "false" "mb-setvar show_outer_gap=false $CONFIG_FILE;$me")")
out2+=("^tag(notify)")
out2+=("$(printf "<tt>%3s</tt>,%s" "true" "mb-setvar notifications=true $CONFIG_FILE;$me")")
out2+=("$(printf "<tt>%3s</tt>,%s" "false" "mb-setvar notifications=false $CONFIG_FILE;$me")")
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()")
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
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
mkconfigfile
cat <<EOF > ${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()"
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[@]}"