Add workspace vars to support DRY when customizing

Relabeling the workspaces required the user to update the labels at least in two places of the i3 config file (switch to workspace + move focused container to workspace) to keep a consistent state.

This got even worse when the user started to reference the workspaces elsewhere, e.g. for assigning containers to specific workspaces.

This change supports the DRY principle for users. Relabeling the workspaces is now merely a matter of changing the respective variable ($ws1, $ws2, … $ws10).
This commit is contained in:
Thomas Praxl 2017-12-23 12:28:03 +01:00
parent 2f1fc7f610
commit 0600b11d2b
2 changed files with 85 additions and 40 deletions

View File

@ -104,29 +104,52 @@ bindsym Mod1+Shift+minus move scratchpad
# If there are multiple scratchpad windows, this command cycles through them.
bindsym Mod1+minus scratchpad show
# Define workspaces along with their labels
#
# Customize your workspace labels here.
# Example:
#
# set $ws1 "Terminals"
#
# or
#
# set $ws1 "1: Terminals"
#
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
# switch to workspace
bindsym Mod1+1 workspace 1
bindsym Mod1+2 workspace 2
bindsym Mod1+3 workspace 3
bindsym Mod1+4 workspace 4
bindsym Mod1+5 workspace 5
bindsym Mod1+6 workspace 6
bindsym Mod1+7 workspace 7
bindsym Mod1+8 workspace 8
bindsym Mod1+9 workspace 9
bindsym Mod1+0 workspace 10
bindsym Mod1+1 workspace $ws1
bindsym Mod1+2 workspace $ws2
bindsym Mod1+3 workspace $ws3
bindsym Mod1+4 workspace $ws4
bindsym Mod1+5 workspace $ws5
bindsym Mod1+6 workspace $ws6
bindsym Mod1+7 workspace $ws7
bindsym Mod1+8 workspace $ws8
bindsym Mod1+9 workspace $ws9
bindsym Mod1+0 workspace $ws10
# move focused container to workspace
bindsym Mod1+Shift+1 move container to workspace 1
bindsym Mod1+Shift+2 move container to workspace 2
bindsym Mod1+Shift+3 move container to workspace 3
bindsym Mod1+Shift+4 move container to workspace 4
bindsym Mod1+Shift+5 move container to workspace 5
bindsym Mod1+Shift+6 move container to workspace 6
bindsym Mod1+Shift+7 move container to workspace 7
bindsym Mod1+Shift+8 move container to workspace 8
bindsym Mod1+Shift+9 move container to workspace 9
bindsym Mod1+Shift+0 move container to workspace 10
bindsym Mod1+Shift+1 move container to workspace $ws1
bindsym Mod1+Shift+2 move container to workspace $ws2
bindsym Mod1+Shift+3 move container to workspace $ws3
bindsym Mod1+Shift+4 move container to workspace $ws4
bindsym Mod1+Shift+5 move container to workspace $ws5
bindsym Mod1+Shift+6 move container to workspace $ws6
bindsym Mod1+Shift+7 move container to workspace $ws7
bindsym Mod1+Shift+8 move container to workspace $ws8
bindsym Mod1+Shift+9 move container to workspace $ws9
bindsym Mod1+Shift+0 move container to workspace $ws10
# reload the configuration file
bindsym Mod1+Shift+c reload

View File

@ -91,29 +91,51 @@ bindcode $mod+38 focus parent
# focus the child container
#bindsym $mod+d focus child
# Define workspaces along with their labels
#
# Customize your workspace labels here.
# Example:
#
# set $ws1 "Terminals"
#
# or
#
# set $ws1 "1: Terminals"
#
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
# switch to workspace
bindcode $mod+10 workspace 1
bindcode $mod+11 workspace 2
bindcode $mod+12 workspace 3
bindcode $mod+13 workspace 4
bindcode $mod+14 workspace 5
bindcode $mod+15 workspace 6
bindcode $mod+16 workspace 7
bindcode $mod+17 workspace 8
bindcode $mod+18 workspace 9
bindcode $mod+19 workspace 10
bindcode $mod+10 workspace $ws1
bindcode $mod+11 workspace $ws2
bindcode $mod+12 workspace $ws3
bindcode $mod+13 workspace $ws4
bindcode $mod+14 workspace $ws5
bindcode $mod+15 workspace $ws6
bindcode $mod+16 workspace $ws7
bindcode $mod+17 workspace $ws8
bindcode $mod+18 workspace $ws9
bindcode $mod+19 workspace $ws10
# move focused container to workspace
bindcode $mod+Shift+10 move container to workspace 1
bindcode $mod+Shift+11 move container to workspace 2
bindcode $mod+Shift+12 move container to workspace 3
bindcode $mod+Shift+13 move container to workspace 4
bindcode $mod+Shift+14 move container to workspace 5
bindcode $mod+Shift+15 move container to workspace 6
bindcode $mod+Shift+16 move container to workspace 7
bindcode $mod+Shift+17 move container to workspace 8
bindcode $mod+Shift+18 move container to workspace 9
bindcode $mod+Shift+19 move container to workspace 10
bindcode $mod+Shift+10 move container to workspace $ws1
bindcode $mod+Shift+11 move container to workspace $ws2
bindcode $mod+Shift+12 move container to workspace $ws3
bindcode $mod+Shift+13 move container to workspace $ws4
bindcode $mod+Shift+14 move container to workspace $ws5
bindcode $mod+Shift+15 move container to workspace $ws6
bindcode $mod+Shift+16 move container to workspace $ws7
bindcode $mod+Shift+17 move container to workspace $ws8
bindcode $mod+Shift+18 move container to workspace $ws9
bindcode $mod+Shift+19 move container to workspace $ws10
# reload the configuration file
bindcode $mod+Shift+54 reload