From e84af0d5db0e47522101629c886f6baf657cccf6 Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Sun, 23 May 2021 13:18:24 +0200 Subject: [PATCH] deskgrid cfg file update --- bin/chwp | 5 +++-- bin/deskgrid | 28 ++++++++++++++-------------- bin/deskmngr | 2 ++ bin/drawgrid | 35 +++++++++++++++++++++++++++-------- bin/snapwin | 6 +++--- 5 files changed, 49 insertions(+), 27 deletions(-) diff --git a/bin/chwp b/bin/chwp index 1192b1d..f9bcd56 100755 --- a/bin/chwp +++ b/bin/chwp @@ -1,4 +1,5 @@ #!/bin/bash + CONFIG_DIR="$HOME/.config/chwp" CONFIG_FILE="$CONFIG_DIR/chwp.conf" WALLPAPERS_LIST="$CONFIG_DIR/wplist" @@ -12,7 +13,7 @@ cat < ${CONFIG_FILE} # Directory with wallpapers wallpaper_dir=/usr/share/backgrounds/ # Rotate time in seconds -interval=10 +interval=60 # Wallpaper setter program: nitrogen or feh setter=nitrogen EOF @@ -23,7 +24,7 @@ source <(grep = $CONFIG_FILE) # decide which setter and command use to set wallpaper case "$setter" in - nitrogen) command="nitrogen --set-zoom-fill";; + nitrogen) command="nitrogen --set-zoom-fill --save";; feh) command="feh --bg-fill" ;; *) echo "Unknown wallpaper setter. Please check your config file $CONFIG_FILE";exit 1;; esac diff --git a/bin/deskgrid b/bin/deskgrid index d21710a..959b4f2 100755 --- a/bin/deskgrid +++ b/bin/deskgrid @@ -7,16 +7,16 @@ CONFIG_DIR=~/.config/deskgrid -CONFIG_FILE="$CONFIG_DIR/deskgrid.conf" +CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg" 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 +columns=12 # Grid rows (6 12 16) -grid_y=12 +rows=6 # titlebar_height=18 #Notifications true or false @@ -30,8 +30,8 @@ fi source <(grep = $CONFIG_FILE) GAP=${gap:-16} -GRID_X=${grid_x:-12} -GRID_Y=${grid_y:-6} +COLUMNS=${columns:-12} +ROWS=${rows:-6} TITLEBAR_HEIGHT=${titlebar_height:-18} @@ -68,10 +68,10 @@ fi slop=$(slop --highlight -b 4 --tolerance=0 --color=0.3,0.4,0.6,0.4 -f "%x %y %w %h") || exit 1 read -r X Y W H < <(echo $slop) -start_x="$(((X-MARGIN_X)/(AVAIL_X/GRID_X)))" -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)))" +start_x="$(((X-MARGIN_X)/(AVAIL_X/COLUMNS)))" +start_y="$(((Y-MARGIN_Y)/(AVAIL_Y/ROWS)))" +end_x="$(((X-MARGIN_X+W)/(AVAIL_X/COLUMNS)))" +end_y="$(((Y-MARGIN_Y+H)/(AVAIL_Y/ROWS)))" ### Outer gap factor if [[ $show_outer_gap = true ]]; then GF="1" ; else GF="0" ; fi @@ -80,12 +80,12 @@ if [[ $show_outer_gap = true ]]; then GF="1" ; else GF="0" ; 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 +if [[ $end_x = $((COLUMNS-1)) ]]; then GAP_X_END="$((GAP*GF))" ; else GAP_X_END=$((GAP/2)) ; fi +if [[ $end_y = $((ROWS-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/COLUMNS)-GAP_X-GAP_X_END)) $(((end_y-start_y+1)*(AVAIL_Y/ROWS)-GAP_Y-GAP_Y_END-T))" -POSITION="$((start_x*AVAIL_X/GRID_X+GAP_X+MARGIN_X)) $((start_y*AVAIL_Y/GRID_Y+GAP_Y+MARGIN_Y))" +POSITION="$((start_x*AVAIL_X/COLUMNS+GAP_X+MARGIN_X)) $((start_y*AVAIL_Y/ROWS+GAP_Y+MARGIN_Y))" xdotool windowsize $WINDOW $SIZE @@ -95,5 +95,5 @@ xdotool windowmap $WINDOW if [ $notifications = true ]; then notify-send.sh -t 15000 --replace-file=/tmp/deskgrid --icon=mbcc "Info" "You can disable those notifications or edit config file using buttons below.\n\n" -o "Disable notifications:mb-setvar enable_notifications=false ~/.config/deskgrid/deskgrid.conf" -o "Edit DeskGrid config file:geany ~/.config/deskgrid/deskgrid.conf" -#notify-send.sh -t 15000 --replace-file=/tmp/deskgrid --icon=mbcc "Success notification" "You can disable those notifications by editing config file. Button below.\nScreensize: $SCREENSIZE\nMargins: $MARGINS\nAvailable size: $AVAILSIZE\nGrid: $((AVAIL_X/GRID_X)) x $((AVAIL_Y/GRID_Y)) Selection: $slop\nPosition: $POSITION\n($start_x*$AVAIL_X/$GRID_X+$GAP_X+$MARGIN_X)\n($start_y*$AVAIL_Y/$GRID_Y+$GAP_Y+$MARGIN_Y) \nSize: $SIZE" -o "Disable notifications:mb-setvar enable_notifications=false ~/.config/deskgrid/deskgrid.conf" -o "Edit config file:geany ~/.config/deskgrid/deskgrid.conf" +#notify-send.sh -t 15000 --replace-file=/tmp/deskgrid --icon=mbcc "Success notification" "You can disable those notifications by editing config file. Button below.\nScreensize: $SCREENSIZE\nMargins: $MARGINS\nAvailable size: $AVAILSIZE\nGrid: $((AVAIL_X/COLUMNS)) x $((AVAIL_Y/ROWS)) Selection: $slop\nPosition: $POSITION\n($start_x*$AVAIL_X/$COLUMNS+$GAP_X+$MARGIN_X)\n($start_y*$AVAIL_Y/$ROWS+$GAP_Y+$MARGIN_Y) \nSize: $SIZE" -o "Disable notifications:mb-setvar enable_notifications=false ~/.config/deskgrid/deskgrid.conf" -o "Edit config file:geany ~/.config/deskgrid/deskgrid.conf" fi diff --git a/bin/deskmngr b/bin/deskmngr index 7f41121..36be94d 100755 --- a/bin/deskmngr +++ b/bin/deskmngr @@ -55,6 +55,7 @@ savesession() { sd -s "/usr/lib/chromium/chromium" "chromium --new-window" "$SESSIONDIR/${filename// /_}.desk" sd -s "/usr/lib/firefox/firefox" "firefox --new-window" "$SESSIONDIR/${filename// /_}.desk" sd -s "/usr/bin/python3 /usr/bin/terminator" "terminator" "$SESSIONDIR/${filename// /_}.desk" + sd -s "/usr/bin/python /usr/bin/terminator" "terminator" "$SESSIONDIR/${filename// /_}.desk" sd -s "geany" "geany -i" "$SESSIONDIR/${filename// /_}.desk" sd -s "cherrytree" "cherrytree --new-window" "$SESSIONDIR/${filename// /_}.desk" sd -s "pcmanfm -d" "pcmanfm -n" "$SESSIONDIR/${filename// /_}.desk" @@ -63,6 +64,7 @@ savesession() { sed -i '/usr/lib/chromium/chromium,chromium --new-window,' "$SESSIONDIR/${filename// /_}.desk" sed -i '/usr/lib/firefox/firefox,firefox --new-window,' "$SESSIONDIR/${filename// /_}.desk" sed -i '/usr/bin/python3 /usr/bin/terminator,terminator,' "$SESSIONDIR/${filename// /_}.desk" + sed -i '/usr/bin/python /usr/bin/terminator,terminator,' "$SESSIONDIR/${filename// /_}.desk" sed -i 'geany,geany -i,' "$SESSIONDIR/${filename// /_}.desk" sed -i 'cherrytree,cherrytree --new-window,' "$SESSIONDIR/${filename// /_}.desk" sed -i 'pcmanfm -d,pcmanfm -n,' "$SESSIONDIR/${filename// /_}.desk" diff --git a/bin/drawgrid b/bin/drawgrid index 079bf76..3651ff8 100755 --- a/bin/drawgrid +++ b/bin/drawgrid @@ -1,31 +1,50 @@ #!/bin/bash CONFIG_DIR="$HOME/.config/deskgrid" -CONFIG_FILE="$CONFIG_DIR/deskgrid.conf" +CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg" +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) +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 source <(grep = $CONFIG_FILE) GAP=${gap:-16} -GRID_X=${grid_x:-12} -GRID_Y=${grid_y:-6} +COLUMNS=${columns:-12} +ROWS=${rows:-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))" +TILE_WIDTH="$((AVAIL_X/COLUMNS))" +TILE_HEIGHT="$((AVAIL_Y/ROWS))" rectangles="" row="0" - for row in $(seq 0 $((GRID_Y-1))); + for row in $(seq 0 $((ROWS-1))); do - for tile in $(seq 0 $((GRID_X-1))); + for tile in $(seq 0 $((COLUMNS-1))); do rectangles+="rectangle $((tile*TILE_WIDTH)),$((row*TILE_HEIGHT)) $((tile*TILE_WIDTH+TILE_WIDTH)),$((row*TILE_HEIGHT+TILE_HEIGHT)) "; done done name="text 24,96 DeskGrid" -text="text 30,120 \"Hello I'm here to help you get familiar with DeskGrid ;)\nGrid: $GRID_X columns, $GRID_Y 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\"" +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\"" magick -size $AVAILSIZE xc:LavenderBlush3 -stroke LavenderBlush2 -strokewidth 1 \ -fill LavenderBlush3 \ -draw "$rectangles" \ diff --git a/bin/snapwin b/bin/snapwin index 12b82f2..9f64089 100755 --- a/bin/snapwin +++ b/bin/snapwin @@ -21,16 +21,16 @@ _config() { CONFIG_DIR="$HOME/.config/deskgrid" -CONFIG_FILE="$CONFIG_DIR/deskgrid.conf" +CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg" 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 +columns=12 # Grid rows (6 12 16) -grid_y=12 +rows=6 # titlebar_height=18 #Notifications true or false