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.

3
  • 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
    Commented Mar 21, 2019 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. Commented Mar 22, 2019 at 5: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). Commented Mar 18, 2021 at 23:34

2 Answers 2

17

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

3
  • Thanks, this worked for me too
    – J-Cake
    Commented Feb 7, 2020 at 0:58
  • Thank you. This worked for Ubuntu 20.4 with xdotool version 3.2
    – Prajwal
    Commented Jul 3, 2020 at 22:45
  • Heed this answer. The accepted answer does not work for negative numbers.
    – markling
    Commented Sep 5, 2022 at 8:55
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

1
  • 3
    I had to use this command to move to previous workspace: xdotool set_desktop --relative -- -1
    – jbeard4
    Commented Apr 10, 2021 at 5:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .