From e1c262230145acd259aa26a084247c2a6dadc3a3 Mon Sep 17 00:00:00 2001 From: noctuid Date: Fri, 29 Apr 2016 03:14:08 -0400 Subject: [PATCH] Update to support bspwm 0.9.1 - Fix floating rules - Fix is_floating (for auto_hide and auto_show) - Fix for -m option --- tdrop | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tdrop b/tdrop index cbd7f16..3e48bfb 100755 --- a/tdrop +++ b/tdrop @@ -181,6 +181,11 @@ update_geometry_settings_for_monitor() { wm=$(get_window_manager) if [[ $wm == bspwm ]]; then current_monitor=$(bspc query -m -M) + # newest bspwm version retuns an id instead of the name + if [[ $current_monitor =~ ^0x ]]; then + current_monitor=$(bspc query -T -m | grep -Po '^{"name":.*?",' | \ + awk -F ":" '{gsub("[\",]", ""); print $2}') + fi elif [[ $wm == i3 ]]; then # I'd rather not make jq a dependency current_monitor=$(i3-msg -t get_workspaces | sed 's/{"num"/\n/g' | \ @@ -274,9 +279,18 @@ wm_autoset_for_all() { # bspwm will use previous size when floating already if [[ $wm == bspwm ]]; then map_pre() { - bspc rule -a "$1" -o state=floating - # maintain compatability with old syntax - bspc rule -a "$1" -o floating=on + # newest (using "instance" names) + if [[ $(bspwm -v) =~ ^0.9.1 ]]; then + if [[ $1 =~ [A-Z] ]]; then + bspc rule -a "$1" -o state=floating + else + bspc rule -a \*:"$1" -o state=floating + fi + else + # compatability with older syntaxes + bspc rule -a "$1" -o state=floating + bspc rule -a "$1" -o floating=on + fi } elif [[ $wm == awesome ]]; then # awesome remembers size, but need to float and then set size first @@ -313,7 +327,8 @@ wm_autoset_for_hide_show() { is_floating() { # checking if the window id (converted from decimal to hex) is floating; empty if not floating bspc query -T | grep -i "$(printf 0x%x "$1").*f-" || \ - bspc query -T -w | grep '"state": "floating"' + bspc query -T -w | grep '"state": "floating"' || \ + bspc query -T -n | grep '"state":"floating"' } elif [[ $wm == i3 ]]; then subtract_when_same=false