Xfce Forum

Sub domains
 

You are not logged in.

#1 2025-06-09 12:04:53

Fragrant1470
Member
From: Poland
Registered: 2025-03-01
Posts: 32
LinuxFirefox 128.0

How to run .desktop file on system startup

In app finder I have the .desktop file that starts the syncthing service in the background. It has all the metadata I need.


Screenshot-2025-06-09-14-02-59.png

I can simply run the command that the .desktop file runs via session and startup menu, but can I instruct system and startup to run a specific desktop file? This sounds to me like a cleaner solution.

Offline

#2 2025-06-09 12:10:35

eriefisher
Wanderer
From: ON, Canada
Registered: 2008-10-25
Posts: 746
LinuxFirefox 139.0

Re: How to run .desktop file on system startup

Once you've created the .desktop file and know the command works you can place it in /home/user/.config/autostart and it will be run at startup/login.


I AM CANADIAN!
Siduction
Debian Sid
Xfce 4.20 with Wayland/Labwc

Offline

#3 2025-06-10 14:36:43

Fragrant1470
Member
From: Poland
Registered: 2025-03-01
Posts: 32
LinuxFirefox 128.0

Re: How to run .desktop file on system startup

eriefisher wrote:

Once you've created the .desktop file and know the command works you can place it in /home/user/.config/autostart and it will be run at startup/login.

And app finder will still find it because it finds all the .desktop files because of ini file format magic?

Offline

#4 2025-06-10 15:34:46

eriefisher
Wanderer
From: ON, Canada
Registered: 2008-10-25
Posts: 746
LinuxFirefox 139.0

Re: How to run .desktop file on system startup

I'm not sure the app finder will find it because it looks for binaries and scripts. If you create a script and call it in the .desktop file it should be called on startup. You must place the script somewhere in $PATH. Example /home/user/.local/share/applications.


I AM CANADIAN!
Siduction
Debian Sid
Xfce 4.20 with Wayland/Labwc

Offline

#5 2025-06-11 11:45:38

Fragrant1470
Member
From: Poland
Registered: 2025-03-01
Posts: 32
LinuxFirefox 128.0

Re: How to run .desktop file on system startup

eriefisher wrote:

I'm not sure the app finder will find it because it looks for binaries and scripts. If you create a script and call it in the .desktop file it should be called on startup. You must place the script somewhere in $PATH. Example /home/user/.local/share/applications.

So what intrigued me is that syncthing as is came with the .desktop file:

kamil$cat syncthing-start.desktop 
[Desktop Entry]
Name=Start Syncthing
GenericName=File synchronization
Comment=Starts the main syncthing process in the background.
Exec=syncthing serve --no-browser --logfile=default
Icon=syncthing
Terminal=false
Type=Application
Keywords=synchronization;daemon;
Categories=Network;FileTransfer;P2P
Path=
StartupNotify=true
kamil$pwd
/home/kamil/.local/share/applications

Which is actually ran on startup, but it's not shown inside "Session and Startup" menu in the GUI. This is the default path of .desktop files and I don't know where it's actually defined to run this .desktop at startup.

Offline

#6 2025-06-11 12:32:46

eriefisher
Wanderer
From: ON, Canada
Registered: 2008-10-25
Posts: 746
LinuxFirefox 139.0

Re: How to run .desktop file on system startup

I'm not familiar with Syncthing but it looks like it has a daemon. So it's probably put somewhere to run at boot rather than login. You might be able to find it with locate.

updatedb
locate syncthing

updatedb must be run as root or sudo. If you look at your .desktop file under "Categories" you see "Network" so it should show up in the Whisker menu or Applications menu under the Network section.


I AM CANADIAN!
Siduction
Debian Sid
Xfce 4.20 with Wayland/Labwc

Offline

#7 2025-06-11 17:03:06

gogogadget
Member
From: EU
Registered: 2023-03-19
Posts: 36
LinuxFirefox 139.0

Re: How to run .desktop file on system startup

Fragrant1470 wrote:

In app finder I have the .desktop file that starts the syncthing service in the background. It has all the metadata I need.

I can simply run the command that the .desktop file runs via session and startup menu, but can I instruct system and startup to run a specific desktop file? This sounds to me like a cleaner solution.

Syncthing is not installed on my system, but I can get the file list of the package remotely. It doesn't provide a .desktop file, but some systemd services :

pacman -Fl syncthing | grep desktop
~
pacman -Fl syncthing | grep service
syncthing usr/lib/systemd/system/syncthing@.service
syncthing usr/lib/systemd/user/syncthing.service

To me, using a service is a better way to start Syncthing, it start automatically at the start of your session, you don't have to do anything.
(I checked, the service is part of Syncthing sources, it's not specific to my distribution)


EndeavourOS
Xfce+gtk3-classic (no CSD)+Picom

Offline

#8 2025-06-12 11:05:24

Fragrant1470
Member
From: Poland
Registered: 2025-03-01
Posts: 32
LinuxFirefox 128.0

Re: How to run .desktop file on system startup

gogogadget wrote:
Fragrant1470 wrote:

In app finder I have the .desktop file that starts the syncthing service in the background. It has all the metadata I need.

I can simply run the command that the .desktop file runs via session and startup menu, but can I instruct system and startup to run a specific desktop file? This sounds to me like a cleaner solution.

Syncthing is not installed on my system, but I can get the file list of the package remotely. It doesn't provide a .desktop file, but some systemd services :

pacman -Fl syncthing | grep desktop
~
pacman -Fl syncthing | grep service
syncthing usr/lib/systemd/system/syncthing@.service
syncthing usr/lib/systemd/user/syncthing.service

To me, using a service is a better way to start Syncthing, it start automatically at the start of your session, you don't have to do anything.
(I checked, the service is part of Syncthing sources, it's not specific to my distribution)


So then I don't know where the .desktop file came from. This was included in the default Debian installation.

// cwd is /usr/lib/systemd/user/

kamil$cat syncthing.service
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)
StartLimitIntervalSec=60
StartLimitBurst=4

[Service]
ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

# Hardening
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true

# Elevated permissions to sync ownership (disabled by default),
# see https://docs.syncthing.net/advanced/folder-sync-ownership
#AmbientCapabilities=CAP_CHOWN CAP_FOWNER

[Install]
WantedBy=default.target

Below was included with another .desktop file to start the syncthing web UI – it seems syncthing is launched on startup via systemd but this desktop file can be used to execute the same command as systemd in case the user disables it.

kamil$cd ~/.local/share/applications/ 
kamil$cat syncthing-start.desktop 
[Desktop Entry]
Name=Start Syncthing
GenericName=File synchronization
Comment=Starts the main syncthing process in the background.
Exec=syncthing serve --no-browser --logfile=default
Icon=syncthing
Terminal=false
Type=Application
Keywords=synchronization;daemon;
Categories=Network;FileTransfer;P2P
Path=
StartupNotify=true
Hidden=true

At this point there is no 'problem' but I am curious and keen on learning (:

Added later 55 min 29 s:
I have to clarify some things. The syncthing service is not actually ran on startup by default as installed for debian  (from syncthing website).

It comes with the .service file I (contents in previous post) and the .desktop files. I said that it is ran on startup because I forgot that I ran:

kamil$mv -v ~/.local/share/applications/syncthing-start.desktop ~/.config/autostart

But then, systemctl does not find the syncthing service in case I wanted to run the daemon:

kamil$systemctl status syncthing.service                                      
Unit syncthing.service could not be found.

but the file exists in the directory /usr/lib/systemd/user, so why is the service not found?

Offline

#9 2025-06-12 12:48:30

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,018
LinuxFirefox 139.0

Re: How to run .desktop file on system startup

Its a user-based service. Try:

systemctl --user status syncthing.service

Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.010 seconds, 7 queries executed - Memory usage: 590.95 KiB (Peak: 607.8 KiB) ]