aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2023-04-15 17:25:29 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2023-04-18 22:43:32 +0300
commit4ac1ecb1c516ddd0ed35650991a0aff27523f4ab (patch)
tree93704fd79567a50413756cdf604132c5d1f5049f
parent3c1241eb3a4376ea01195a08d267dc91695ebab7 (diff)
downloadswayrice-4ac1ecb1c516ddd0ed35650991a0aff27523f4ab.tar.gz
swayrice-4ac1ecb1c516ddd0ed35650991a0aff27523f4ab.zip
workspace: adapt for different screen sizes
-rwxr-xr-xdotfiles/.local/bin/workspace11
1 files changed, 9 insertions, 2 deletions
diff --git a/dotfiles/.local/bin/workspace b/dotfiles/.local/bin/workspace
index 5183c72..749d77f 100755
--- a/dotfiles/.local/bin/workspace
+++ b/dotfiles/.local/bin/workspace
@@ -27,14 +27,21 @@ if [ -z "$1" ]; then
exit 1
fi
-swaymsg "gaps inner current set 0; gaps outer current set 0"
+displayw=$(swaymsg -rt get_outputs |\
+ jq --raw-output '.[] | select(.focused == true) | .rect.width')
+sidebarw=30
+
+if [ $displayw -lt 2560 ]; then
+ swaymsg "gaps inner current set 0; gaps outer current set 0"
+ sidebarw=27
+fi
cd "$1"
setsid $TERMINAL -a "$TERMINAL lf:$1" zsh -ic "lfcd" >/dev/null 2>&1 & sleep 0.1
setsid $TERMINAL -a "$TERMINAL edit:$1" >/dev/null 2>&1 & sleep 0.1
sleep 0.2
-swaymsg "[app_id=\"$TERMINAL lf:$1\"] focus; resize set width 27ppt; split v"
+swaymsg "[app_id=\"$TERMINAL lf:$1\"] focus; resize set width ${sidebarw}ppt; split v"
setsid $TERMINAL >/dev/null 2>&1 & sleep 0.2
swaymsg "resize set height 60ppt" && sleep 0.1
swaymsg "[app_id=\"$TERMINAL edit:$1\"] focus"