diff --git a/dot_config/i3/config b/dot_config/i3/config index 2e82abb..02bedc1 100644 --- a/dot_config/i3/config +++ b/dot_config/i3/config @@ -145,6 +145,9 @@ bindsym $mod+q focus parent # focus the child container #bindsym $mod+d focus child +# SOURCE OF ALL CONFS +# https://github.com/sharpTrick/set-i3-workspace + # Define names for default workspaces for which we configure key bindings later on. # We use variables to avoid repeating the names in multiple places. set $ws1 "1" @@ -159,28 +162,28 @@ set $ws9 "9" set $ws10 "10" # switch to workspace -bindsym $mod+1 workspace number $ws1 -bindsym $mod+2 workspace number $ws2 -bindsym $mod+3 workspace number $ws3 -bindsym $mod+4 workspace number $ws4 -bindsym $mod+5 workspace number $ws5 -bindsym $mod+6 workspace number $ws6 -bindsym $mod+7 workspace number $ws7 -bindsym $mod+8 workspace number $ws8 -bindsym $mod+9 workspace number $ws9 -bindsym $mod+0 workspace number $ws10 +bindsym $mod+1 exec ~/.config/i3/relative_workspace.sh $ws1 +bindsym $mod+2 exec ~/.config/i3/relative_workspace.sh $ws2 +bindsym $mod+3 exec ~/.config/i3/relative_workspace.sh $ws3 +bindsym $mod+4 exec ~/.config/i3/relative_workspace.sh $ws4 +bindsym $mod+5 exec ~/.config/i3/relative_workspace.sh $ws5 +bindsym $mod+6 exec ~/.config/i3/relative_workspace.sh $ws6 +bindsym $mod+7 exec ~/.config/i3/relative_workspace.sh $ws7 +bindsym $mod+8 exec ~/.config/i3/relative_workspace.sh $ws8 +bindsym $mod+9 exec ~/.config/i3/relative_workspace.sh $ws9 +bindsym $mod+0 exec ~/.config/i3/relative_workspace.sh $ws10 # move focused container to workspace -bindsym $mod+Shift+1 move container to workspace number $ws1 -bindsym $mod+Shift+2 move container to workspace number $ws2 -bindsym $mod+Shift+3 move container to workspace number $ws3 -bindsym $mod+Shift+4 move container to workspace number $ws4 -bindsym $mod+Shift+5 move container to workspace number $ws5 -bindsym $mod+Shift+6 move container to workspace number $ws6 -bindsym $mod+Shift+7 move container to workspace number $ws7 -bindsym $mod+Shift+8 move container to workspace number $ws8 -bindsym $mod+Shift+9 move container to workspace number $ws9 -bindsym $mod+Shift+0 move container to workspace number $ws10 +bindsym $mod+Shift+1 exec ~/.config/i3/relative_workspace.sh $ws1 move +bindsym $mod+Shift+2 exec ~/.config/i3/relative_workspace.sh $ws2 move +bindsym $mod+Shift+3 exec ~/.config/i3/relative_workspace.sh $ws3 move +bindsym $mod+Shift+4 exec ~/.config/i3/relative_workspace.sh $ws4 move +bindsym $mod+Shift+5 exec ~/.config/i3/relative_workspace.sh $ws5 move +bindsym $mod+Shift+6 exec ~/.config/i3/relative_workspace.sh $ws6 move +bindsym $mod+Shift+7 exec ~/.config/i3/relative_workspace.sh $ws7 move +bindsym $mod+Shift+8 exec ~/.config/i3/relative_workspace.sh $ws8 move +bindsym $mod+Shift+9 exec ~/.config/i3/relative_workspace.sh $ws9 move +bindsym $mod+Shift+0 exec ~/.config/i3/relative_workspace.sh $ws10 move # kill window bindsym $mod+Shift+q kill @@ -268,6 +271,9 @@ exec --no-startup-id /usr/bin/gnome-keyring-daemon --start --components=secrets 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 + # Desktop notifications_ exec --no-startup-id /usr/bin/dunst diff --git a/dot_config/i3/executable_common_var.sh b/dot_config/i3/executable_common_var.sh index e5ae079..0560252 100644 --- a/dot_config/i3/executable_common_var.sh +++ b/dot_config/i3/executable_common_var.sh @@ -2,3 +2,10 @@ MONITOR_CONF=~/.screenlayout/monitor.sh GENERATED_MONITOR_CONF=~/.screenlayout/generated_monitor.sh + +# Set command from current VM +MSG_COMMAND=i3-msg +if [[ $DESKTOP_SESSION =~ ^sway$ ]]; then + MSG_COMMAND=swaymsg +fi + diff --git a/dot_config/i3/executable_configure_monitors.sh b/dot_config/i3/executable_configure_monitors.sh index 86547e9..6b8a6d4 100644 --- a/dot_config/i3/executable_configure_monitors.sh +++ b/dot_config/i3/executable_configure_monitors.sh @@ -12,7 +12,7 @@ function set_configuration () { $MONITOR_CONF # Apply configuration } -# set_configuration +set_configuration # SCREENS => HashMap | Key => Output name | Value => Position X # SCREENS EX: @@ -49,3 +49,4 @@ EXPORT_SCREENS="${EXPORT_SCREENS:0:-1})" # Remove last space echo "#!/bin/bash" > $GENERATED_MONITOR_CONF echo $EXPORT_SCREENS >> $GENERATED_MONITOR_CONF +echo "SCREEN_NUMBER=\${#SCREENS[@]}" >> $GENERATED_MONITOR_CONF diff --git a/dot_config/i3/executable_on_i3_start.sh b/dot_config/i3/executable_on_i3_start.sh new file mode 100644 index 0000000..4c6e262 --- /dev/null +++ b/dot_config/i3/executable_on_i3_start.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +source ~/.config/i3/common_var.sh +source $GENERATED_MONITOR_CONF + +$MONITOR_CONF # Apply configured layout + +# To launch as dry mode. Uncomment line in below +# MSG_COMMAND=echo + +for i in $(seq 1 $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 +done diff --git a/dot_config/i3/executable_relative_workspace.sh b/dot_config/i3/executable_relative_workspace.sh index da6b716..a1f11ee 100644 --- a/dot_config/i3/executable_relative_workspace.sh +++ b/dot_config/i3/executable_relative_workspace.sh @@ -6,14 +6,6 @@ source ~/.config/i3/common_var.sh source $GENERATED_MONITOR_CONF -SCREEN_NUMBER=${#SCREENS[@]} - -# Set command from current WM -MSG_COMMAND=i3-msg -if [[ $DESKTOP_SESSION =~ ^sway$ ]]; then - MSG_COMMAND=swaymsg -fi - # Get current workspace output (Screen) CURRENT_WORKSPACE=$($MSG_COMMAND -t get_workspaces \ | jq '.[] | select(.visible == true and .focused == true) | .output' \ @@ -33,9 +25,11 @@ done DESIRED_WORKSPACE=$(($SCREEN_INDEX * 10 + $1)) # To run in DRY RUN uncomment line in below -MSG_COMMAND=echo +# MSG_COMMAND=echo if [[ "$2" == "move" ]]; then + notify-send "move to $DESIRED_WORKSPACE" $MSG_COMMAND move container to workspace number $DESIRED_WORKSPACE else + notify-send "switch to $DESIRED_WORKSPACE" $MSG_COMMAND workspace number $DESIRED_WORKSPACE fi