commit b0a584bfd2830c04f7989e664678c1d4a1d59f7b parent e49c5abb1376399321058b4a68bdf9ec44cc7144 Author: jacobsGit <JacobDoesLinux@protonmail.com> Date: Sun, 12 Jan 2020 11:16:54 -0800 inital comment bspwm scripts i wrote in dash Diffstat:
| A | bspwm/.config/bspwm/bspc-utils/bspc-hjkl | | | 37 | +++++++++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/bspc-larger-smaller | | | 29 | +++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/bspc-set-geometry | | | 60 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/bspc-subscribe-desktop | | | 35 | +++++++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/bspc-toggle-layer | | | 24 | ++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/trash/bspR-d | | | 31 | +++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/trash/bspc-hjkl | | | 92 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/trash/bspc-rainbow-border | | | 72 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/trash/bspwm-resize | | | 95 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/trash/resize.fail | | | 79 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/trash/resize.save.firstworking | | | 72 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | bspwm/.config/bspwm/bspc-utils/unpolished/resize | | | 76 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
12 files changed, 702 insertions(+), 0 deletions(-)
diff --git a/bspwm/.config/bspwm/bspc-utils/bspc-hjkl b/bspwm/.config/bspwm/bspc-utils/bspc-hjkl @@ -0,0 +1,37 @@ +#!/bin/dash +# Jacob Edwards, 2020 +# bspwm utility to resize nodes + + +# set increment to default if none is specified and test weather an argument was given. +if [ -z "$1" ]; then + printf 'error, no arguments `--help` for help.\n' + exit 1 +elif [ -z $2 ]; then + inc=25 +else + inc="$2" +fi + + +if [ "$1" = '--left' ]; then + bspc node --resize left "-$inc" 0 + bspc node east.tiled --resize left "-$inc" 0 +elif [ "$1" = '--right' ]; then + bspc node --resize right "$inc" 0 + bspc node west.tiled --resize right "$inc" 0 +elif [ "$1" = '--up' ]; then + bspc node --resize top 0 "$inc" + bspc node south.tiled --resize top 0 "$inc" +elif [ "$1" = '--down' ]; then + bspc node --resize bottom 0 "-$inc" + bspc node north.tiled --resize bottom 0 "-$inc" +elif [ "$1" = '--help' ]; then + printf 'Usage, bspc-hjkl [DIRECTION] [OPTIONAL:INCREMENT:INT]\n' + printf '\n' + printf 'Directions:\n' + printf ' --right\n' + printf ' --left\n' + printf ' --up\n' + printf ' --down\n' +fi diff --git a/bspwm/.config/bspwm/bspc-utils/bspc-larger-smaller b/bspwm/.config/bspwm/bspc-utils/bspc-larger-smaller @@ -0,0 +1,29 @@ +#!/bin/dash +# jacob edwards -- 09/01/2020 +# bspwm window resizing + +bspc query --nodes --node north +north=$? + +bspc query --nodes --node east +east=$? + +bspc query --nodes --node south +south=$? + +bspc query --nodes --node west +west=$? + + +if [ "$1" = '--enlarge' ]; then + if [ "$north" -eq '0' ]; then bspc node --resize top 0 -50 ;fi + if [ "$east" -eq '0' ]; then bspc node --resize right 50 0 ;fi + if [ "$south" -eq '0' ]; then bspc node --resize bottom 0 50 ;fi + if [ "$west" -eq '0' ]; then bspc node --resize left -50 0 ;fi + +elif [ "$1" = '--shrink' ]; then + if [ "$north" -eq '0' ]; then bspc node --resize top 0 50 ;fi + if [ "$east" -eq '0' ]; then bspc node --resize right -50 0 ;fi + if [ "$south" -eq '0' ]; then bspc node --resize bottom 0 -50 ;fi + if [ "$west" -eq '0' ]; then bspc node --resize left 50 0 ;fi +fi diff --git a/bspwm/.config/bspwm/bspc-utils/bspc-set-geometry b/bspwm/.config/bspwm/bspc-utils/bspc-set-geometry @@ -0,0 +1,60 @@ +#!/bin/dash +# Jacob Edwards, 10/01/2020 +# fast script to change node (window) geometry (primarily floating) in bspwm using bspc. + + +# help message +if [ "$1" = '--help' ]; then + printf 'Usage, bspc.set.geometry [X:int] [Y:int]\n' + exit 0 +fi + + +# test wether specified geometry surpases display size +Gdisplay="$( xdotool getdisplaygeometry)" +if [ "$1" -gt "$( printf "$Gdisplay" | awk '{print $1}' )" ] || [ "$2" -gt "$( printf "$Gdisplay" | awk '{print $2}' )" ]; then + printf "Error, max geometry is $Gdisplay\n" + exit 1 +fi + + +# get node geometry +Gnode="$( xdotool getwindowgeometry "$( xdotool getactivewindow )" | tail -n 1 | awk '{print $2}' )" +Xnode="$( printf "$Gnode" | cut -d 'x' -f 1 )" +Ynode="$( printf "$Gnode" | cut -d 'x' -f 2 )" + + +# 0 = adding, 1 = subtracting +if [ "$1" -lt "$Xnode" ]; then + x=true +else + x=false +fi + +if [ "$2" -lt "$Ynode" ]; then + y=true +else + y=false +fi + + +# set new geometry +if [ "$x" = 'true' ]; then + Xdiff="$( expr \( "$Xnode" - "$1" \) / 2 )" + bspc node --resize left "$Xdiff" 0 + bspc node --resize right "-$Xdiff" 0 +elif [ "$x" = 'false' ]; then + Xdiff="$( expr \( "$1" - "$Xnode" \) / 2 )" + bspc node --resize left "-$Xdiff" 0 + bspc node --resize right "$Xdiff" 0 +fi + +if [ "$y" = 'true' ]; then + Ydiff="$( expr \( "$Ynode" - "$2" \) / 2 )" + bspc node --resize top 0 "$Ydiff" + bspc node --resize bottom 0 "-$Ydiff" +elif [ "$y" = 'false' ]; then + Ydiff="$( expr \( "$2" - "$Ynode" \) / 2 )" + bspc node --resize top 0 "-$Ydiff" + bspc node --resize bottom 0 "$Ydiff" +fi diff --git a/bspwm/.config/bspwm/bspc-utils/bspc-subscribe-desktop b/bspwm/.config/bspwm/bspc-utils/bspc-subscribe-desktop @@ -0,0 +1,35 @@ +#!/bin/dash +# Jacob Edwards, 2020 +# bspwm utility for notifying of desktop change + +tmpfile='/tmp/bspc-focus' + + +if [ "$1" = '--help' ]; then + printf 'error, no arguments `--help` for help\n' + exit 1 +elif [ -z "$1" ]; then + delay=0.2 +else + delay="$1" +fi + + +# init log +if [ -e "$tmpfile" ]; then + rm "$tmpfile" +fi + + + +bspc subscribe desktop_focus > "$tmpfile" & + +while true; do + if [ "$focus" != "$( tail -n 1 "$tmpfile" )" ]; then + desktop="$(bspc query --desktops --desktop --names)" + notify-send-replace "$desktop" + fi + + focus="$( tail -n 1 "$tmpfile" )" + sleep "$delay" +done diff --git a/bspwm/.config/bspwm/bspc-utils/bspc-toggle-layer b/bspwm/.config/bspwm/bspc-utils/bspc-toggle-layer @@ -0,0 +1,24 @@ +#!/bin/dash +# +# Jacob Edwards, 2020 +# bspwm utility to switch floating windows +# that are above or below to the opposite + + +if [ "$1" = '--above' ]; then + bspc node --focus any.floating.below.local + + if [ "$?" -eq '0' ]; then + bspc-set-geometry 1266 668 + bspc node --layer above + fi + +elif [ "$1" = '--below' ]; then + bspc node --focus any.floating.above.local + + if [ "$?" -eq '0' ]; then + bspc node --layer below + bspc-set-geometry 683 384 + bspc node --focus last.local.tiled + fi +fi diff --git a/bspwm/.config/bspwm/bspc-utils/trash/bspR-d b/bspwm/.config/bspwm/bspc-utils/trash/bspR-d @@ -0,0 +1,31 @@ +#!/bin/dash +# trying dash to see if its faster. +# maybe there is a premade script (definitaly) but +# oh well im not on internet for a week and I find it fun +# jacob edwards -- 09/01/2020 + +bspc query --nodes --node north +north=$? + +bspc query --nodes --node east +east=$? + +bspc query --nodes --node south +south=$? + +bspc query --nodes --node west +west=$? + + +if [ "$1" = '--enlarge' ]; then + if [ "$north" -eq '0' ]; then bspc node --resize top 0 -50 ;fi + if [ "$east" -eq '0' ]; then bspc node --resize right 50 0 ;fi + if [ "$south" -eq '0' ]; then bspc node --resize bottom 0 50 ;fi + if [ "$west" -eq '0' ]; then bspc node --resize left -50 0 ;fi + +elif [ "$1" = '--shrink' ]; then + if [ "$north" -eq '0' ]; then bspc node --resize top 0 50 ;fi + if [ "$east" -eq '0' ]; then bspc node --resize right -50 0 ;fi + if [ "$south" -eq '0' ]; then bspc node --resize bottom 0 -50 ;fi + if [ "$west" -eq '0' ]; then bspc node --resize left 50 0 ;fi +fi diff --git a/bspwm/.config/bspwm/bspc-utils/trash/bspc-hjkl b/bspwm/.config/bspwm/bspc-utils/trash/bspc-hjkl @@ -0,0 +1,92 @@ +#!/bin/dash +# +# Jacob Edwards +# resizing bspwm nodes (windows) meant to be used with keybinder (sxhkd,xbindkeys) + + +if [ -z "$1" ]; then + printf 'error, no arguments\nUsage, bspc-hjkl -{n,e,s,w}\n' + exit 1 +fi + +# don't know how to silence these. +(bspc query --nodes --node west); west=$? +(bspc query --nodes --node east); east=$? +(bspc query --nodes --node north); north=$? +(bspc query --nodes --node south); south=$? + +if [ "$north" -eq '1' ] && [ "$east" -eq '1' ]; then # :. + if [ "$1" = '-n' ]; then + bspc node --resize top 0 50 + bspc node --resize bottom 0 -50 + elif [ "$1" = '-e' ]; then + bspc node --resize left 50 0 + bspc node --resize right -50 0 + elif [ "$1" = '-s' ]; then + bspc node --resize top 0 -50 + bspc node --resize bottom 0 50 + elif [ "$1" = '-w' ]; then + bspc node --resize left -50 0 + bspc node --resize right 50 0 + fi + +elif [ "$north" -eq '1' ] && [ "$west" -eq '1' ]; then # .: + if [ "$1" = '-n' ]; then + bspc node --resize top 0 50 + bspc node --resize bottom 0 -50 + elif [ "$1" = '-e' ]; then + bspc node --resize left -50 0 + bspc node --resize right 50 0 + elif [ "$1" = '-s' ]; then + bspc node --resize top 0 -50 + bspc node --resize bottom 0 50 + elif [ "$1" = '-w' ]; then + bspc node --resize left 50 0 + bspc node --resize right -50 0 + fi + +elif [ "$south" -eq '1' ] && [ "$east" -eq '1' ]; then # :` + if [ "$1" = '-n' ]; then + bspc node --resize top 0 -50 + bspc node --resize bottom 0 50 + elif [ "$1" = '-e' ]; then + bspc node --resize left 50 0 + bspc node --resize right -50 0 + elif [ "$1" = '-s' ]; then + bspc node --resize top 0 50 + bspc node --resize bottom 0 -50 + elif [ "$1" = '-w' ]; then + bspc node --resize left -50 0 + bspc node --resize right 50 0 + fi + +elif [ "$south" -eq '1' ] && [ "$west" -eq '1' ]; then # `: + if [ "$1" = '-n' ]; then + bspc node --resize top 0 -50 + bspc node --resize bottom 0 50 + elif [ "$1" = '-e' ]; then + bspc node --resize left -50 0 + bspc node --resize right 50 0 + elif [ "$1" = '-s' ]; then + bspc node --resize top 0 50 + bspc node --resize bottom 0 -50 + elif [ "$1" = '-w' ]; then + bspc node --resize left 50 0 + bspc node --resize right -50 0 + fi +else + if [ "$1" = '-n' ]; then + bspc node --resize bottom 0 -50 + bspc node --resize top 0 -50 + elif [ "$1" = '-e' ]; then + bspc node --resize left -50 0 + bspc node --resize right 50 0 + elif [ "$1" = '-s' ]; then + bspc node --resize bottom 0 50 + bspc node --resize top 0 50 + elif [ "$1" = '-w' ]; then + bspc node --resize left 50 0 + bspc node --resize right -50 0 + fi +fi + diff --git a/bspwm/.config/bspwm/bspc-utils/trash/bspc-rainbow-border b/bspwm/.config/bspwm/bspc-utils/trash/bspc-rainbow-border @@ -0,0 +1,72 @@ +#!/bin/dash +step=5 + +lowT="$(expr "$step" + 60)" +highT="$(expr 98 - "$step")" +r=9 +radd=true +g=35 +gadd=false +b=68 +badd=true + +rand(){ + # rand [num] makes $rand into a random number between 0 & that number + num="$( grep -m 1 'MHz' /proc/cpuinfo | awk -F '.' '{print $2}' )" + rand="$( expr $num % "$( expr $1 + 1 )" )" +} + +randomise(){ + # randomise red + if [ "$r" -gt "$highT" ]; then + radd=false + elif [ "$r" -lt "$lowT" ]; then + radd=true + fi + + if [ "$radd" = 'true' ]; then + rand 4 + r="$( expr "$r" + "$rand" )" + elif [ "$radd" = 'false' ]; then + rand 4 + r="$( expr "$r" - "$rand" )" + fi + + # randomise blue + if [ "$b" -gt "$highT" ]; then + badd=false + elif [ "$b" -lt "$lowT" ]; then + badd=true + fi + + if [ "$badd" = 'true' ]; then + rand 4 + b="$( expr "$b" + "$rand" )" + elif [ "$badd" = 'false' ]; then + rand 4 + b="$( expr "$b" - "$rand" )" + fi + + # randomise green + if [ "$g" -gt "$highT" ]; then + gadd=false + elif [ "$g" -lt "$lowT" ]; then + gadd=true + fi + + if [ "$gadd" = 'true' ]; then + rand 4 + g="$( expr "$g" + "$rand" )" + elif [ "$gadd" = 'false' ]; then + rand 4 + g="$( expr "$g" - "$rand" )" + fi +} + + +while true; do + randomise + + bspc config focused_border_color \#$r$g$b + sleep 0.05 +done diff --git a/bspwm/.config/bspwm/bspc-utils/trash/bspwm-resize b/bspwm/.config/bspwm/bspc-utils/trash/bspwm-resize @@ -0,0 +1,95 @@ +#!/bin/dash +# trying dash to see if its faster. +# maybe there is a premade script (definitaly) but +# oh well im not on internet for a week and I find it fun +# jacob edwards -- 09/01/2020 + +bspc query --nodes --node north +north=$? + +bspc query --nodes --node east +east=$? + +bspc query --nodes --node south +south=$? + +bspc query --nodes --node west +west=$? + +printf "N;$north\nE;$east\nS;$south\nW;$west" + + + +if [ "$north" -eq '0' ] && [ "$east" -eq '0' ] && [ "$west" -eq '0' ] && [ "$south" -ne '0' ]; then + #bspc node --resize bottom 0 50 + bspc node --resize left -50 0 + bspc node --resize top 0 -50 + bspc node --resize right 50 0 +elif [ "$north" -eq '0' ] && [ "$east" -eq '0' ] && [ "$west" -ne '0' ] && [ "$south" -eq '0' ]; then + bspc node --resize bottom 0 50 + #bspc node --resize left -50 0 + bspc node --resize top 0 -50 + bspc node --resize right 50 0 +elif [ "$north" -eq '0' ] && [ "$east" -ne '0' ] && [ "$west" -eq '0' ] && [ "$south" -eq '0' ]; then + bspc node --resize bottom 0 50 + bspc node --resize left -50 0 + #bspc node --resize top 0 -50 + bspc node --resize right 50 0 +elif [ "$north" -ne '0' ] && [ "$east" -eq '0' ] && [ "$west" -eq '0' ] && [ "$south" -eq '0' ]; then + bspc node --resize bottom 0 50 + bspc node --resize left -50 0 + bspc node --resize top 0 -50 + #bspc node --resize right 50 0 + + + +elif [ "$north" -eq '0' ] && [ "$east" -eq '0' ] && [ "$west" -ne '0' ] && [ "$south" -ne '0' ]; then + #bspc node --resize bottom 0 50 + #bspc node --resize left -50 0 + bspc node --resize top 0 -50 + bspc node --resize right 50 0 +elif [ "$north" -eq '0' ] && [ "$east" -ne '0' ] && [ "$west" -ne '0' ] && [ "$south" -eq '0' ]; then + #WORKS + bspc node --resize bottom 0 50 + #bspc node --resize left -50 0 + #bspc node --resize top 0 -50 + bspc node --resize right 50 0 +elif [ "$north" -ne '0' ] && [ "$east" -ne '0' ] && [ "$west" -eq '0' ] && [ "$south" -eq '0' ]; then + bspc node --resize bottom 0 50 + bspc node --resize left -50 0 + #bspc node --resize top 0 -50 + #bspc node --resize right 50 0 +elif [ "$north" -ne '0' ] && [ "$east" -eq '0' ] && [ "$west" -eq '0' ] && [ "$south" -ne '0' ]; then + #bspc node --resize bottom 0 50 + bspc node --resize left -50 0 + bspc node --resize top 0 -50 + #bspc node --resize right 50 0 + + + +elif [ "$north" -eq '0' ] && [ "$east" -ne '0' ] && [ "$west" -ne '0' ] && [ "$south" -ne '0' ]; then + #bspc node --resize bottom 0 50 + #bspc node --resize left -50 0 + #bspc node --resize top 0 -50 + bspc node --resize right 50 0 +elif [ "$north" -ne '0' ] && [ "$east" -ne '0' ] && [ "$west" -ne '0' ] && [ "$south" -eq '0' ]; then + bspc node --resize bottom 0 50 + #bspc node --resize left -50 0 + #bspc node --resize top 0 -50 + #bspc node --resize right 50 0 +elif [ "$north" -ne '0' ] && [ "$east" -ne '0' ] && [ "$west" -eq '0' ] && [ "$south" -ne '0' ]; then + #bspc node --resize bottom 0 50 + bspc node --resize left -50 0 + #bspc node --resize top 0 -50 + #bspc node --resize right 50 0 +elif [ "$north" -ne '0' ] && [ "$east" -eq '0' ] && [ "$west" -ne '0' ] && [ "$south" -ne '0' ]; then + #bspc node --resize bottom 0 50 + #bspc node --resize left -50 0 + bspc node --resize top 0 -50 + #bspc node --resize right 50 0 +elif [ "$north" -eq '0' ] && [ "$east" -eq '0' ] && [ "$west" -eq '0' ] && [ "$south" -eq '0' ]; then + bspc node --resize bottom 0 50 + bspc node --resize left -50 0 + bspc node --resize top 0 -50 + bspc node --resize right 50 0 +fi diff --git a/bspwm/.config/bspwm/bspc-utils/trash/resize.fail b/bspwm/.config/bspwm/bspc-utils/trash/resize.fail @@ -0,0 +1,79 @@ +#!/bin/dash + +# get various geometry +getgeometry(){ + Xgeo="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' | awk -F 'x' '{print $1}' )" + Ygeo="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' | awk -F 'x' '{print $2}' )" +} + +nodeGeometry="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' )" +nodeX="$(printf "$nodeGeometry" | awk -F 'x' '{print $1}')" +nodeY="$(printf "$nodeGeometry" | awk -F 'x' '{print $2}')" + +monitorGeometry="$(xdotool getdisplaygeometry)" +monitorX="$(printf "$monitorGeometry" | awk '{print $1}' )" +monitorY="$(printf "$monitorGeometry" | awk '{print $2}' )" + + +Xpercent="$(expr $monitorX / 100)" +Ypercent="$(expr $monitorY / 100)" + +scaleX="$(expr $2 \* $Xpercent)" +scaleY="$(expr $1 \* $Ypercent)" + + +# true equals adding, false means subtracting +if [ "$nodeY" -lt "$scaleY" ]; then + stepsizeY="$(expr "$scaleY" - "$nodeY" / 10)" + Y=true +else + stepsizeY="$(expr "$nodeY" - "$scaleX" / 10)" + Y=false +fi + +if [ "$nodeX" -lt "$scaleX" ]; then + stepsizeX="$(expr "$scaleX" - "$nodeX" / 10)" + X=true +else + stepsizeX="$(expr "$nodeX" - "$scaleX" / 10)" + X=false +fi + +stepsizeX=4 +stepsizeY=8 +notify-send-replace "X:$stepsizeX\nY:$stepsizeY\n" + + +if [ "$Y" = 'true' ]; then # adding to node + while [ "$nodeY" -lt "$scaleY" ]; do + bspc node --resize top 0 "-$stepsizeY" + bspc node --resize bottom 0 "$stepsizeY" + nodeY="$( expr $nodeY + "$( expr "$stepsizeY" / 2 )" )" + sleep 0.01 + done & + +elif [ "$Y" = 'false' ]; then # subtracting + while [ "$nodeY" -gt "$scaleY" ]; do + bspc node --resize top 0 "$stepsizeY" + bspc node --resize bottom 0 "-$stepsizeY" + nodeY="$( expr $nodeY - "$( expr "$stepsizeY" / 2 )" )" + sleep 0.01 + done & +fi + +if [ "$X" = 'true' ]; then # adding + while [ "$nodeX" -lt "$scaleX" ]; do + bspc node --resize left "-$stepsizeX" 0 + bspc node --resize right "$stepsizeX" 0 + nodeX="$( expr $nodeX + "$( expr "$stepsizeX" / 2 )" )" + sleep 0.01 + done & + +elif [ "$X" = 'false' ]; then # subtracting + while [ "$nodeX" -gt "$scaleX" ]; do + bspc node --resize left "$stepsizeX" 0 + bspc node --resize right "-$stepsizeX" 0 + nodeX="$( expr $nodeX - "$( expr "$stepsizeX" / 2 )" )" + sleep 0.01 + done & +fi diff --git a/bspwm/.config/bspwm/bspc-utils/trash/resize.save.firstworking b/bspwm/.config/bspwm/bspc-utils/trash/resize.save.firstworking @@ -0,0 +1,72 @@ +#!/bin/dash + +# get various geometry +getgeometry(){ + Xgeo="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' | awk -F 'x' '{print $1}' )" + Ygeo="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' | awk -F 'x' '{print $2}' )" +} + +nodeGeometry="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' )" +nodeX="$(printf "$nodeGeometry" | awk -F 'x' '{print $1}')" +nodeY="$(printf "$nodeGeometry" | awk -F 'x' '{print $2}')" + +monitorGeometry="$(xdotool getdisplaygeometry)" +monitorX="$(printf "$monitorGeometry" | awk '{print $1}' )" +monitorY="$(printf "$monitorGeometry" | awk '{print $2}' )" + + +Xpercent="$(expr $monitorX / 100)" +Ypercent="$(expr $monitorY / 100)" + +scaleX="$(expr $2 \* $Xpercent)" +scaleY="$(expr $1 \* $Ypercent)" + + +# true equals adding, false means subtracting +if [ "$nodeY" -lt "$scaleY" ]; then + Y=true +else + Y=false +fi + +if [ "$nodeX" -lt "$scaleX" ]; then + X=true +else + X=false +fi + + + +if [ "$Y" = 'true' ]; then # adding to node + while [ "$nodeY" -lt "$scaleY" ]; do + bspc node --resize top 0 -10 + bspc node --resize bottom 0 10 + nodeY="$(expr $nodeY + 20)" + #sleep 0.1 + done & + +elif [ "$Y" = 'false' ]; then # subtracting + while [ "$nodeY" -gt "$scaleY" ]; do + bspc node --resize top 0 10 + bspc node --resize bottom 0 -10 + nodeY="$(expr $nodeY - 20)" + #sleep 0.1 + done & +fi + +if [ "$X" = 'true' ]; then # adding + while [ "$nodeX" -lt "$scaleX" ]; do + bspc node --resize left -10 0 + bspc node --resize right 10 0 + nodeX="$(expr $nodeX + 20)" + #sleep 0.1 + done & + +elif [ "$X" = 'false' ]; then # subtracting + while [ "$nodeX" -gt "$scaleX" ]; do + bspc node --resize left 10 0 + bspc node --resize right -10 0 + nodeX="$(expr $nodeX - 20)" + #sleep 0.1 + done & +fi diff --git a/bspwm/.config/bspwm/bspc-utils/unpolished/resize b/bspwm/.config/bspwm/bspc-utils/unpolished/resize @@ -0,0 +1,76 @@ +#!/bin/dash + +# get various geometry +getgeometry(){ + Xgeo="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' | awk -F 'x' '{print $1}' )" + Ygeo="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' | awk -F 'x' '{print $2}' )" +} + +nodeGeometry="$(xdotool getwindowgeometry "$(xdotool getactivewindow)" | tail -n 1 | awk '{print $2}' )" +nodeX="$(printf "$nodeGeometry" | awk -F 'x' '{print $1}')" +nodeY="$(printf "$nodeGeometry" | awk -F 'x' '{print $2}')" + +monitorGeometry="$(xdotool getdisplaygeometry)" +monitorX="$(printf "$monitorGeometry" | awk '{print $1}' )" +monitorY="$(printf "$monitorGeometry" | awk '{print $2}' )" + + +Xpercent="$(expr $monitorX / 100)" +Ypercent="$(expr $monitorY / 100)" + +scaleX="$(expr $2 \* $Xpercent)" +scaleY="$(expr $1 \* $Ypercent)" + + +# true equals adding, false means subtracting +if [ "$nodeY" -lt "$scaleY" ]; then + Y=true +else + Y=false +fi + +if [ "$nodeX" -lt "$scaleX" ]; then + X=true +else + X=false +fi + +Xstep=32 +Ystep=18 +delay=0.03 + +if [ "$Y" = 'true' ]; then # adding to node + while [ "$nodeY" -lt "$scaleY" ]; do + bspc node --resize top 0 -$Ystep + bspc node --resize bottom 0 $Ystep + nodeY="$(expr $nodeY + "$(expr $Ystep \* 2)" )" + sleep "$delay" + done & + +elif [ "$Y" = 'false' ]; then # subtracting + while [ "$nodeY" -gt "$scaleY" ]; do + bspc node --resize top 0 $Ystep + bspc node --resize bottom 0 -$Ystep + nodeY="$(expr $nodeY - "$(expr $Ystep \* 2)" )" + sleep "$delay" + done & +fi + +if [ "$X" = 'true' ]; then # adding + while [ "$nodeX" -lt "$scaleX" ]; do + bspc node --resize left -$Xstep 0 + bspc node --resize right $Xstep 0 + nodeX="$(expr $nodeX + "$(expr $Xstep \* 2)" )" + sleep "$delay" + done & + +elif [ "$X" = 'false' ]; then # subtracting + while [ "$nodeX" -gt "$scaleX" ]; do + bspc node --resize left $Xstep 0 + bspc node --resize right -$Xstep 0 + nodeX="$(expr $nodeX - "$(expr $Xstep \* 2)" )" + sleep "$delay" + done & +fi + +wait