#!/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 text="text $((4)),$((26)) \"Hello I'm here to help you get familiar with DrawGrid ;)\nGrid: $GRID_X rows, $GRID_Y columns\nSingle tile size: $TILE_WIDTH x $TILE_HEIGHT\n\nUse mousewheel on taskbar to show/hide me\nTo close me: 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" \ /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