How to run a script / Terminal Command on startup automatically in Debian lxde?

Please post all general support questions for LXDE here.
Post Reply
bkpsusmitaa
Posts: 8
Joined: Sat Apr 25, 2015 12:08 pm

How to run a script / Terminal Command on startup automatically in Debian lxde?

Post by bkpsusmitaa »

I have posted this topic on debian-users forum. I am nearing a solution. But it appears that the list leaders and senior members aren't aware of the specifics of lxde session that I have been using since 2007.

Incidentally, I installed the Debian system from a Live-ISO. I use the Debian lxde session, having installed the Official Debian GNU/Linux Live 11.6.0 lxde 2022-12-17T11:46.

I have learnt launching a GUI program when the system starts up to begin the GUI using the GUI application called "Default applications for LXSession" accessible from Start Menu / Preferences, which runs the command lxsession-default-apps, from lxsession-default-app.desktop, target file /usr/share/applications/lxsession-default-apps.desktop. The binary is at /usr/bin.

But I am not aware of how to automatically run a script or a command (that is run at the command prompt of terminal) at the start up of every session.

Could you please advise and/or direct me to the appropriate lxde help files in this regard?
williamenriquez
Posts: 1
Joined: Tue Jul 04, 2023 3:36 am

Re: How to run a script / Terminal Command on startup automatically in Debian lxde?

Post by williamenriquez »

Hi,
To automatically run a script or command at the start up of every LXDE session, you can use the "Autostart" feature. Here are the steps to do this:
1. Open your file manager and navigate to the following directory: ~/.config/autostart/. If the autostart directory does not exist, you can create it.

2. Create a new file in the autostart directory with a .desktop extension. You can name the file whatever you like, but it must end with .desktop.

3. Open the file in a text editor and add the following lines:

Code: Select all

[Desktop Entry]
Type=Application
Name=My Application
Exec=/path/to/my/script
4. Replace "My Application" with a name for your application, and replace "/path/to/my/script" with the path to your script or command.

5. Save the file and exit the text editor. bloxd io

6. Restart your LXDE session, and your script or command should automatically run.
Note that the script or command must be executable and have the correct permissions to run. You can make a script executable by running the command chmod +x /path/to/my/script.
Post Reply