mabox-tools/bin/drawgrid

62 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
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}
AVAILSIZE=$(wmctrl -d |grep "*"|awk -F' ' '{print $9}')
AVAIL_X="${AVAILSIZE%x*}"
AVAIL_Y="${AVAILSIZE#*x}"
TILE_WIDTH="$((AVAIL_X/COLUMNS))"
TILE_HEIGHT="$((AVAIL_Y/ROWS))"
rectangles=""
row="0"
for row in $(seq 0 $((ROWS-1)));
do
for tile in $(seq 0 $((COLUMNS-1)));
do
rectangles+="rectangle $((tile*TILE_WIDTH)),$((row*TILE_HEIGHT)) $((tile*TILE_WIDTH+TILE_WIDTH)),$((row*TILE_HEIGHT+TILE_HEIGHT)) ";
done
done
name="text 24,96 DeskGrid"
text="text 30,120 \"Hello I'm here to help you get familiar with DeskGrid ;)\nGrid: $COLUMNS columns, $ROWS rows\nSingle tile size: $TILE_WIDTH x $TILE_HEIGHT\n\nUse mousewheel on taskbar to show/hide me\nTo close: middle click on taskbar or click here, then hit q key\""
magick -size $AVAILSIZE xc:LavenderBlush3 -stroke LavenderBlush2 -strokewidth 1 \
-fill LavenderBlush3 \
-draw "$rectangles" \
-style Normal +stroke -pointsize 14 -fill gray16 -draw "$text" \
-style Normal -weight Bold +stroke -pointsize 64 -fill orange3 -draw "$name" \
/tmp/grid.png
feh -N -x -g "$AVAILSIZE" --title "DrawGrid helper" /tmp/grid.png > /dev/null 2>&1 &
sleep 1
dghelper=$(wmctrl -l -p |grep "DrawGrid helper")
read -r A B C D< <(echo $dghelper)
wmctrl -i -r "$A" -b add,below