|
|
@ -146,25 +146,44 @@ update_geometry_settings_for_monitor() {
|
|
|
|
# monitor IF the monitor has changed since the last time the dropdown
|
|
|
|
# monitor IF the monitor has changed since the last time the dropdown
|
|
|
|
# was used
|
|
|
|
# was used
|
|
|
|
|
|
|
|
|
|
|
|
# determine curent monitor
|
|
|
|
# it is conceivable that a user may want to use -m but not -a, so
|
|
|
|
wininfo=$(xwininfo -id "$(xdotool getactivewindow)")
|
|
|
|
# get the wm from with
|
|
|
|
window_x=$(echo "$wininfo" | awk '/Absolute.*X/ {print $4}')
|
|
|
|
# in this function
|
|
|
|
window_y=$(echo "$wininfo" | awk '/Absolute.*Y/ {print $4}')
|
|
|
|
wm=$(get_window_manager)
|
|
|
|
monitors_info=$(xrandr --query | awk '/ connected/ {gsub("primary ",""); print}')
|
|
|
|
if [[ $wm == bspwm ]]; then
|
|
|
|
while read -r monitor; do
|
|
|
|
current_monitor=$(bspc query -m -M)
|
|
|
|
monitor_geo=$(echo "$monitor" | awk '{print $3}')
|
|
|
|
elif [[ $wm == i3 ]]; then
|
|
|
|
|
|
|
|
# I'd rather not make jq a dependency
|
|
|
|
|
|
|
|
current_monitor=$(i3-msg -t get_workspaces | sed 's/{"num"/\n/g' | awk -F ',' '/focused":true/ {sub(".*output",""); gsub("[:\"]",""); print $1}')
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -n $current_monitor ]]; then
|
|
|
|
|
|
|
|
monitor_geo=$(xrandr --query | awk "/$current_monitor/ {gsub(\"primary \",\"\"); print \$3}")
|
|
|
|
x_begin=$(echo "$monitor_geo" | awk -F '+' '{print $2}')
|
|
|
|
x_begin=$(echo "$monitor_geo" | awk -F '+' '{print $2}')
|
|
|
|
y_begin=$(echo "$monitor_geo" | awk -F '+' '{print $3}')
|
|
|
|
y_begin=$(echo "$monitor_geo" | awk -F '+' '{print $3}')
|
|
|
|
x_width=$(echo "$monitor_geo" | awk -F 'x' '{print $1}')
|
|
|
|
x_width=$(echo "$monitor_geo" | awk -F 'x' '{print $1}')
|
|
|
|
y_height=$(echo "$monitor_geo" | awk -F 'x|+' '{print $2}')
|
|
|
|
y_height=$(echo "$monitor_geo" | awk -F 'x|+' '{print $2}')
|
|
|
|
x_end=$((x_begin+x_width))
|
|
|
|
else
|
|
|
|
y_end=$((y_begin+y_height))
|
|
|
|
# determine current monitor in generic (hacky) way
|
|
|
|
if [[ $window_x -ge $x_begin ]] && [[ $window_x -lt $x_end ]] && \
|
|
|
|
wininfo=$(xwininfo -id "$(xdotool getactivewindow)")
|
|
|
|
[[ $window_y -ge $y_begin ]] && [[ $window_y -lt $y_end ]]; then
|
|
|
|
window_x=$(echo "$wininfo" | awk '/Absolute.*X/ {print $4}')
|
|
|
|
current_monitor=$(echo "$monitor" | awk '{print $1}')
|
|
|
|
window_y=$(echo "$wininfo" | awk '/Absolute.*Y/ {print $4}')
|
|
|
|
break
|
|
|
|
monitors_info=$(xrandr --query | awk '/ connected/ {gsub("primary ",""); print}')
|
|
|
|
fi
|
|
|
|
while read -r monitor; do
|
|
|
|
done <<< "$monitors_info"
|
|
|
|
monitor_geo=$(echo "$monitor" | awk '{print $3}')
|
|
|
|
|
|
|
|
x_begin=$(echo "$monitor_geo" | awk -F '+' '{print $2}')
|
|
|
|
|
|
|
|
y_begin=$(echo "$monitor_geo" | awk -F '+' '{print $3}')
|
|
|
|
|
|
|
|
x_width=$(echo "$monitor_geo" | awk -F 'x' '{print $1}')
|
|
|
|
|
|
|
|
y_height=$(echo "$monitor_geo" | awk -F 'x|+' '{print $2}')
|
|
|
|
|
|
|
|
x_end=$((x_begin+x_width))
|
|
|
|
|
|
|
|
y_end=$((y_begin+y_height))
|
|
|
|
|
|
|
|
if [[ $window_x -ge $x_begin ]] && [[ $window_x -lt $x_end ]] && \
|
|
|
|
|
|
|
|
[[ $window_y -ge $y_begin ]] && [[ $window_y -lt $y_end ]]; then
|
|
|
|
|
|
|
|
current_monitor=$(echo "$monitor" | awk '{print $1}')
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done <<< "$monitors_info"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# update x and y offsets, so that will appear on correct screen
|
|
|
|
# update x and y offsets, so that will appear on correct screen
|
|
|
|
# (required for some WMs apparently, but not for others)
|
|
|
|
# (required for some WMs apparently, but not for others)
|
|
|
|