[Solved] What is the shell command to change workspace?

Forum rules
Before you post please read this

[Solved] What is the shell command to change workspace?

Postby sadhu on Wed Dec 11, 2013 1:05 pm

I would like to write a simple shells script that would do the following

1. switch to workspace #N
2. run some app.[/list]

I can't seem to get xdotools to work, and in any case a script seems to be a more straightforward solution.

Back in the DOS days I had dozens of startup scripts (batch files), so this approach is nothing new.
Last edited by sadhu on Thu Dec 12, 2013 12:50 am, edited 1 time in total.
sabbe satta bhavantu sukhitatta
sadhu
Level 2
Level 2
 
Posts: 65
Joined: Fri Nov 22, 2013 9:48 am

Linux Mint is funded by ads and donations.
 

Re: What is the shell command to change workspace?

Postby xenopeek on Wed Dec 11, 2013 3:36 pm

Try wmctrl instead. To switch to workspace N, you give the command `wmctrl -s N-1`. So to switch to your second workspace that would be:
Code: Select all
wmctrl -s 1

To switch back to your first workspace:
Code: Select all
wmctrl -s 0

You don't really need a script for this though. Say you are on the first workspace and want to switch to the second workspace and open Firefox there, the command to use would be:
Code: Select all
wmctrl -s 1 && firefox

If you want to use this as a launcher in your menu you need to change the command to be:
Code: Select all
bash -c "wmctrl -s 1 && firefox"
Forum Rules | IRC Channel Rules
Image
Arch Linux / 64-bit / Gnome Shell
User avatar
xenopeek
Level 21
Level 21
 
Posts: 13682
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: What is the shell command to change workspace?

Postby sadhu on Thu Dec 12, 2013 12:50 am

Works beautifully!
TYVM
sabbe satta bhavantu sukhitatta
sadhu
Level 2
Level 2
 
Posts: 65
Joined: Fri Nov 22, 2013 9:48 am

Re: [Solved] What is the shell command to change workspace?

Postby ericramos1990 on Wed Mar 26, 2014 1:16 pm

In case you wanted the xdotool solution, I use

Code: Select all
xdotool set_desktop 0


0 being the first workspace.

I only use 2 workspaces, so I made a script that toggles between both :)

Code: Select all
#!/bin/bash
aplay ~/notifications/workspace.wav &
if [ $(xdotool get_desktop) = 1 ]
then
xdotool set_desktop 0
else
xdotool set_desktop 1
fi


The first line is the sound effect from Cinnamon to switch workspaces you can find here:
/usr/share/mint-artwork-cinnamon/sounds/switch.oga

I had to convert it to .wav for aplay to play though
Keep on tuxin' =)
User avatar
ericramos1990
Level 3
Level 3
 
Posts: 129
Joined: Sun Jul 21, 2013 11:54 am


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 2 guests