Plans for the next bspwm edition release

Okay, this is slightly better:

#!/bin/bash
#intented to allow resizing bspwm windows by dragging them from window gap. Requires rootmenu

eval $(xdotool getmouselocation --shell)
IFS=" " read -a window <<< $(wattr whxy $(bspc query -N -n focused))

# location of each side of focused window
miny=$(expr "${window[3]}" + 20)
maxy=$(expr "${window[3]}" + "${window[1]}" - 20)
minx=$(expr "${window[2]}" + 20)
maxx=$(expr "${window[2]}" + "${window[0]}" - 20)

# set final position to current or at most within window
XP=$X
[[ $XP -gt $maxx ]] && XP=$maxx
[[ $XP -lt $minx ]] && XP=$minx
YP=$Y
[[ $YP -lt $miny ]] && YP=$miny
[[ $YP -gt $maxy ]] && YP=$maxy

for	win in $(lsw); do
	xdotool behave $win mouse-enter keyup super mouseup 3 exec pkill xdotool &
	xdotool behave $win mouse-leave keyup super mouseup 3 exec pkill xdotool &
done
# move mouse just inside the focused window and initiate resize combination for 2 seconds
xdotool mousemove --sync $XP $YP keydown super mousedown 3

#sleep 2 && xdotool keyup super mouseup 3

It spawns a crapton of xdotools to watch if mouse leaves or enters any window. However, once in 6 tries or so one of the xdotools kills the others before the task is completed, and super key is left down. So, not ideal.

This is the best thusfar:

#!/bin/bash
#intented to allow resizing bspwm windows by dragging them from window gap. Requires rootmenu

eval $(xdotool getmouselocation --shell)
IFS=" " read -a window <<< $(wattr whxy $(bspc query -N -n focused))

# location of each side of focused window
miny=$(expr "${window[3]}" + 20)
maxy=$(expr "${window[3]}" + "${window[1]}" - 20)
minx=$(expr "${window[2]}" + 20)
maxx=$(expr "${window[2]}" + "${window[0]}" - 20)

# set final position to current or at most within window
XP=$X
[[ $XP -gt $maxx ]] && XP=$maxx
[[ $XP -lt $minx ]] && XP=$minx
YP=$Y
[[ $YP -lt $miny ]] && YP=$miny
[[ $YP -gt $maxy ]] && YP=$maxy

#for	win in $(lsw); do
#	xdotool behave $win mouse-enter keyup super mouseup 3 exec pkill xdotool &
#	xdotool behave $win mouse-leave keyup super mouseup 3 exec pkill xdotool &
#done
# move mouse just inside the focused window and initiate resize combination for 2 seconds
xdotool mousemove --sync $XP $YP keydown super mousedown 3

#MOUSE_ID=$(xinput --list | grep -i -m 1 'touchpad' | grep -o 'id=[0-9]\+' | grep -o '[0-9]\+')

listenbuttonrelease.sh

listenbuttonrelease.sh:

#!/bin/bash

MOUSE_ID=$(xinput --list | grep -i -m 1 'touchpad' | grep -o 'id=[0-9]\+' | grep -o '[0-9]\+')

STATE1=$(xinput --query-state $MOUSE_ID | grep 'button\[' | sort)
while true; do
    sleep 0.1
    xinput --query-state 14 | grep -q 'button\[1\]=up'&& xdotool keyup super mouseup 3 && exit
done

However, this is dependent on the device identifies, so it would need to be dublicated for mouses.

Finally:

#!/bin/bash
#intented to allow resizing bspwm windows by dragging them from window gap. Requires rootmenu

eval $(xdotool getmouselocation --shell)
IFS=" " read -a window <<< $(wattr whxy $(bspc query -N -n focused))

# location of each side of focused window
miny=$(expr "${window[3]}" + 20)
maxy=$(expr "${window[3]}" + "${window[1]}" - 20)
minx=$(expr "${window[2]}" + 20)
maxx=$(expr "${window[2]}" + "${window[0]}" - 20)

# set final position to current or at most within window
XP=$X
[[ $XP -gt $maxx ]] && XP=$maxx
[[ $XP -lt $minx ]] && XP=$minx
YP=$Y
[[ $YP -lt $miny ]] && YP=$miny
[[ $YP -gt $maxy ]] && YP=$maxy

buttonrelease() {
	PAD_ID=$(xinput --list | grep -i -m 1 'touchpad' | grep -o 'id=[0-9]\+' | grep -o '[0-9]\+')
	MOUSE_ID=$(xinput --list | grep -i -m 1 'mouse' | grep -o 'id=[0-9]\+' | grep -o '[0-9]\+')
	
	STATE1=$(xinput --query-state $PAD_ID | grep 'button\[' | sort)
	while true; do
	    sleep 0.1
	    xinput --query-state $PAD_ID | grep -q 'button\[1\]=up'&& xdotool keyup super mouseup 3 && exit
	    xinput --query-state $MOUSE_ID | grep -q 'button\[1\]=up'&& xdotool keyup super mouseup 3 && exit
	done
}
xdotool mousemove --sync $XP $YP keydown super mousedown 3

buttonrelease

https://youtu.be/b36yB_rGsW4

Showing gapdrag and general mouse controls in bspwm. @c00ter, tilers can be used with mouse too :slight_smile:

3 Likes

I just figured out, that conky breaks script DidIClickDesktop.sh because lsw lists conky window id first and desktop window id second, but xdotool getmouselocation ignores conky and gives desktop window id. This occurs when conky config has own_window_type = 'desktop'. So I guess it results in two desktop windows at the same time and conky is the lowest of them.
I tried other conky window types and found, that override doesn't work with bspwm, dock and panel show conky over other windows, normal makes conky into normal window, but it is not what I want. Adding own_window_hints = 'below' did not help either.
So at the moment root menu and gap grab don't work with conky. Maybe there is a way to get desktop window id not with lsw? Or somehow sort out what desktop window is really desktop and what is conky window.

EDIT. I can "fix" it if I run
xdotool search --class "conky" set_window --overrideredirect 1 %@
But if conky restarts or refreshes config, it is broken again.

Maybe I should make the script take conky into account... Problem is that since it is run on every mouse click, it needs to be very efficient.

Maybe, I never got to the bottom of this. I just used xcape / xmodmap to use the menu key and wrote a menu to call the other menus.

Can I limit conky to one desktop? Then I could click for menus on another desktop.

A script that checks if you clicked on a window of the class Conky.

Hmm... Does the root window have consistent class? We could check the class and use case statement, including conky, xfdesktop and plain root window. That would be fast enough.

This hack works even if there are more than one conky

rootwindowid=$(($(lsw | sed -n "$(($(xdotool search --class conky|wc -l)+1))p")))
1 Like

Genius!!!!!! Confirmed working here.

And this one works too

rootwindowid=$(($(lsw|grep -v -F "$(xdotool search --class conky|xargs printf '0x%08x\n')"|head -n 1)))

Thanks, I'll do some testing. Us it fast enough? Xdotool search is usually a bit ponderous.

It is quie fast, about 0.015 - 0.020 seconds on my laptop, both variants almost the same.

Is there a better way to look up window class and id?

for class i've been using xprop | grep WM_CLASS. maybe something similar can be done for id?

1 Like

Using xprop I've learnt that desktop has "Bspwm" class, so this line also works and is faster, 0.007 - 0.012 s:

rootwindowid=$(xdotool search --class Bspwm|head -n 1)

I think it will work, because first line is the window at the bottom. man xdotool:

Note that the order of windows in the window stack corresponds to the window stacking order, i.e. the bottom-most window will be reported first

1 Like

Yep, it seems to work and is only 0.002-0.003 seconds slower than the current implementation. That seems quite acceptable.

Maybe this is a bit faster, 0.004-0.012 s.

#!/bin/dash
eval $(xdotool getmouselocation --shell)
[ $WINDOW = $(xdotool search --limit 1 --class Bspwm) ]
1 Like

There is an unusual behavior with gapgrab: when I left-click on empty desktop (with no windows), cursor jumps to the upper left corner of the screen. It might prove handy, because I can quicly open panel menu with the second click, it is just a bit unexpected.

EDIT. Maybe add a check if there is any focused window to prevent this behavior?

focused="$(bspc query -N -n focused)"; [ "$focused" ] || exit
IFS=" " read -a window <<< $(wattr whxy $focused)

Forum kindly sponsored by