# see https://savannah.gnu.org/maintenance/fsf/bash-style-guide/ for justifications
local quotes others ret
quotes=2048,2068,2086,2206,2254
- others=2029,2032,2033,2054,2164
+ others=2029,2032,2033,2054,2164,2317
shellcheck -x -W 999 -e $quotes,$others "$@" || ret=$?
if (( ret >= 1 )); then
echo "A template comment to disable is now in clipboard. eg: # shellcheck disable=SC2206 # reason"
x="$(readlink -f -- "${BASH_SOURCE[0]}")"; cd ${x%/*} # directory of this file
+## do sway config. untested and probably broken at this point
dir=/a/bin/distro-setup/subdir_files/.config/sway
mkdir -p $dir
cat common.conf sway.conf > $dir/config
+
+## do i3 config
dir=/a/bin/distro-setup/subdir_files/.config/i3
mkdir -p $dir
cat common.conf i3.conf > $dir/config
-
-monitor_count=$(xrandr|grep -c ' connected')
-if [[ $1 == bar ]] || (( monitor_count >= 2 )); then
- cat bar.conf >> $dir/config
+if [[ -s ~/i3-myx.conf ]]; then
+ cat ~/i3-myx.conf >>$dir/config
fi
-move_arg=right
-if xrandr --listmonitors | awk '$2 == "MON-BOTTOM-LEFT"' |grep . >/dev/null; then
- cat >>$dir/config <<'EOF'
-# by default, new workspaces are created on whatever screen doesn't have
-# one active or else the current one. That is annoying, I have one
-# primary monitor, I don't want a new workspace created on secondary
-# monitor just because I happen be focused on it. This fixes that.
-workspace 1 output primary
-workspace 2 output MON-LEFT
-workspace 3 output MON-BOTTOM-LEFT
-workspace 4 output MON-RIGHT
-workspace 5 output MON-RIGHT
-workspace 6 output MON-RIGHT
-workspace 7 output MON-RIGHT
-workspace 8 output MON-RIGHT
-workspace 9 output MON-RIGHT
-workspace 10 output MON-RIGHT
-EOF
- move_arg="MON-BOTTOM-LEFT MON-RIGHT primary"
-elif xrandr --listmonitors | awk '$2 == "MON-LEFT"' |grep . >/dev/null; then
- cat >>$dir/config <<'EOF'
-# by default, new workspaces are created on whatever screen doesn't have
-# one active or else the current one. That is annoying, I have one
-# primary monitor, I don't want a new workspace created on secondary
-# monitor just because I happen be focused on it. This fixes that.
-workspace 1 output primary
-workspace 2 output MON-LEFT
-workspace 3 output MON-RIGHT
-workspace 4 output MON-RIGHT
-workspace 5 output MON-RIGHT
-workspace 6 output MON-RIGHT
-workspace 7 output MON-RIGHT
-workspace 8 output MON-RIGHT
-workspace 9 output MON-RIGHT
-workspace 10 output MON-RIGHT
-EOF
- move_arg="MON-RIGHT primary"
-else
- mon2=$(xrandr | awk '$2 == "connected" && $3 != "primary" {print $1}')
- if [[ $mon2 ]]; then
- cat >>$dir/config <<EOF
-workspace 1 output primary
-workspace 2 output $mon2
-workspace 3 output $mon2
-workspace 4 output primary
-workspace 5 output $mon2
-workspace 6 output $mon2
-workspace 7 output $mon2
-workspace 8 output $mon2
-workspace 9 output $mon2
-workspace 10 output $mon2
-EOF
- fi
-fi
-
- # shellcheck disable=SC2016
-echo 'bindsym $mod+Shift+t move workspace to output '$move_arg >>$dir/config
-
if [[ $I3SOCK ]]; then
echo $0: i3-msg reload
i3-msg reload
m xrandr --output $target_out $left_right_arg --mode $target_res
fi
-
-m /a/bin/ds/i3-sway/gen
-
-
if $tall; then
-
# 298 & 336 are millimeters. I took them from a monitor I was using. I
# don't know if they are important, I assume not important enough to
# change for different monitors.
m xrandr --setmonitor MON-LEFT $half_x/298x$target_y/336+$x_offset+0 $target_out
m xrandr --setmonitor MON-RIGHT $half_x/298x$target_y/336+$(( x_offset + half_x ))+0 none
- move-ws MON-LEFT 2
- move-ws MON-RIGHT 3 4 5 6 7 8 9 10
-
elif $quarter; then
-
m xrandr --setmonitor MON-LEFT $half_x/298x$half_y/336+$x_offset+0 $target_out
m xrandr --setmonitor MON-BOTTOM-LEFT $half_x/298x$half_y/336+$x_offset+$half_y none
m xrandr --setmonitor MON-RIGHT $half_x/298x$target_y/336+$(( x_offset + half_x ))+0 none
-
- move-ws MON-LEFT 2
- move-ws MON-BOTTOM-LEFT 3
- move-ws MON-RIGHT 4 5 6 7 8 9 10
-else # fullscreen
- move-ws $target_out 2 3 5 6 7 8 9 10
fi
+
+
+## begin i3 config ##
if [[ $secondary_out ]]; then
ws1_output=$primary_out
+ move_outputs=($primary_out)
else
+ move_outputs=()
ws1_output=MON-RIGHT
fi
-move-ws $ws1_output 1
+
+ws_outputs=(
+ $ws1_output
+)
+
+if $tall; then
+ ws_outputs+=(
+ MON-LEFT
+ MON-RIGHT
+ )
+ move_outputs+=(MON-RIGHT)
+elif $quarter; then
+ ws_outputs+=(
+ MON-LEFT
+ MON-BOTTOM-LEFT
+ MON-RIGHT
+ )
+ move_outputs+=(MON-BOTTOM-LEFT MON-RIGHT)
+fi
+
+echo d1 ${ws_outputs[@]}
+
+if (( ${#move_outputs[@]} == 0 )); then
+ move_outputs=(right)
+fi
+
+rm -f ~/i3-myx.conf
+total_ws_count=10
+for (( i=0; i<total_ws_count; i++ )); do
+ ws=$(( i+1 ))
+ tmp=${ws_outputs[$i]}
+ echo tmp: $tmp
+ # use the last output in the array for all remaining workspaces
+ if [[ $tmp ]]; then
+ ws_out=$tmp
+ fi
+ echo "workspace $ws output $ws_out" >>~/i3-myx.conf
+done
+echo "bindsym \$mod+Shift+t move workspace to output ${move_outputs[*]}" >>~/i3-myx.conf
+m /a/bin/ds/i3-sway/gen
+
+# this bit is so that we only move workspaces that need to be moved
+# and we don't have to ignore errors. A waste of time, but
+# it was fun.
+declare -A ws_to_out
+tmps=$(i3 -t get_workspaces)
+tmps=$(jq -r '.[] | .num, .output' <<<"$tmps")
+while read -r ws; do
+ read -r output || break
+ ws_to_out["$ws"]=$output
+done <<<"$tmps"
+
+for (( i=0; i<total_ws_count; i++ )); do
+ ws=$(( i+1 ))
+ tmp=${ws_outputs[$i]}
+ echo tmp: $tmp
+ # use the last output in the array for all remaining workspaces
+ if [[ $tmp ]]; then
+ ws_out=$tmp
+ fi
+ if [[ ${ws_to_out[$ws]} && ${ws_to_out[$ws]} != "$ws_out" ]]; then
+ m i3 '[workspace="'$ws'"]' move workspace to output $ws_out
+ fi
+done
+## end i3 config ##
+
m /a/exe/input-setup