2020-04-07 16:05:34 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
wid=$1
|
|
|
|
class=$2
|
|
|
|
instance=$3
|
|
|
|
consequences=$4
|
|
|
|
|
|
|
|
title=$(xtitle "$wid")
|
2021-02-10 16:25:44 +00:00
|
|
|
role="$(xprop -id "$wid" WM_WINDOW_ROLE | awk -F '"' '{print $2}')"
|
2022-08-16 12:49:36 +00:00
|
|
|
parent_id="$(xprop -id "$wid" WM_TRANSIENT_FOR | awk -F '# ' '{print $2}')"
|
|
|
|
|
|
|
|
# notify-send $1 "$2 | $3 | $4"
|
|
|
|
|
|
|
|
# put child windows in center of parent window instead of desktop center
|
|
|
|
if [ -n "$parent_id" ] ; then
|
|
|
|
parent_class="$(xprop -id "$parent_id" WM_CLASS | awk -F '"' '{print $2}')"
|
|
|
|
|
2022-08-18 09:13:39 +00:00
|
|
|
if [ "$parent_class" = gimp ] ; then
|
|
|
|
parent_x="$(xdotool getwindowgeometry --shell $parent_id | grep X | awk -F '=' '{print $2}')"
|
|
|
|
parent_y="$(xdotool getwindowgeometry --shell $parent_id | grep Y | awk -F '=' '{print $2}')"
|
|
|
|
|
|
|
|
x="$((parent_x + 20))"
|
|
|
|
y="$((parent_y + 20))"
|
|
|
|
|
|
|
|
# without an echo, the xdotool command will not work.
|
|
|
|
# it appears that xdotool runs before the window is created if no echo is used.
|
|
|
|
# using a sleep command instead of echo just causes a delay in the window opening.
|
|
|
|
# so it appears the output to stdout (or whatever) causes bspwm to open the window
|
|
|
|
echo ""
|
|
|
|
xdotool windowmove "$wid" "$x" "$y"
|
|
|
|
exit
|
|
|
|
|
|
|
|
# notify-send $parent_id "$parent_class | $parent_x , $parent_y | $parent_width x $parent_height"
|
|
|
|
# notify-send $wid "$width x $height"
|
|
|
|
# (sleep 2 ; notify-send $wid "xdotool windowmove --sync $wid $x $y") &
|
|
|
|
fi
|
|
|
|
|
2022-08-16 12:49:36 +00:00
|
|
|
if [ "$parent_class" = chromium ] ; then
|
|
|
|
parent_x="$(xdotool getwindowgeometry --shell $parent_id | grep X | awk -F '=' '{print $2}')"
|
|
|
|
parent_y="$(xdotool getwindowgeometry --shell $parent_id | grep Y | awk -F '=' '{print $2}')"
|
|
|
|
parent_width="$(xdotool getwindowgeometry --shell $parent_id | grep WIDTH | awk -F '=' '{print $2}')"
|
|
|
|
parent_height="$(xdotool getwindowgeometry --shell $parent_id | grep HEIGHT | awk -F '=' '{print $2}')"
|
|
|
|
|
|
|
|
width="$(xdotool getwindowgeometry --shell $wid | grep WIDTH | awk -F '=' '{print $2}')"
|
|
|
|
height="$(xdotool getwindowgeometry --shell $wid | grep HEIGHT | awk -F '=' '{print $2}')"
|
|
|
|
|
|
|
|
x="$((parent_x + parent_width / 2 - width / 2))"
|
|
|
|
y="$((parent_y + parent_height / 2 - height / 2))"
|
|
|
|
|
|
|
|
# without an echo, the xdotool command will not work.
|
|
|
|
# it appears that xdotool runs before the window is created if no echo is used.
|
|
|
|
# using a sleep command instead of echo just causes a delay in the window opening.
|
|
|
|
# so it appears the output to stdout (or whatever) causes bspwm to open the window
|
|
|
|
echo ""
|
|
|
|
xdotool windowmove "$wid" "$x" "$y"
|
|
|
|
exit
|
|
|
|
|
|
|
|
# notify-send $parent_id "$parent_class | $parent_x , $parent_y | $parent_width x $parent_height"
|
|
|
|
# notify-send $wid "$width x $height"
|
|
|
|
# (sleep 2 ; notify-send $wid "xdotool windowmove --sync $wid $x $y") &
|
|
|
|
fi
|
|
|
|
fi
|
2020-04-11 16:28:12 +00:00
|
|
|
|
2021-02-10 16:25:44 +00:00
|
|
|
if [ $class = "Thunderbird" ] && [ $role = "messageWindow" ] || [ $role = "Msgcompose" ] ; then
|
|
|
|
echo "state=floating"
|
2021-10-07 09:54:41 +00:00
|
|
|
echo "rectangle=1080x868+0+800"
|
2021-02-10 16:25:44 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-10-07 09:54:41 +00:00
|
|
|
if [ $class = "Surf" ] ; then
|
|
|
|
echo "state=floating"
|
2021-11-21 12:35:43 +00:00
|
|
|
echo "follow=on"
|
2021-10-07 09:54:41 +00:00
|
|
|
echo "rectangle=1080x868+0+700"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-10-07 09:56:35 +00:00
|
|
|
# notify-send "$title" "$1 | class: '$2' | instance: '$3' | $4 | role: '$role'"
|
2020-04-07 16:05:34 +00:00
|
|
|
|
2020-12-30 12:07:04 +00:00
|
|
|
#place floating windows
|
|
|
|
#adapted from https://github.com/baskerville/bspwm/issues/263
|
2022-08-16 12:49:36 +00:00
|
|
|
# floats=$(bspc query -N -n .floating -d .focused | wc -l)
|
|
|
|
# if [ $floats -gt 0 ] ; then
|
|
|
|
# echo ""
|
|
|
|
# xdotool windowmove --relative $wid $(( 50 * floats )) $(( 50 * floats ))
|
|
|
|
# why does --relative option not work?
|
|
|
|
# notify-send $floats "xdotool windowmove --relative $wid $(( 50 * floats )) $(( 50 * floats ))"
|
|
|
|
# exit
|
|
|
|
# fi
|
2020-12-30 12:07:04 +00:00
|
|
|
|
2021-02-10 16:25:44 +00:00
|
|
|
case "$role" in
|
2021-05-31 15:33:53 +00:00
|
|
|
messageWindow)
|
|
|
|
echo "state=floating"
|
|
|
|
;;
|
2020-04-07 16:05:34 +00:00
|
|
|
WM_FORCE_FLOATING)
|
|
|
|
echo "state=floating"
|
|
|
|
;;
|
2020-10-27 12:45:23 +00:00
|
|
|
WM_FORCE_TILED)
|
|
|
|
echo "state=tiled"
|
|
|
|
;;
|
2020-04-07 16:05:34 +00:00
|
|
|
WM_FORCE_FULLSCREEN)
|
|
|
|
echo "state=fullscreen"
|
|
|
|
;;
|
|
|
|
esac
|
2020-12-30 12:07:04 +00:00
|
|
|
|
|
|
|
# case $state in
|
|
|
|
# floating)
|
|
|
|
# if [ -z "$desktop" ] || [ "$desktop" = "$(bspc query -D -d --names)" ] && [ -z "$rectangle" ]; then
|
|
|
|
# rule="${rule}$(centerfloat) center=false "
|
|
|
|
# fi
|
|
|
|
# ;;
|
|
|
|
# esac
|