grid update

master
Daniel Napora 2021-05-15 02:38:38 +02:00
parent a70eb59fc7
commit 4e90a47d34
3 changed files with 45 additions and 34 deletions

View File

@ -4,16 +4,31 @@
# Author: Daniel Napora <napcok@gmail.com> # Author: Daniel Napora <napcok@gmail.com>
# https://maboxlinux.org # https://maboxlinux.org
# #
### Configuration CONFIG_DIR="$HOME/.config/deskgrid"
# Gap between windows CONFIG_FILE="$CONFIG_DIR/deskgrid.conf"
GAP="32" mkdir -p $CONFIG_DIR
show_outer_gap="true" if [ ! -f $CONFIG_FILE ]; then
# TITLEBAR HEIGHT - no idea how to find it from cli cat <<EOF > ${CONFIG_FILE}
TITLEBAR_HEIGHT="20" # Gap between windows in pixels (reasonable values: 0 8 16 24)
# Activate moved windows? gap=16
activate_window="false" # Grid columns (12 16 24)
### End Configuration 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) eval $(xdotool getmouselocation --shell)
Mouse_x="$X" Mouse_x="$X"

View File

@ -9,16 +9,20 @@ CONFIG_FILE="$CONFIG_DIR/deskgrid.conf"
mkdir -p $CONFIG_DIR mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE} cat <<EOF > ${CONFIG_FILE}
# Gap between windows in pixels # Gap between windows in pixels (reasonable values: 0 8 16 24)
gap=16 gap=16
# Grid columns # Grid columns (12 16 24)
grid_x=16 grid_x=16
# Grid rows # Grid rows (6 12 16)
grid_y=12 grid_y=12
# #
titlebar_height=18 titlebar_height=18
#Notifications true or false #Notifications true or false
enable_notifications=true enable_notifications=true
# Outer gap (disable if you use WM margins)
show_outer_gap=true
# Only for clicksnap action
activate_window=false
EOF EOF
fi fi
source <(grep = $CONFIG_FILE) 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_x="$(((X-MARGIN_X+W)/(AVAIL_X/GRID_X)))"
end_y="$(((Y-MARGIN_Y+H)/(AVAIL_Y/GRID_Y)))" end_y="$(((Y-MARGIN_Y+H)/(AVAIL_Y/GRID_Y)))"
### SIZE and POS calculation ### Outer gap factor
if [[ $start_x = "0" ]]; then GAP_X="$GAP" ; else GAP_X=$((GAP/2)) ; fi if [[ $show_outer_gap = true ]]; then GF="1" ; else GF="0" ; fi
if [[ $start_y = "0" ]]; then GAP_Y="$GAP" ; else GAP_Y=$((GAP/2)) ; fi
if [[ $end_x = $((GRID_X-1)) ]]; then GAP_X_END="$GAP" ; else GAP_X_END=$((GAP/2)) ; fi ### SIZE and POS calculation
if [[ $end_y = $((GRID_Y-1)) ]]; then GAP_Y_END="$GAP" ; else GAP_Y_END=$((GAP/2)) ; fi 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))" 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))"

View File

@ -8,23 +8,14 @@ GAP=${gap:-16}
GRID_X=${grid_x:-12} GRID_X=${grid_x:-12}
GRID_Y=${grid_y:-6} GRID_Y=${grid_y:-6}
AVAILSIZE=$(wmctrl -d |grep "*"|awk -F' ' '{print $9}') AVAILSIZE=$(wmctrl -d |grep "*"|awk -F' ' '{print $9}')
AVAIL_X="${AVAILSIZE%x*}" AVAIL_X="${AVAILSIZE%x*}"
AVAIL_Y="${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_WIDTH="$((AVAIL_X/GRID_X))"
TILE_HEIGHT="$((DRAW_Y/GRID_Y))" TILE_HEIGHT="$((AVAIL_Y/GRID_Y))"
rectangles="" rectangles=""
row="0" row="0"
for row in $(seq 0 $((GRID_Y-1))); for row in $(seq 0 $((GRID_Y-1)));
do do
@ -33,7 +24,7 @@ rectangles=""
rectangles+="rectangle $((tile*TILE_WIDTH)),$((row*TILE_HEIGHT)) $((tile*TILE_WIDTH+TILE_WIDTH)),$((row*TILE_HEIGHT+TILE_HEIGHT)) "; rectangles+="rectangle $((tile*TILE_WIDTH)),$((row*TILE_HEIGHT)) $((tile*TILE_WIDTH+TILE_WIDTH)),$((row*TILE_HEIGHT+TILE_HEIGHT)) ";
done done
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 \ magick -size $AVAILSIZE xc:LavenderBlush3 -stroke LavenderBlush2 -strokewidth 1 \
-fill LavenderBlush3 \ -fill LavenderBlush3 \
-draw "$rectangles" \ -draw "$rectangles" \
@ -41,11 +32,9 @@ magick -size $AVAILSIZE xc:LavenderBlush3 -stroke LavenderBlush2 -strokewidth 1
/tmp/grid.png /tmp/grid.png
feh -N -x --title "DrawGrid helper" /tmp/grid.png > /dev/null 2>&1 & feh -N -x --title "DrawGrid helper" /tmp/grid.png > /dev/null 2>&1 &
sleep 1 sleep 1
dupa=$(wmctrl -l -p |grep "DrawGrid helper") dghelper=$(wmctrl -l -p |grep "DrawGrid helper")
#echo "$dupa"
read -r A B C D< <(echo $dupa) read -r A B C D< <(echo $dghelper)
#echo "$A $C"
wmctrl -i -r "$A" -b add,below wmctrl -i -r "$A" -b add,below
#Kolory dawne: fill LavenderBlush3 stroke LavenderBlush1