mabox-tools/bin/drawgrid
2021-05-14 20:44:00 +02:00

52 lines
1.6 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}"
# DRAWAREA = AVAILSIZE - OUTER_GAP
if [[ "$show_outer_gap" == "true" ]]; then
DRAW_X="$((AVAIL_X-GAP))" DRAW_Y="$((AVAIL_Y-GAP))"
else
DRAW_X="$AVAIL_X" DRAW_Y="$AVAIL_Y"
GAP_COMP="0"
fi
TILE_WIDTH="$((DRAW_X/GRID_X))"
TILE_HEIGHT="$((DRAW_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 this crazy tool ;)\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 --title "DrawGrid helper" /tmp/grid.png > /dev/null 2>&1 &
sleep 1
dupa=$(wmctrl -l -p |grep "DrawGrid helper")
#echo "$dupa"
read -r A B C D< <(echo $dupa)
#echo "$A $C"
wmctrl -i -r "$A" -b add,below
#Kolory dawne: fill LavenderBlush3 stroke LavenderBlush1