diff options
| author | Robert Günzler <r@gnzler.io> | 2020-07-10 14:35:31 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2020-07-10 14:35:31 +0200 |
| commit | 2e3e4ea9a26935244bff85f4a4409fa05b1d7244 (patch) | |
| tree | 7d14c04e1b452c5db1ff1775949320a2f88708b9 /bin | |
| parent | 4ab81bf9b65fb317c9ad39530ac9060f16d77d97 (diff) | |
bin/swx: Add option to move window to scratchpad
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/swx | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/bin/swx b/bin/swx index 87a98d5..c9ca172 100755 --- a/bin/swx +++ b/bin/swx @@ -19,7 +19,8 @@ rotate= sticky= floating= autotile= -while getopts b:w:o:g:I:r:stfF:ah name; do +into_scratchpad= +while getopts b:w:o:g:I:r:stfF:aSh name; do case "$name" in b) # border border="${OPTARG}" ;; @@ -45,7 +46,9 @@ while getopts b:w:o:g:I:r:stfF:ah name; do floating="${OPTARG}" ;; a) # auto-tiling enabled autotile=1 ;; - h|?) printf "usage: %s [-bwogIrsfo] COMMAND\n" "$(basename "$0")" + S) # launch into scratchpad + into_scratchpad=1 ;; + h|?) printf "usage: %s [-bwogIrsfoS] COMMAND\n" "$(basename "$0")" printf "\n" printf " -t \t\trun COMMAND in \$TERM\n" printf " -b BORDER \tset border property\n" @@ -54,8 +57,10 @@ while getopts b:w:o:g:I:r:stfF:ah name; do printf " -g GEOMETRY \tresize/position window\n" printf " -r ROTATION \trotate the container, requires cage(1)\n" printf " -s \t\tmake COMMAND a sticky window, appearing on all workspaces\n" - printf " -f [PERC [MODE]]\tmake COMMAND a floating window\n\tsee centercon(1) for possible values\n" + printf " -f \t\tmake COMMAND a floating window\n\tsee centercon(1) for possible values\n" + printf " -F [PERC [MODE]]\tmake COMMAND a floating window\n\tsee centercon(1) for possible values\n" printf " -a \t\tauto-tiling; always open COMMAND on the shorter edge\n\t\tof the current container\n" + printf " -S \t\tmove the container into the scratchpad\n" printf "\n" printf "See sway(5) for possible options for BORDER, WORKSPACE, OUTPUT and GEOMETRY.\n" exit 2 ;; @@ -115,14 +120,12 @@ con_id="$(swaymsg -t subscribe '["window"]' | jq -s -r '.[]|select(.change=="new sway_props_done= while [ -z "${sway_props_done}" ]; do - if [ -n "${border}" ]; then - swaymsg [con_id="${con_id}"] border "${border}" - fi - if [ -n "${wspace}" ]; then - swaymsg [con_id="${con_id}"] move workspace "${wspace}" + if [ -n "${floating}" ]; then + swaymsg [con_id="${con_id}"] floating enable + [ ! "${floating}" = "1" ] && centercon "${floating}" fi - if [ -n "${output}" ]; then - swaymsg [con_id="${con_id}"] move output "${wspace}" + if [ -n "${into_scratchpad}" ]; then + swaymsg [con_id="${con_id}"] move to scratchpad fi if [ -n "${geometry}" ]; then swaymsg [con_id="${con_id}"] floating enable @@ -135,12 +138,17 @@ while [ -z "${sway_props_done}" ]; do "$(printf "%s" "${xy}" | cut -d',' -f1)" px \ "$(printf "%s" "${xy}" | cut -d',' -f2)" px fi + if [ -n "${wspace}" ]; then + swaymsg [con_id="${con_id}"] move workspace "${wspace}" + fi + if [ -n "${output}" ]; then + swaymsg [con_id="${con_id}"] move output "${wspace}" + fi if [ -n "${sticky}" ]; then swaymsg [con_id="${con_id}"] sticky enable fi - if [ -n "${floating}" ]; then - swaymsg [con_id="${con_id}"] floating enable - [ "${floating}" = "1" ] || centercon ${floating} + if [ -n "${border}" ]; then + swaymsg [con_id="${con_id}"] border "${border}" fi sway_props_done=1 done >/dev/null |