Anyway to switch between workspaces

Hi, im trying to bind keys to switch between workspaces instead of selecting the exact workspace #. I tried back_and_forth but not having any luck. Any help would be appreciated. Thanks

Welcome to the community. :beers: Hope you find what you need and have a good time doing it. :smiley:

I think “workspace next” is what you are wanting. Hope this helps.

2 Likes

Not sure which DE you’re using. I know in XFCE, switching workspaces defaults as Ctrl+Alt+Left or Right Arrow Key.

Or - just put the mouse pointer on the ‘open’ screen background and spin the mouse wheel… (selectable item in Settings/Windows Manager Tweaks/Workspaces)

There are a variety of ways to do this dependent on whether you use a DE or, if you are like me, using a tiling window manager. Since you don’t know how to do it, I assume that you are using a desktop environment that you don’t know well. The two main methods are ctrl-alt-right (or left) and middle mouse wheel. The answer is usually in the docs or in the keybindings setting that you should be able to find in the menu.

1 Like

Thanks, I am not using any DE just i3. workspace next did not work. I guess I can get used to super+1234…

Try this:

# Alt tab workspace switching

bindsym Mod1+Tab workspace next
bindsym Mod1+Shift+Tab workspace prev
1 Like

From i3’s user guide: https://i3wm.org/docs/userguide.html#_changing_named_workspaces_moving_to_workspaces

You can also switch to the next and previous workspace with the commands workspace next and workspace prev, which is handy, for example, if you have workspace 1, 3, 4 and 9 and you want to cycle through them with a single key combination. To restrict those to the current output, use workspace next_on_output and workspace prev_on_output. Similarly, you can use move container to workspace next, move container to workspace prev to move a container to the next/previous workspace and move container to workspace current (the last one makes sense only when used with criteria).

It’s been a while since I’ve used i3, but I would assume that would mean it would be

bindsym Mod1+Tab workspace next_on_output

For example. Pardon though, my i3 knowledge is not great these days, but their user guide is basically an i3wm version of the arch wiki. It’s VERY well documented and in depth, even if it is a bit hard to understand sometimes.

1 Like

This seems to be a feature not included in i3. I’ve tried all the suggestions and been through the i3 docs. Closest i’ve found is a script I can’t get to work. https://github.com/altdesktop/i3ipc-python/blob/master/examples/i3-cycle-focus.py

syntax error at "use strict;’
I made sure my java was up to date.

ideas?

If you have your workspaces named 1,2,3… like mine, simple shell scripts will help you.

  1. To move to previous workspace
#!/bin/bash
# To switch to previous workspace

current_workspace=$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true).name' | cut -d"\"" -f2)

next_workspace=0

echo $current_workspace

if [ $current_workspace == "1" ] 
then 
    next_workspace=$current_workspace
else
    next_workspace=`expr $current_workspace - 1`
fi 

i3-msg workspace $next_workspace
  1. To move to next workspace
#!/bin/bash
# To switch to next workspace

current_workspace=$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true).name' | cut -d"\"" -f2)

next_workspace=`expr $current_workspace + 1`

i3-msg workspace $next_workspace

Bind them to your preferred keyboard shortcut.
These give you an idea how to go about it. You can edit them to suit you, for example, put an if statement to wrap back to the first workspace after a certain workspace you assume to be the last. Or if your workspaces aren’t named 1,2,3… then you’ll have to use a map, or use if statements if you don’t mind your script looking tedious.

Edit: you need to have package jq installed for the script to work.

2 Likes

workspace back and forth (with/without active container)

workspace_auto_back_and_forth yes
bindsym $mod+b workspace back_and_forth
bindsym $mod+Shift+b move container to workspace back_and_forth; workspace back_and_forth

This sort of thing?