Start up of an application on a specific desktop

I use a laptop for a jukebox with wireless speakers on my patio.

I use two desktops. My desktops are simply named ‘one’ and ‘two’. I have Strawberry Music player set to start up when I boot up. The OS (Ubuntu Mate 24.04) always boot so desktop ‘one’, and so does Strawberry.

Is there a way to get Strawberry to start on Desktop ‘two’ on startup instead of desktop ‘one’?

ps I have no idea on how to write a script

There is a command that can communicate with your windowmanager (marco)

sudo apt install wmctrl

From the commandline you can now switch to the 2nd workspace:

wmctrl -s1

(wmctrl starts to count at zero, so your first workspace is 0 , the second is 1, etc)

if you start strawberry now, it will start on the second workspace.

This is scriptable:

#!/bin/bash

wmctrl -s1
strawberry &
wmctrl -s0

You can add this script to 'autostart applications'

There are other solutions but none as simple as this one

6 Likes

... and, presumably, that would be included in an

  • rc.local

file.

:slight_smile:

1 Like

No, that wouldn't work. The script can only be started after the user logged in, X has started and following that, the windowmanager.
So it can only be called from a .desktop file in $HOME/config/autostart/

The mate-control-center -> Startup Applications GUI will create this file automagically for you :slight_smile:

4 Likes

Thanks for the information.

1 Like

Please excuse my ignorance on this but here is what I did:

I installed sudo apt install wmctrl sucessfully.

then I used pluma to make a config file named <wmctrl -s1.config> and saved it in home>jim> .config

the files contains this:

#!/bin/bash

wmctrl -s1
strawberry &
wmctrl -s0

Strawberry did not start at all so I then went to system>preferences>personal>startup applications and made an entry for Strawberry and gave it a one second delay. It now starts but still on desktop one.

I am sure I am either missing something or don’t understand the instructions.

1 Like

Tricky name. Best practice is to avoid dashes and spaces, otherwise you have to be constantly alert to quote the name accurately.

A descriptive name would probably better, also to avoid mistakes and such.
You better rename it to strawberry_2nd_workspace.sh or something like that.

Also, a better place to store the script (conforming to convention) is in /home/jim/.local/bin
This has also the benefit of not needing the complete path to call it.

This command will take care of those things.

mv /home/jim/.config/'wmctrl -s1.config'  /home/jim/.local/bin/strawberry_2nd_workspace.sh 

Sorry, I forgot to mention that you have to make the script executable.
Use this:

chmod a+x  /home/jim/.local/bin/strawberry_2nd_workspace.sh

The autostart entry should be then strawberry_2nd_workspace.sh

That is to be expected. You need to call the script, not strawberry directly.
The script is not a configfile. It is an executable program, albeit very short :slight_smile:

By the way, you can test the script from terminal: strawberry_2nd_workspace.sh

2 Likes

Thanks, as I said I had no idea how to make a script, I will give these instructions a try.

2 Likes