IceAsteroid / swayWorkroom.sh

More than 10 workspaces categorized into sets
GNU General Public License v3.0
3 stars 1 forks source link
sway workflow

swayWorkroom.sh

A script of implementing more than one set of 1-10 workspaces in Sway.

Inspired from a reddit post: link, but with enhancements.

News

It looks like someone loved & starred my work. So, I refactored the options, see the help page.

$: swayWorkroom.sh
## Help Page ##
Usage:
  swayWorkroom.sh [OPTION]
  -s <N>|<M> Switch to workroom number N or named M
  -x N       Navigate to workspace N in current workroom
  -x --toN   Move focused container to workspace N

Demo

demoGif

Enhancements

Features

How to use

  1. Download the script, and put it to the directory of choice.

  2. Comment out all lines related to workspace actions in sway, for example, as below:

    ## Workspaces:
    #
    #    # Switch to workspace
    #    bindsym $mod+1 workspace number 1
    #    bindsym $mod+2 workspace number 2
    #    bindsym $mod+3 workspace number 3
    #    bindsym $mod+4 workspace number 4
    #    bindsym $mod+5 workspace number 5
    #    bindsym $mod+6 workspace number 6
    #    bindsym $mod+7 workspace number 7
    #    bindsym $mod+8 workspace number 8
    #    bindsym $mod+9 workspace number 9
    #    bindsym $mod+0 workspace number 10
    #    # Move focused container to workspace
    #    bindsym $mod+Shift+1 move container to workspace number 1
    #    bindsym $mod+Shift+2 move container to workspace number 2
    #    bindsym $mod+Shift+3 move container to workspace number 3
    #    bindsym $mod+Shift+4 move container to workspace number 4
    #    bindsym $mod+Shift+5 move container to workspace number 5
    #    bindsym $mod+Shift+6 move container to workspace number 6
    #    bindsym $mod+Shift+7 move container to workspace number 7
    #    bindsym $mod+Shift+8 move container to workspace number 8
    #    bindsym $mod+Shift+9 move container to workspace number 9
    #    bindsym $mod+Shift+0 move container to workspace number 10
  3. Add following keybindings to the script. "xxx" will be the directory that the script is in.

    ## Workroom implementaton:
    # Reset workroom to 1
    # , for workspace N0, as this workspace's number is set from a file and + 1 to it.
    # This is to prevent loading N0 when restarting sway from tty, while the file's been written by the "swayWorkroom.sh" script.
    set $swayScriptsTmpDir "/tmp/swayScriptsTmpDir"
    set $workroomTmpFile $swayScriptsTmpDir/swayWorkroomSwitched.txt
    exec echo 1 > $workroomTmpFile
    
    # Switch workroom
    bindsym Alt+Shift+q exec "${HOME}/xxx/swayWorkroom.sh -s 1"
    bindsym Alt+Shift+w exec "${HOME}/xxx/swayWorkroom.sh -s 2"
    bindsym Alt+Shift+e exec "${HOME}/xxx/swayWorkroom.sh -s 3"
    # You can add more workrooms as below
    #bindsym Alt+Shift+r exec "${HOME}/xxx/swayWorkroom.sh -s r"
    #bindsym Alt+Shift+t exec "${HOME}/xxx/swayWorkroom.sh -s t"
    
    # Navigate
    bindsym $mod+Escape exec "${HOME}/Bin/swayWorkroom.sh -x 1"
    bindsym $mod+1 exec "${HOME}/xxx/swayWorkroom.sh -x 1"
    bindsym $mod+2 exec "${HOME}/xxx/swayWorkroom.sh -x 2"
    bindsym $mod+3 exec "${HOME}/xxx/swayWorkroom.sh -x 3"
    bindsym $mod+4 exec "${HOME}/xxx/swayWorkroom.sh -x 4"
    bindsym $mod+5 exec "${HOME}/xxx/swayWorkroom.sh -x 5"
    bindsym $mod+6 exec "${HOME}/xxx/swayWorkroom.sh -x 6"
    bindsym $mod+7 exec "${HOME}/xxx/swayWorkroom.sh -x 7"
    bindsym $mod+8 exec "${HOME}/xxx/swayWorkroom.sh -x 8"
    bindsym $mod+9 exec "${HOME}/xxx/swayWorkroom.sh -x 9"
    bindsym $mod+0 exec "${HOME}/xxx/swayWorkroom.sh -x 0"
    
    # Move focused container to workspace
    bindsym $mod+Shift+1 exec "${HOME}/xxx/swayWorkroom.sh -x --to1"
    bindsym $mod+Shift+2 exec "${HOME}/xxx/swayWorkroom.sh -x --to2"
    bindsym $mod+Shift+3 exec "${HOME}/xxx/swayWorkroom.sh -x --to3"
    bindsym $mod+Shift+4 exec "${HOME}/xxx/swayWorkroom.sh -x --to4"
    bindsym $mod+Shift+5 exec "${HOME}/xxx/swayWorkroom.sh -x --to5"
    bindsym $mod+Shift+6 exec "${HOME}/xxx/swayWorkroom.sh -x --to6"
    bindsym $mod+Shift+7 exec "${HOME}/xxx/swayWorkroom.sh -x --to7"
    bindsym $mod+Shift+8 exec "${HOME}/xxx/swayWorkroom.sh -x --to8"
    bindsym $mod+Shift+9 exec "${HOME}/xxx/swayWorkroom.sh -x --to9"
    bindsym $mod+Shift+0 exec "${HOME}/xxx/swayWorkroom.sh -x --to0"
  4. Refresh sway and you're good to go. :)

Contribution

Just post an issue, if you encounter any problems. I'll fix them if I can when I'm feeling a bit energic.