From 4e90a47d34b445b91a775201525b182c5522e889 Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Sat, 15 May 2021 02:38:38 +0200 Subject: [PATCH] grid update --- bin/clicksnap | 33 ++++++++++++++++++++++++--------- bin/deskgrid | 23 +++++++++++++++-------- bin/drawgrid | 23 ++++++----------------- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/bin/clicksnap b/bin/clicksnap index c3348f8..13e2170 100755 --- a/bin/clicksnap +++ b/bin/clicksnap @@ -4,16 +4,31 @@ # Author: Daniel Napora # https://maboxlinux.org # -### Configuration -# Gap between windows -GAP="32" -show_outer_gap="true" -# TITLEBAR HEIGHT - no idea how to find it from cli -TITLEBAR_HEIGHT="20" -# Activate moved windows? -activate_window="false" -### End Configuration +CONFIG_DIR="$HOME/.config/deskgrid" +CONFIG_FILE="$CONFIG_DIR/deskgrid.conf" +mkdir -p $CONFIG_DIR +if [ ! -f $CONFIG_FILE ]; then +cat < ${CONFIG_FILE} +# Gap between windows in pixels (reasonable values: 0 8 16 24) +gap=16 +# Grid columns (12 16 24) +grid_x=16 +# Grid rows (6 12 16) +grid_y=12 +# +titlebar_height=18 +#Notifications true or false +enable_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} +TITLEBAR_HEIGHT=${titlebar_height:-18} eval $(xdotool getmouselocation --shell) Mouse_x="$X" diff --git a/bin/deskgrid b/bin/deskgrid index 0155143..70b12e0 100755 --- a/bin/deskgrid +++ b/bin/deskgrid @@ -9,16 +9,20 @@ CONFIG_FILE="$CONFIG_DIR/deskgrid.conf" mkdir -p $CONFIG_DIR if [ ! -f $CONFIG_FILE ]; then cat < ${CONFIG_FILE} -# Gap between windows in pixels +# Gap between windows in pixels (reasonable values: 0 8 16 24) gap=16 -# Grid columns +# Grid columns (12 16 24) grid_x=16 -# Grid rows +# Grid rows (6 12 16) grid_y=12 # titlebar_height=18 #Notifications true or false enable_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) @@ -67,12 +71,15 @@ start_y="$(((Y-MARGIN_Y)/(AVAIL_Y/GRID_Y)))" end_x="$(((X-MARGIN_X+W)/(AVAIL_X/GRID_X)))" end_y="$(((Y-MARGIN_Y+H)/(AVAIL_Y/GRID_Y)))" -### SIZE and POS calculation -if [[ $start_x = "0" ]]; then GAP_X="$GAP" ; else GAP_X=$((GAP/2)) ; fi -if [[ $start_y = "0" ]]; then GAP_Y="$GAP" ; else GAP_Y=$((GAP/2)) ; fi +### Outer gap factor +if [[ $show_outer_gap = true ]]; then GF="1" ; else GF="0" ; fi -if [[ $end_x = $((GRID_X-1)) ]]; then GAP_X_END="$GAP" ; else GAP_X_END=$((GAP/2)) ; fi -if [[ $end_y = $((GRID_Y-1)) ]]; then GAP_Y_END="$GAP" ; else GAP_Y_END=$((GAP/2)) ; fi +### SIZE and POS calculation +if [[ $start_x = "0" ]]; then GAP_X="$((GAP*GF))" ; else GAP_X=$((GAP/2)) ; fi +if [[ $start_y = "0" ]]; then GAP_Y="$((GAP*GF))" ; else GAP_Y=$((GAP/2)) ; fi + +if [[ $end_x = $((GRID_X-1)) ]]; then GAP_X_END="$((GAP*GF))" ; else GAP_X_END=$((GAP/2)) ; fi +if [[ $end_y = $((GRID_Y-1)) ]]; then GAP_Y_END="$((GAP*GF))" ; else GAP_Y_END=$((GAP/2)) ; fi SIZE="$(((end_x-start_x+1)*(AVAIL_X/GRID_X)-GAP_X-GAP_X_END)) $(((end_y-start_y+1)*(AVAIL_Y/GRID_Y)-GAP_Y-GAP_Y_END-T))" diff --git a/bin/drawgrid b/bin/drawgrid index bb070e3..b3fcaa2 100755 --- a/bin/drawgrid +++ b/bin/drawgrid @@ -8,23 +8,14 @@ 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))" +TILE_WIDTH="$((AVAIL_X/GRID_X))" +TILE_HEIGHT="$((AVAIL_Y/GRID_Y))" rectangles="" - row="0" for row in $(seq 0 $((GRID_Y-1))); do @@ -33,7 +24,7 @@ rectangles="" 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\"" +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" \ @@ -41,11 +32,9 @@ magick -size $AVAILSIZE xc:LavenderBlush3 -stroke LavenderBlush2 -strokewidth 1 /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" +dghelper=$(wmctrl -l -p |grep "DrawGrid helper") + +read -r A B C D< <(echo $dghelper) wmctrl -i -r "$A" -b add,below -#Kolory dawne: fill LavenderBlush3 stroke LavenderBlush1