#!/bin/sh wid=$1 class=$2 instance=$3 consequences=$4 title=$(xtitle "$wid") role="$(xprop -id "$wid" WM_WINDOW_ROLE | awk -F '"' '{print $2}')" 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}')" 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 if [ $class = "Thunderbird" ] && [ $role = "messageWindow" ] || [ $role = "Msgcompose" ] ; then echo "state=floating" echo "rectangle=1080x868+0+800" exit fi if [ $class = "Surf" ] ; then echo "state=floating" echo "follow=on" echo "rectangle=1080x868+0+700" exit fi # notify-send "$title" "$1 | class: '$2' | instance: '$3' | $4 | role: '$role'" #place floating windows #adapted from https://github.com/baskerville/bspwm/issues/263 # 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 case "$role" in messageWindow) echo "state=floating" ;; WM_FORCE_FLOATING) echo "state=floating" ;; WM_FORCE_TILED) echo "state=tiled" ;; WM_FORCE_FULLSCREEN) echo "state=fullscreen" ;; esac # case $state in # floating) # if [ -z "$desktop" ] || [ "$desktop" = "$(bspc query -D -d --names)" ] && [ -z "$rectangle" ]; then # rule="${rule}$(centerfloat) center=false " # fi # ;; # esac