7

I am using Manjaro Linux 18 (Arch Linux based Linux distro). I am using XFCE desktop environment. I have 8 workspaces on my computer. How do I move to the next and previous workspace using the command line?

I have Googled and found multiple apps on Github that are said to do that, but none seem to work.

  • I am curious what doing this on the command line would be used for? In case you are new to Xfce, you can set keyboard shortcuts for switching workspaces in Window Manager > Keyboard. There are quite a few options. – jbrock Mar 21 '19 at 14:39
  • 2
    @jbrock It's for libinput-gestures for my laptop's touchpad. I want this command to be executed when I do a gesture. – Blake Mc Jones Mar 22 '19 at 05:50
  • 1
    Here's my application FWIW, when I work on a substantial project I write a little "workspace" script to open and arrange all the windows I will use the way I want them to be, including browser windows and tabs, and multiple screen sesssions with multiple tabs and programs running in some of them. I also want to use and set up two virtual desktops, one for focused work and the other for communication and entertainment (playing music, random browsing, or whatever). – Sam Watkins Mar 18 '21 at 23:34

2 Answers2

15

I had the same issue with going to the previous workspace. Eventually I found a solution. Try replacing:

xdotool set_desktop --relative -1

with:

xdotool set_desktop --relative -- -1

Answer was found in the comments on: https://askubuntu.com/questions/41093/is-there-a-command-to-go-a-specific-workspace

RalfFriedl
  • 8,816
  • 6
  • 23
  • 34
9

You will need xdotool.

Installation

sudo pacman -S xdotool

Usage

Going to the next workspace

xdotool set_desktop --relative 1

Going to the previous workspace

xdotool set_desktop --relative -1

NOTE: Negative numbers are said to be allowed, but some versions of xdotool do not allow negative numbers or at least give an error. Test negative numbers before you implement scripts with negative numbers.

Work around for going to the previous workspace If you have n workspaces, then for going into the previous workspace

xdotool set_desktop --relative n-1

where n = number of workspaces.

Example: n = 8 workspaces

xdotool set_desktop --relative 7

Prajwal
  • 718
  • 1
  • 7
  • 10
  • 3
    I had to use this command to move to previous workspace: `xdotool set_desktop --relative -- -1` – jbeard4 Apr 10 '21 at 05:03