mabox-tools/bin/drawgrid

62 lines
1.8 KiB
Plaintext
Raw Normal View History

2021-05-14 19:35:19 +02:00
#!/bin/bash
CONFIG_DIR="$HOME/.config/deskgrid"
2021-05-23 13:18:24 +02:00
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
2021-05-14 19:35:19 +02:00
source <(grep = $CONFIG_FILE)
GAP=${gap:-16}
2021-05-23 13:18:24 +02:00
COLUMNS=${columns:-12}
ROWS=${rows:-6}
2021-05-14 19:35:19 +02:00
AVAILSIZE=$(wmctrl -d |grep "*"|awk -F' ' '{print $9}')
AVAIL_X="${AVAILSIZE%x*}"
AVAIL_Y="${AVAILSIZE#*x}"
2021-05-23 13:18:24 +02:00
TILE_WIDTH="$((AVAIL_X/COLUMNS))"
TILE_HEIGHT="$((AVAIL_Y/ROWS))"
2021-05-14 19:35:19 +02:00
rectangles=""
row="0"
2021-05-23 13:18:24 +02:00
for row in $(seq 0 $((ROWS-1)));
2021-05-14 19:35:19 +02:00
do
2021-05-23 13:18:24 +02:00
for tile in $(seq 0 $((COLUMNS-1)));
2021-05-14 19:35:19 +02:00
do
rectangles+="rectangle $((tile*TILE_WIDTH)),$((row*TILE_HEIGHT)) $((tile*TILE_WIDTH+TILE_WIDTH)),$((row*TILE_HEIGHT+TILE_HEIGHT)) ";
done
done
2021-05-21 23:06:41 +02:00
name="text 24,96 DeskGrid"
2021-05-23 13:18:24 +02:00
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\""
2021-05-14 19:35:19 +02:00
magick -size $AVAILSIZE xc:LavenderBlush3 -stroke LavenderBlush2 -strokewidth 1 \
-fill LavenderBlush3 \
-draw "$rectangles" \
-style Normal +stroke -pointsize 14 -fill gray16 -draw "$text" \
2021-05-20 14:37:22 +02:00
-style Normal -weight Bold +stroke -pointsize 64 -fill orange3 -draw "$name" \
2021-05-14 19:35:19 +02:00
/tmp/grid.png
2021-05-19 02:35:11 +02:00
feh -N -x -g "$AVAILSIZE" --title "DrawGrid helper" /tmp/grid.png > /dev/null 2>&1 &
2021-05-14 20:44:00 +02:00
sleep 1
2021-05-15 02:38:38 +02:00
dghelper=$(wmctrl -l -p |grep "DrawGrid helper")
read -r A B C D< <(echo $dghelper)
2021-05-14 19:35:19 +02:00
wmctrl -i -r "$A" -b add,below