From 0600b11d2b151fa034cd6bdfa2ad4ccdcfe1f184 Mon Sep 17 00:00:00 2001 From: Thomas Praxl Date: Sat, 23 Dec 2017 12:28:03 +0100 Subject: [PATCH] Add workspace vars to support DRY when customizing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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). --- etc/config | 63 +++++++++++++++++++++++++++++++-------------- etc/config.keycodes | 62 ++++++++++++++++++++++++++++++-------------- 2 files changed, 85 insertions(+), 40 deletions(-) diff --git a/etc/config b/etc/config index 5b751d00..77966e8a 100644 --- a/etc/config +++ b/etc/config @@ -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 diff --git a/etc/config.keycodes b/etc/config.keycodes index c07462b4..86eadb82 100644 --- a/etc/config.keycodes +++ b/etc/config.keycodes @@ -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 -- 2.39.5