Results 1 to 9 of 9

Thread: xfce: How do I start an application on another workspace on autostart?

  1. #1
    Join Date
    Dec 2020
    Beans
    25

    xfce: How do I start an application on another workspace on autostart?

    Running Xubuntu 20.04, I'll be upgrading next year.

    I want to launch PulseEffects on autostart, but I want it to launch on Workspace 4. Here's my attempts:

    Code:
    wmctrl -l -x
    0x0440000a  3 pulseeffects.Pulseeffects  salamilimos-PC PulseEffects
    
    flatpak run com.github.wwmm.pulseeffects && wmctrl -x -r 'pulseeffects.Pulseeffects' -t 3
    
    flatpak run com.github.wwmm.pulseeffects && wmctrl -x -r 'pulseeffects' -t 3
    
    flatpak run com.github.wwmm.pulseeffects && wmctrl -x -r 'PulseEffects' -t 3
    
    flatpak run com.github.wwmm.pulseeffects && wmctrl -F 'pulseeffects' -t 3
    These commands didn't work, PulseEffects loaded on the Workspace I was on instead of on Workspace 4, as I wanted.

    Note, I have another instance of wmctrl running though, this is my video wallpaper which I set on autostart, could this be interfering with this?

    Code:
    bash -c "sleep 2; mpv -loop-file=inf --no-stop-screensaver --no-audio --osc=no --cursor-autohide=no --no-input-default-bindings --wid=$(wmctrl -l|awk '/Desktop/ {print $1}') '/home/salamilimos/Videos/.Razer loop RGB Full HD 60fps Chroma background for   Wallpaper Engine [5le-dkHZLd0].mp4'"

  2. #2
    Join Date
    Jun 2016
    Beans
    2,831
    Distro
    Xubuntu

    Re: xfce: How do I start an application on another workspace on autostart?

    Those commands don't run wmctrl until after PulseEffects quits, and will only run it if PulseEffects exits with status 0 (success).

    Step 1 is to figure out a wmctrl command that you can run manually, while PulseEffects is running, to move it to Workspace 4.

    Once you have that, then you could write a bash script to run PulseEffects in the background (just one & not two), then loop checking wmctrl output for the presence of the PulseEffects window and if it's there, run the wmctrl command you found to move PulseEffects to Workspace 4 and then exit the script.
    Xubuntu 22.04, ArchLinux ♦ System76 hardware, virt-manager/KVM, VirtualBox
    When your questions are resolved to your satisfaction, please use Thread Tools > "Mark this thread as solved..."

  3. #3
    Join Date
    Aug 2017
    Location
    melbourne, au
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: xfce: How do I start an application on another workspace on autostart?

    You realize Xfce can restore set applications at session start.

    Refer https://docs.xfce.org/xfce/xfce4-session/start

    Xfce4-session is a session manager for Xfce. Its task is to save the state of your desktop (opened applications and their location) and restore it during a next startup. You can create several different sessions and choose one of them on startup.

  4. #4
    Join Date
    Dec 2020
    Beans
    25

    Re: xfce: How do I start an application on another workspace on autostart?

    Quote Originally Posted by halogen2 View Post
    Those commands don't run wmctrl until after PulseEffects quits, and will only run it if PulseEffects exits with status 0 (success).

    Step 1 is to figure out a wmctrl command that you can run manually, while PulseEffects is running, to move it to Workspace 4.

    Once you have that, then you could write a bash script to run PulseEffects in the background (just one & not two), then loop checking wmctrl output for the presence of the PulseEffects window and if it's there, run the wmctrl command you found to move PulseEffects to Workspace 4 and then exit the script.
    Running these commands in two terminals works though:

    Opens PulseEffects:
    Code:
    flatpak run com.github.wwmm.pulseeffects
    Moves PulseEffects to Workplace 4:
    Code:
    wmctrl -r PulseEffects -t 3
    However, putting these together in a command doesn't work though:

    Code:
    flatpak run com.github.wwmm.pulseeffects && sleep 25 && wmctrl -r PulseEffects -t 3
    I figured out a dirty workaround:

    I created two .desktop files and saved them in /home/salamilimos/.config/autostart/ with the following:

    Code:
    [Desktop Entry]
    Version=1.1
    Type=Application
    Exec=bash -c "sleep 5 && flatpak run com.github.wwmm.pulseeffects"
    and

    Code:
    [Desktop Entry]
    Version=1.1
    Type=Application
    Exec=bash -c "sleep 20 && wmctrl -r PulseEffects -t 3"
    They worked.

    I no idea why putting the two commands together doesn't work though.

  5. #5
    Join Date
    Dec 2020
    Beans
    25

    Re: xfce: How do I start an application on another workspace on autostart?

    Quote Originally Posted by guiverc View Post
    You realize Xfce can restore set applications at session start.

    Refer https://docs.xfce.org/xfce/xfce4-session/start
    I couldn't figure this out though.

  6. #6
    Join Date
    Jun 2016
    Beans
    2,831
    Distro
    Xubuntu

    Re: xfce: How do I start an application on another workspace on autostart?

    Quote Originally Posted by salamilimos View Post
    putting these together in a command doesn't work though:

    Code:
    flatpak run com.github.wwmm.pulseeffects && sleep 25 && wmctrl -r PulseEffects -t 3
    Again, because the way you are putting them together means PulseEffects must exit with a success status before the sleep and wmctrl commands are run. To achieve what you want, use only one & after the PulseEffects command.

    I figured out a dirty workaround:

    I created two .desktop files and saved them in /home/salamilimos/.config/autostart/ with the following:
    That's pretty close to one possible actual solution.

    You could combine your two desktop files into one -
    Code:
    [Desktop Entry]
    Version=1.1
    Type=Application
    Exec=bash -c "sleep 5;flatpak run com.github.wwmm.pulseeffects & sleep 20;wmctrl -r PulseEffects -t 3"
    Xubuntu 22.04, ArchLinux ♦ System76 hardware, virt-manager/KVM, VirtualBox
    When your questions are resolved to your satisfaction, please use Thread Tools > "Mark this thread as solved..."

  7. #7
    Join Date
    Dec 2020
    Beans
    25

    Re: xfce: How do I start an application on another workspace on autostart?

    Quote Originally Posted by halogen2 View Post
    You could combine your two desktop files into one -

    Code:
    [Desktop Entry]
    Version=1.1
    Type=Application
    Exec=bash -c "sleep 5;flatpak run com.github.wwmm.pulseeffects & sleep 20;wmctrl -r PulseEffects -t 3"
    That worked thank you.

    So, my previous attempts failed because I was using two "&&" instead of one "&"? Based off my reading of your posts, the difference between "&" and "&&" is that using one "&" doesn't allow the program to exit while the next command runs, while "&&" exits the program and does the next command. Is this correct? I'm not exactly terminal savvy.

  8. #8
    Join Date
    Jun 2016
    Beans
    2,831
    Distro
    Xubuntu

    Re: xfce: How do I start an application on another workspace on autostart?

    You're welcome.

    Quote Originally Posted by salamilimos View Post
    So, my previous attempts failed because I was using two "&&" instead of one "&"?
    Yes, that was dooming your previous attempts to fail.

    Based off my reading of your posts, the difference between "&" and "&&" is that using one "&" doesn't allow the program to exit while the next command runs, while "&&" exits the program and does the next command. Is this correct?
    Using just one & after a command means "run the command in the background", i.e. free up the shell to continue on with running other commands without waiting for that command to exit.

    "&&" is something completely different. It is used to chain two commands together. The command on its right will not run unless and until the command on its left exits with the success status 0.

    Hope this helps clarify.
    Xubuntu 22.04, ArchLinux ♦ System76 hardware, virt-manager/KVM, VirtualBox
    When your questions are resolved to your satisfaction, please use Thread Tools > "Mark this thread as solved..."

  9. #9
    Join Date
    Dec 2020
    Beans
    25

    Re: xfce: How do I start an application on another workspace on autostart?

    Quote Originally Posted by halogen2 View Post
    You're welcome.



    Yes, that was dooming your previous attempts to fail.



    Using just one & after a command means "run the command in the background", i.e. free up the shell to continue on with running other commands without waiting for that command to exit.

    "&&" is something completely different. It is used to chain two commands together. The command on its right will not run unless and until the command on its left exits with the success status 0.

    Hope this helps clarify.
    Thanks for the explanation. I learn something new everyday. Thanks!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •