Start up of an application on a specific desktop

@pavlos_kairis is correct, with these additional steps:

  1. After you store the file, right click it in Caja and select "Properties" from the pop-up menu.
  2. In the Properties dialog, click on the "Permissions" tab.
  3. Check the box next to "Allow executing file as program".
  4. Click the close button on the dialog box.

Regardless of where you place the file, when you create an entry in Preferences/Startup Applications, be sure to enter the entire path and name of the file in the command box. The easy way to do this is to click the Browse button, navigate to the file in the file selection dialog that pops up, and then click the Open button.

Of course, in the script file be sure to replace the name of the program, engrampa or thunderbird, with the name of your app's command: strawberry.

Hope this helps. Please let us know whether it worked.

My apologies. I tested that script with engrampa, but I should have installed strawberry and tested the script with that command before posting my reply above. It turns out that strawberry is a little slower than engrampa, so it requires more delay before switching back to the original desktop (workspace. I had to increase the second sleep delay to two seconds. I also suspect that the more music files you have added to your collection, the more delay there is before strawberry creates its window, so don't hesitate to increase that delay a second or two at a time until you get the right result.

Here's the updated script.

#!/bin/bash

current_desktop=$(xdotool get_desktop)

xdotool set_desktop 1
sleep 1
nohup strawberry &
sleep 2

xdotool set_desktop "${current_desktop}"
2 Likes

(to @pavlos_kairis, @tkn, anyone else who knows ... )

Looking to the future, under Wayland architecture with X11 layer,

  • do those commands still apply ?         or

  • is there a substitute command(s) available to provide the functionality of either wmctrl or xdotool ?

Also, in an "pure"Wayland architecture (without intermediate X11 layer),

  • which substitute command(s) would provide the functionality equivalent to those of either wmctrl or xdotool ?
1 Like
 Xorg    | Wayland (wlroots)
--------------------
 xdotool | ydotool
 wmctrl  | wlctrl

Seems that we don't have to worry :wink:

1 Like

Thanks Dave and Pavlos. I will give it a try later today.

Okay

Here is the file - play:

I put the file in home/jim/play:

Can I make this a hidden file? (.play)

I didn’t know if I had to but I took possession:

chmod +x /home/jim/play

Here I am confused exactly what to put in the startup file, this:

or this:

Then do I still need a Strawberry start up menu or not?

1 Like

Jim - go to Startup apps, create a new entry, there a 4 boxes to be filled.

1st box ... play
2nd box ... /home/jim/.play
3rd box ... play music
4th box ... 0

Line 2 refers to a file (dot play) as /home/jim/.play

that file contains:

#!/bin/bash
current_desktop=$(xdotool get_desktop)
xdotool set_desktop 1
sleep 1
nohup strawberry &
sleep 2
xdotool set_desktop "${current_desktop}"

I'm not sure that .play needs to be exec. Startup takes care of it.
if needed: chmod +x /home/jim/.play

Is this better?

2 Likes

Despite everything it opens on Desktop one (0). It was an idea, but I don’t know if it is worth the effort at this point. I thought it would be relatively easy, which it has not been. Thanks everyone for the help.

1 Like

before reboot
Screenshot at 2025-11-06 13-36-39

after reboot (that box is strawberry)
Screenshot at 2025-11-06 13-38-01

__
tested on um24.04, traditional panel

2 Likes

I think maybe the age and slowness of the laptop my be the problem. It is an Core I3 from around 2010. It takes forever to build the graphics, but is fairly quick after that. I have extended the sleep time from 2 - 30 seconds and it still boot to desktop one. I have never scanned the library so that is not it, and I closed all the playlists and that didn’t work either. I deleted the strawberry startup application and it opens on the play file. My file is exactly as you wrote it, but it still opens on Desktop one. I only use two desktops.

1 Like

I changed my pc to 2 workspaces. It works as expected.

You said your laptop is slow so change the 4th box to 10, that will give it time to startup and after 10 sec run the startup apps (dot play).

Check that you have /usr/bin/xdotool installed. (sudo apt install xdotool).

You could add, logger start dotplay in your script.

after reboot, grep dotplay /var/log/syslog should show you a line.

1 Like

Again, my apologies. The xdotool app is not installed by default on UM, so you'll need to do that before the script has any chance of working:

sudo apt update
sudo apt install xdotool

Keeping my fingers crossed. (I feel like Bullwinkle: "Hey, Rockie. This time for sure!")

1 Like

Okay, I will check on fi xdotool is installed and install it if not. Another question. I have Strawberry set up to start maximized instead of minimized. Could that make a difference?

1 Like

I don't think maximized/minimized/normal should matter. If the script still doesn't work after you install xdotool, you could always try configuring strawberry to start as a normal-sized window. If that works, many apps remember their window size from the last time they executed, so as a workaround you could resize strawberry to almost maximized just before you close it.

But try installing xdotool first, please, and let us know what happens.
Thanks.

1 Like

Interesting behavior. I installed xdotool, logged out an logged back in. Desktop two showed up with Strawberry starting on it, then in about a half second it switched to desktop one. All is good. Well not quite.

Then I rebooted and it booted to desktop one and Strawberry started on Desktop one. Tried both multiple times, that is how it works.

I did fool around with the settings and having the window at a certain size made no difference. What I did do was change it from opening Maximized to opening Minimized. That way it show up on the panel on both desktops but minimized but neither desktop maximized and all I have to do is un-minimize it when I go to desktop two. That is pretty much what I wanted anyway. You can set it to resume playback on start, but I did not want that to happen.

eI probably should have just done that from the start, but didn’t think about it until Dave brought it up. I always had it set to show the main window. I am not sure it is worth further effort. I want to thank everyone for trying to help. You guys are tenacious when trying to solve a problem.

1 Like

If it is not starting on the workspace of choice, then you probably need to increase the sleep time to ensure there is enough time for the application to fully start before switching the workspace. I don't see any other explanation.

1 Like

Work space two doesn’t show up at all like on reboot. I have incrementally increased the time to 10 and deceased it to zero. No differnce.

1 Like

I changed my setup to 2 workspaces, I tested it on a Lenovo M73 which is rather slow. I removed the nohup and set timers 5 for start apps, 5 between workspaces. Here's is music2

#!/bin/sh
logger starting music2
current_desktop=$(xdotool get_desktop)
xdotool set_desktop 1
sleep 5
strawberry &
sleep 5
xdotool set_desktop "${current_desktop}"

It works as expected. After reboot it takes time to go to workspace 2, start strawberry in the background, and then switches to workspace 1. Also, a strawberry icon appears on top right, next to datetime, network, etc.

2 Likes

I have a nagging suspicion here that the random variable is @jymm Jim's startup applications list. This list can vary considerably from user to user, determined by each person's needs and preferences.

In the script, when strawberry launches, it creates its window on the current desktop. The script tries to force that desktop to be Desktop 2 (numbered as 1). But the startup process can launch multiple applications, and one of them may switch the current desktop back to Desktop 1 (numbered as 0) before strawberry has a chance to create its window.

I tried to solve this wilh another xdotool command:

xdotool set_desktop_for_window [window] desktop_number

but I couldn't get it to work. The idea would be to launch strawberry, wait for it to create its window, query the XID for that window, and than move that window to the desired desktop.

Either that command has a bug, or I just don't understand how to invoke it correctly.

2 Likes

Startup apps start defined apps in sequence, they do not start them in parallel. Even if an app decides to switch workspaces, there is lock until that task is completed.

UNIX/Linux is a multi-user, multi-task env; it makes sure there are no conflicts in tasks.

Before rebooting, I started strawberry from Menu > Video > strawberry, resized the window to be 50% on x, 50% on y, closed strawberry. It remembers its window size and position.

Then, I rebooted, wait 5 sec, workspace 2 became active (green color), and showed me the outline of strawberry's window, wait 5 sec and workspace 1 became active.

1 Like