diff options
| author | Robert Günzler <r@gnzler.io> | 2026-02-10 12:32:48 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-02-10 12:41:25 +0100 |
| commit | 63feeb9f369fc6176e85c1c2d8fcc863caad1946 (patch) | |
| tree | 41cd5d2d1ec36e74e464caab722cc9b460153f04 /bin/centercon | |
| parent | 5bd0a4aca65ecb9818ef1285982d160b6b6ff665 (diff) | |
start new
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bin/centercon')
| -rwxr-xr-x | bin/centercon | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/bin/centercon b/bin/centercon deleted file mode 100755 index c38cbab..0000000 --- a/bin/centercon +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -set -e -[ -n "$DEBUG" ] && set -x - -if [ "$1" = "-h" ]; then - printf "usage: %s [RESIZE_PERC] [MODE]\n" "$(basename "$0")" - printf "\n" - printf "MODE can be tr (for top-right) or empty (for center)\n" - exit 2 -fi - -con=$(swq current con) -con_width=$(echo "$con" | jq -r '.window_rect.width') -con_height=$(echo "$con" | jq -r '.window_rect.height') - -ws=$(swq current workspace) -ws_width=$(echo "$ws" | jq -r '.rect.width') -ws_height=$(echo "$ws" | jq -r '.rect.height') - -if [ "$1" = "-w" ]; then - shift - printf "scaling relative to workspace\n" - ratio=$(awk "BEGIN{print ($ws_width / $ws_height)}") - con_width=$ws_width - con_height=$ws_height -else - printf "scaling relative to container\n" - ratio=$(awk "BEGIN{print ($con_width / $con_height)}") -fi - -if [ -n "$1" ] || [ ! "$1" = "-" ]; then - perc="$1" - con_height=$(awk "BEGIN{print int($con_height * $perc)}") - con_width=$(awk "BEGIN{print int($con_height * $ratio)}") -fi - -if awk "BEGIN{ if (${perc} > 2.0) exit 0; else exit 1; }"; then - printf "scaling factor %.1f larger than 200%%, aborting...\n" "${perc}" - exit 1 -fi - -case "$2" in - tl) # top-left - tar_x=0 - tar_y=0 - ;; - tm) # top-middle - tar_x=$(awk "BEGIN{print int(($ws_width - $con_width)/2)}") - tar_y=0 - ;; - tr) # top-right - tar_x=$(awk "BEGIN{print int($ws_width - $con_width)}") - tar_y=0 - ;; - rm) # right-middle - tar_x=$(awk "BEGIN{print int($ws_width - $con_width)}") - tar_y=$(awk "BEGIN{print int(($ws_height - $con_height)/2)}") - ;; - br) # bottom-right - tar_x=$(awk "BEGIN{print int($ws_width - $con_width)}") - tar_y=$(awk "BEGIN{print int($ws_height - $con_height)}") - ;; - bm) # bottom-middle - tar_x=$(awk "BEGIN{print int(($ws_width - $con_width)/2)}") - tar_y=$(awk "BEGIN{print int($ws_height - $con_height)}") - ;; - bl) # bottom-left - tar_x=0 - tar_y=$(awk "BEGIN{print int($ws_height - $con_height)}") - ;; - lm) # left-middle - tar_x=0 - tar_y=$(awk "BEGIN{print int(($ws_height - $con_height)/2)}") - ;; - noop) # noop - ;; - c | *) # center - tar_x=$(awk "BEGIN{print int(($ws_width - $con_width)/2)}") - tar_y=$(awk "BEGIN{print int(($ws_height - $con_height)/2)}") - ;; -esac - -echo "ws: $ws_width x $ws_height" -echo "con: $con_width x $con_height" -echo "moveto: $tar_x x $tar_y" - -con_id=$(echo "$con" | jq -r '.id') -swaymsg [con_id="$con_id"] resize set "$con_width" "$con_height" -swaymsg [con_id="$con_id"] move position "$tar_x" "$tar_y" |