diff --git a/dot_config/i3/config b/dot_config/i3/config index 02bedc1..434492a 100644 --- a/dot_config/i3/config +++ b/dot_config/i3/config @@ -272,7 +272,7 @@ exec --no-startup-id /usr/bin/gnome-keyring-daemon --start --components=ssh exec --no-startup-id /usr/bin/gnome-keyring-daemon --start --components=pkcs11 # Set current monitor configuration -exec_always --no-startup-id ~/.config/i3/on_i3_start.sh +exec --no-startup-id ~/.config/i3/on_i3_start.sh # Desktop notifications_ exec --no-startup-id /usr/bin/dunst diff --git a/dot_config/i3/executable_on_i3_start.sh b/dot_config/i3/executable_on_i3_start.sh index 4c6e262..3033889 100644 --- a/dot_config/i3/executable_on_i3_start.sh +++ b/dot_config/i3/executable_on_i3_start.sh @@ -5,13 +5,32 @@ source $GENERATED_MONITOR_CONF $MONITOR_CONF # Apply configured layout -# To launch as dry mode. Uncomment line in below -# MSG_COMMAND=echo +function process_workspace () { + WORKSPACE_NUMBER=$(echo $1 | cut -d ',' -f1) + OUTPUT_NAME=$(echo $1 | cut -d ',' -f2) -for i in $(seq 1 $SCREEN_NUMBER); do + NEW_OUTPUT_NAME=${SCREENS[$(($WORKSPACE_NUMBER / 10))]} + + if [[ "$OUTPUT_NAME" != "$NEW_OUTPUT_NAME" ]]; then + echo "WORKSPACE_NUMBER: $WORKSPACE_NUMBER | OUTPUT: $OUTPUT_NAME | NEW_OUTPUT: $NEW_OUTPUT_NAME" + echo move workspace number $WORKSPACE_NUMBER to output $NEW_OUTPUT_NAME + $MSG_COMMAND move workspace number \"$WORKSPACE_NUMBER\" to output $NEW_OUTPUT_NAME + fi +} + +# Create new workspace for multiple screen at first index of relative index +# Ex: SCREEN 2 => WORKSPACE NUMBER => 20 +for i in $(seq 2 $SCREEN_NUMBER); do INDEX=$(($i - 1)) SCREEN=${SCREENS[$INDEX]} - for j in $(seq 1 10); do - $MSG_COMMAND move workspace number $(($INDEX * 10 + $j)) to output $SCREEN - done + echo workspace number $(($INDEX * 10)) to output $SCREEN + $MSG_COMMAND workspace number \"$(($INDEX * 10))\" to output $SCREEN done + +$MSG_COMMAND -t get_workspaces \ + | jq -c '.[] | [.num, .output] | @csv' \ + | sed 's/"//g' | sed 's/\\//g' | + while IFS=$'\n' read -r c; do + process_workspace $c + done +