mabox-pipemenus/usr/bin/jgdeskgrid

130 lines
4.8 KiB
Bash
Executable File

#!/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 <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- ilość kolumn\n- ilość wierszy\n- odstęp\n- odstęp zewnętrzny'
ABOUT="O DesktopGrid"
SHOW_IMGHELPER="Pokaż siatkę"
CONFIGURATION="Konfiguracja"
LCOLUMNS="Kolumny"
LROWS="Wiersze"
LGAP="Odstęp"
OUTER_GAP="Zewnętrzny odstęp"
NOTIFY="Powiadomienia"
EDITCONF="Edytuj plik konfiguracyjny"
;;
es*)
REMOVE="Eliminar este menú del panel"
;;
*)
REMOVE="Remove this menu from panel"
title="DesktopGrid - arrange your windows on the grid"
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- columns\n- rows\n- gap\n- show_outer_gap'
ABOUT="About DesktopGrid"
SHOW_IMGHELPER="Show image helper"
CONFIGURATION="Configuration"
LCOLUMNS="Columns"
LROWS="Rows"
LGAP="Gap between windows"
OUTER_GAP="Show outer gap"
NOTIFY="Notifications"
EDITCONF="Edit config file"
;;
esac
. ~/.config/mabox/mabox.conf
CONFIG_DIR="$HOME/.config/deskgrid"
CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg"
mkdir -p $CONFIG_DIR
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)
columns=12
# Grid rows (6 12 16)
rows=6
#
titlebar_height=18
#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}
COLUMNS=${columns:-12}
ROWS=${rows:-6}
TITLEBAR_HEIGHT=${titlebar_height:-18}
me="mb-jgtools $jgtools_last"
out+=("^sep(DesktopGrid)")
out+=("$ABOUT,notify-send.sh -u critical -i mbcc '$title' '$help' -o '$EDITCONF:geany ~/.config/deskgrid/deskgrid.cfg'")
out+=("$SHOW_IMGHELPER,drawgrid")
out+=("^sep($CONFIGURATION)")
out+=("$LCOLUMNS [ <b>$COLUMNS</b> ],^checkout(columns)")
out+=("$LROWS [ <b>$ROWS</b> ],^checkout(rows)")
out+=("$LGAP [ <b>$GAP</b> ],^checkout(gap)")
out+=("$OUTER_GAP [ <b>$show_outer_gap</b> ],^checkout(outer)")
out+=("$NOTIFY [ <b>$notifications</b> ],^checkout(notify)")
out+=("^sep()")
out+=("$EDITCONF ,geany $CONFIG_FILE")
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
out2+=("^tag(gap)")
for i in 0 2 4 8 12 16 24 32 40; do out2+=("$(printf "<tt>%3s</tt>,%s" "$i" "mb-setvar gap=${i} $CONFIG_FILE;$me")");done
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")")
### RUN
if [[ "$1" == "-s" ]]; then
. /usr/bin/pipemenu-standalone.cfg
MENU_PADDING_TOP=0
MENU_HALIGN="center"
MENU_VALIGN="center"
jgmenu_icon_size=0
[ $(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()"
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_jgdeskgrid=false;mb-jgtools places"
fi
printf '%s\n' "${out2[@]}"