mabox-tools/bin/drawgrid

43 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
CONFIG_DIR="$HOME/.config/deskgrid"
CONFIG_FILE="$CONFIG_DIR/deskgrid.conf"
source <(grep = $CONFIG_FILE)
GAP=${gap:-16}
GRID_X=${grid_x:-12}
GRID_Y=${grid_y:-6}
AVAILSIZE=$(wmctrl -d |grep "*"|awk -F' ' '{print $9}')
AVAIL_X="${AVAILSIZE%x*}"
AVAIL_Y="${AVAILSIZE#*x}"
TILE_WIDTH="$((AVAIL_X/GRID_X))"
TILE_HEIGHT="$((AVAIL_Y/GRID_Y))"
rectangles=""
row="0"
for row in $(seq 0 $((GRID_Y-1)));
do
for tile in $(seq 0 $((GRID_X-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: $GRID_X columns, $GRID_Y 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