diff --git a/tdrop b/tdrop index 336ade0..76903d4 100755 --- a/tdrop +++ b/tdrop @@ -101,70 +101,70 @@ name= while getopts :h:w:x:y:s:n:c:C:l:L:p:P:u:U:d:f:-:amt opt do case $opt in - h) height=$OPTARG;; - w) width=$OPTARG;; - x) xoff=$OPTARG;; - y) yoff=$OPTARG;; - s) session_name=$OPTARG;; - n) num=$OPTARG;; - c) pre_create=$OPTARG;; - C) post_create=$OPTARG;; - l) pre_float=$OPTARG;; - L) post_float=$OPTARG;; - p) pre_map=$OPTARG;; - P) post_map=$OPTARG;; - u) pre_unmap=$OPTARG;; - U) post_unmap=$OPTARG;; - d) dec_fix=$OPTARG;; - S) subtract_when_same=false;; - i) is_floating=$OPTARG;; - f) program_flags=$OPTARG;; - a) auto_detect_wm=true;; - m) monitor_aware=true;; - t) pointer_monitor_detection=true;; - -) - if [[ $OPTARG =~ ^(auto-detect-wm|monitor-aware|pointer-monitor-detection|clear|no-cancel|help)$ ]] || \ - [[ $OPTARG == *=* ]]; then - OPTION=${OPTARG%%=*} - OPTARG=${OPTARG#*=} - else - OPTION=$OPTARG - # shellcheck disable=SC2124 - OPTARG=${@:$OPTIND:1} - ((OPTIND++)) - fi - case $OPTION in - height) height=$OPTARG;; - width) width=$OPTARG;; - x-offset) xoff=$OPTARG;; - y-offset) yoff=$OPTARG;; - session) session_name=$OPTARG;; - number) num=$OPTARG;; - pre-create-hook) pre_create=$OPTARG;; - post-create-hook) post_create=$OPTARG;; - pre-map-float-command) pre_float=$OPTARG;; - post-map-float-command) post_float=$OPTARG;; - pre-map-hook) pre_map=$OPTARG;; - post-map-hook) post_map=$OPTARG;; - pre-unmap-hook) pre_unmap=$OPTARG;; - post-unmap-hook) post_unmap=$OPTARG;; - decoration-fix) dec_fix=$OPTARG;; - no-subtract-when-same) subtract_when_same=false;; - is-floating) is_floating=$OPTARG;; - program-flags) program_flags=$OPTARG;; - auto-detect-wm) auto_detect_wm=true;; - monitor-aware) monitor_aware=true;; - pointer-monitor-detection) pointer_monitor_detection=true;; - wm) wm=$OPTARG - user_set_wm=true;; - class) class=$OPTARG;; - name) name=$OPTARG;; - clear) clearwid=true;; - no-cancel) cancel_auto_show=false;; - help) print_help;; + h) height=$OPTARG;; + w) width=$OPTARG;; + x) xoff=$OPTARG;; + y) yoff=$OPTARG;; + s) session_name=$OPTARG;; + n) num=$OPTARG;; + c) pre_create=$OPTARG;; + C) post_create=$OPTARG;; + l) pre_float=$OPTARG;; + L) post_float=$OPTARG;; + p) pre_map=$OPTARG;; + P) post_map=$OPTARG;; + u) pre_unmap=$OPTARG;; + U) post_unmap=$OPTARG;; + d) dec_fix=$OPTARG;; + S) subtract_when_same=false;; + i) is_floating=$OPTARG;; + f) program_flags=$OPTARG;; + a) auto_detect_wm=true;; + m) monitor_aware=true;; + t) pointer_monitor_detection=true;; + -) + if [[ $OPTARG =~ ^(auto-detect-wm|monitor-aware|pointer-monitor-detection|clear|no-cancel|help)$ ]] || \ + [[ $OPTARG == *=* ]]; then + OPTION=${OPTARG%%=*} + OPTARG=${OPTARG#*=} + else + OPTION=$OPTARG + # shellcheck disable=SC2124 + OPTARG=${@:$OPTIND:1} + ((OPTIND++)) + fi + case $OPTION in + height) height=$OPTARG;; + width) width=$OPTARG;; + x-offset) xoff=$OPTARG;; + y-offset) yoff=$OPTARG;; + session) session_name=$OPTARG;; + number) num=$OPTARG;; + pre-create-hook) pre_create=$OPTARG;; + post-create-hook) post_create=$OPTARG;; + pre-map-float-command) pre_float=$OPTARG;; + post-map-float-command) post_float=$OPTARG;; + pre-map-hook) pre_map=$OPTARG;; + post-map-hook) post_map=$OPTARG;; + pre-unmap-hook) pre_unmap=$OPTARG;; + post-unmap-hook) post_unmap=$OPTARG;; + decoration-fix) dec_fix=$OPTARG;; + no-subtract-when-same) subtract_when_same=false;; + is-floating) is_floating=$OPTARG;; + program-flags) program_flags=$OPTARG;; + auto-detect-wm) auto_detect_wm=true;; + monitor-aware) monitor_aware=true;; + pointer-monitor-detection) pointer_monitor_detection=true;; + wm) wm=$OPTARG + user_set_wm=true;; + class) class=$OPTARG;; + name) name=$OPTARG;; + clear) clearwid=true;; + no-cancel) cancel_auto_show=false;; + help) print_help;; + *) print_help illegal_opt;; + esac;; *) print_help illegal_opt;; - esac;; - *) print_help illegal_opt;; esac done shift "$((OPTIND-1))" @@ -180,7 +180,7 @@ fi if [[ $# -ne 1 ]]; then echo >&2 "Exactly 1 positional argument is required." \ - "For help use -h or --help or see the manpage." | \ + "For help use -h or --help or see the manpage." | \ tee -a "$MUTDROP_PATH"/log exit 1 fi @@ -193,7 +193,7 @@ if [[ ! $height$width$xoff$yoff =~ ^[0-9%-]*$ ]]; then fi if [[ -n $dec_fix ]] && [[ ! $dec_fix =~ ^-?[0-9]+x-?[0-9]+$ ]]; then echo >&2 "The decoration fix value must have form 'num'x'num'." \ - "The numbers can be negative or zero." | tee -a "$MUTDROP_PATH"/log + "The numbers can be negative or zero." | tee -a "$MUTDROP_PATH"/log exit 1 fi @@ -269,7 +269,7 @@ update_geometry_settings_for_monitor() { # TODO use jq if installed # I'd rather not make jq a dependency current_monitor=$(i3-msg -t get_workspaces | sed 's/{"num"/\n/g' | \ - gawk -F ',' '/focused":true/ {sub(".*output",""); gsub("[:\"]",""); print $1}') + gawk -F ',' '/focused":true/ {sub(".*output",""); gsub("[:\"]",""); print $1}') fi local monitor_geo x_begin y_begin x_width y_height @@ -327,7 +327,7 @@ update_geometry_settings_for_monitor() { map_and_reset_geometry() { xdotool windowmap "$wid" windowmove "$wid" "$xoff" "$yoff" \ - windowsize "$wid" "$width" "$height" 2> /dev/null + windowsize "$wid" "$width" "$height" 2> /dev/null } # * WM Detection and Hooks @@ -579,7 +579,7 @@ create_win_return_wid() { if [[ -n "$wids" ]]; then while read -r wid; do if [[ ! $blacklist =~ (^|$'\n')"$wid"($|$'\n') ]] && \ - [[ $(get_visibility "$wid") == IsViewable ]]; then + [[ $(get_visibility "$wid") == IsViewable ]]; then visible_wid=true program_wid=$wid fi