Skip to content

IceAsteroid/swayWorkroom.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

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

  • Intuitive workspace numbering, for example, 11 to 20, instead of 11 to 19, as implementing Workroom only in Sway conf file has this limitation.
  • Unlimited sets just to set corresponding keybindings in Sway conf, without the need to modify the script.
  • Added container moving functionality to use with Workroom.

Features

  • Sets
    • Set 1's workspaces start at 11 up to 20.
    • Set 2's workspaces start at 21 up to 30.
    • Set 3 follows the same.
    • Or add more sets with names or numbers.
      • For example:
      # 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"
      bindsym Alt+Shift+r exec "${HOME}/xxx/swayWorkroom.sh -s r"
      bindsym Alt+Shift+t exec "${HOME}/xxx/swayWorkroom.sh -s t"
      #... more sets
      
  • Workflow
    • Keybindings
      • Move to numeral-named sets 1, 2, 3 by keybindings of choice.
        • Or to sets named with non-numbe by keybindings of choice.
      • Number & non-number named sets can be specified respectively wihout problems.
    • Inheriting digits
      • When moving to another set, for example, from set 1 to set 2, and you're in 13, the workspace to switch to, will be 23. And 20 will be 30, etc.
        • For example, you're on a browser for a certain task, now more browser instances for different tasks are desired, you can just switch to other sets to open more instances, since, when you switch to a set, the workspace's digit will be exactly the one as to other sets, so there's not need to find those workspaces which contain browser instances in Sway, all you need to do is just simply switch to other sets.
        • Say that you choose to open up browsers for task A in workspace 13, now more instances for tasks B, C, are needed. You can just switch to other sets, for example, switch to set 2, 3, will be 23, 33, respectively. This is just too clean and good, now I cannot live without this. :)
  • Container/window moving functionality
    • Added container moving support, but it only allows containers to move only inside of the set they're in.
    • Trick to move a container from the current set to another set: Switch to another set that's intended with swayWorkroom,sh, and then switch back to the workspace that holds the intended container you want to move by clicking on the swaybar or waybar which is the bar you use, move it to a certain workspace of the intended set, by mod+shift+N for example.

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
  1. 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"
  1. 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.

About

More than 10 workspaces categorized into sets

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages