Automatic startup script/program Linux Mint 12/LXDE

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Krookroo

Automatic startup script/program Linux Mint 12/LXDE

Post by Krookroo »

Hello all.
I'm new to linux for one week now. For the moment, linux mint is quite a pleasant os to use, but as I'm still new it is still inferior to "windows ?" in my hands in terms of productivity (which doesn't mean that I consider LM12 inferior of course, this is just a statement).
In an attempt to "customize" my OS and getting it better suited to my needs, I wish to be able to add scripts or programs to be launched on startup. After a bit of searches over this forum and the web, here is where I am:

=> A tip I could read was to go through the startup application manager, however (unless I made an embarrassing mistake) in LM12 LXDE, in the menu/preference what I have is the "desktop session settings" which seems to manage the startup program, and I wasn't able to find how to add a line or script. However, even if it would have worked this way the solution would have been totally distro-dependant since I would'nt have been able to do the same on another distro without this feature, so quite happily I thought that I had to learn a few things to get it work!

=> Tried to play with the /etc/init.d directory. What I basically did was:

1/ creating a test script in /etc/init.d:

test:
#! /bin/sh

PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="enables logitech g300 mouse to work properly"
NAME=test
SCRIPTNAME=/etc/init.d/$NAME


# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# launches lxterminal
#
do_start()
{
lxterminal
}

#
# does nothing
#
do_stop()
{

}

case "$1" in
start)
do_start
;;
stop)
;;
restart|force-reload)
;;
esac

:
What I did here was taking another script which seemed to work at startup, deleting the entries which I though had only something to do with the initial task and not with mine. As I didn't really had a clue about what the lsb stuff at the beginning was here for, I did let it stay.
I also made the file executable through:

Code: Select all

chmod 755 /etc/init.d/test
2/ Link it to the file that will be used at startup (don't really have a clue about how this works, neither about how the startup process is going on, but...)
I went

Code: Select all

sudo update-rc.d /etc/init.d/test defaults
It actually seemed to work and create the links even if the lsb wasn't very happy (I suppose I did delete too much things in when I wrote "test", however I kept going on since I read that lsb was some kind of a "model" which files in here should adopt for stability issues or something along the way and did not seem to prevent execs from working, but I may(must) have read too fast).
(maybe I had to deal with some permission issues along the way also, I don't really remember, sorry about not being able to be more precise)

3/ Reboot and no lxterminal got launched.

I also have a few questions:
-> which programming language is used in "test"? I searched a few minutes though google but wasn't able to find it out, probably a keyword issue, I ask this because it will be faster and possibly more precise that way. If you think it is only laziness then sorry and don't take the time to answer :)
-> does the problem come from the command line to call the program? I did this way because I sort of thought that I read this was the way the previous file went to call programs.
-> how (very basically of course, just to get the starting idea from which I will be able to document myself efficiently) does the system boots (loading of kernel then??? in fact the "mechanics" of booting)
-> In my opinion, loading a script or a program on startup would be exactly the same in terms of command lines and stuff, because to read a script and having it have an effect I need to call a program which runs through the script. Am I right?
(if not then it's stupid for me to "test" by launching lxterminal because the first idea was to launch a script (to fix some hardware issue)

Thank you in advance, and sorry for the huge post!

Edit: I forgot to mention that I'm not really advanced in the world of computer sciences. I have a few basics of how things work, and had basics courses in the university and a few hours using python as a programming language but please consider me as someone who doesn't know a programming language, just switched to linux and wasn't an advanced user under windows.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Krookroo

Re: Automatic startup script/program in Linux Mint 12 / LXDE

Post by Krookroo »

Looks like I'm starting quite well in the wrong section, sorry about that.
Might a moderator move my topic to the appropriate (LXDE/newbie questions) or should I copy it there myself and they will delete this one?
User avatar
Oscar799
Level 20
Level 20
Posts: 10398
Joined: Tue Aug 11, 2009 9:21 am
Location: United Kingdom

Re: Automatic startup script/program in Linux Mint 12 / LXDE

Post by Oscar799 »

Moved here by moderator
Image
User avatar
nunol
Level 9
Level 9
Posts: 2633
Joined: Sun Mar 06, 2011 9:25 pm
Location: Portugal

Re: Automatic startup script/program in Linux Mint 12 / LXDE

Post by nunol »

Not sure if this is what you want but for starting programs or scripts in LXDE you can do this: http://blip.tv/file/get/Llelectronics-L ... art754.m4v

If the script starts with "#! /bin/sh" then it's Bash but you can start others:
Some typical shebang lines:

#!/bin/sh — Execute the file using sh, the Bourne shell, or a compatible shell
#!/bin/csh — Execute the file using csh, the C shell, or a compatible shell
#!/usr/bin/perl -T — Execute using Perl with the option for taint checks
#!/usr/bin/ruby — Execute using Ruby
#!/usr/bin/python -O — Execute using Python with optimizations to code
#!/usr/bin/php — Execute the file using the PHP command line interpreter
http://en.wikipedia.org/wiki/Shebang_%28Unix%29
http://tldp.org/LDP/Bash-Beginners-Guid ... Guide.html
Krookroo

Re: Automatic startup script/program in Linux Mint 12 / LXDE

Post by Krookroo »

Thank you for the information about the start of files that could be used, your links are bookmarked.
Thanks to also your first link, I managed to bring an application at startup. However the .sh script doesn't seem to load. Just in case, here's the line in the xxx.desktop file:

Code: Select all

Exec=~/.ipconfig/autostart/logitechg300.sh
I strictly followed the video. I have the exact same file working with

Code: Select all

Exec=lxterminal
I did not try with "Exec=sh file.sh" but I'm not really sure it's worth the 30 seconds.

Edit: yes, this tip would basically do the job, but I was looking for a more "dirty hands" way to do this, in order to learn some useful stuff. In fact, I'm new to linux, and decided to go with a "ready" distribution as a start and moving as fast as possible to a more tunable environment, hence my questions.
seppalta

Re: Automatic startup script/program in Linux Mint 12 / LXDE

Post by seppalta »

I'm not sure what you are trying to do, but if you just add lxterminal to autostart, it will launch at boot. Similar for exec of any application. Autostart is at /etc/xdg/lxsession/lubuntu/autostart. http://lxlinux.com
Last edited by seppalta on Fri Aug 10, 2012 12:31 am, edited 1 time in total.
Krookroo

Re: Automatic startup script/program in Linux Mint 12 / LXDE

Post by Krookroo »

Okay, maybe I did not write things clear enough, english isn't my first language so apologizes about this :)
In fact, my mouse does not work well in linux mint. I have a bash script which fixes this, but I have to manually launch it each time I log in, and this is annoying, so I tried to look how to get it launched automatically on startup. For my tests on how to "manually automate the autostart", I used lxterminal, because it is faster for me to see if it worked, and I don't have my mouse allways plugged on my laptop.

I'll have a look at your links, thank you for taking the time :)

Edit: many thanks. If anyone else asks himself the question:
sudo leafpad /etc/xdg/lxsession/Mint-LXDE/autostart
add simply a line:
@yourcommandline
and it works.
Krookroo

Re: Automatic startup script/program Linux Mint 12/LXDE

Post by Krookroo »

Hop, in fact the problem is not fully solved:
this solution is ran twice at login! I would like to have it run only once!
I made a test by adding at the end of the file

Code: Select all

@lxterminal
and on startup I have two of them launching (and of course when I comment that line I don't have any popping up!)

Not that it is a problem in that case (since I have another location where I can put my link towards an application for startup), however if I want to custom things with a script that shouldn't be ran twice, then the solution isn't one.

Any idea?
etisdale

Re: Automatic startup script/program Linux Mint 12/LXDE

Post by etisdale »

Krookroo wrote:Any idea?
Krookroo, have you tried to copy the .desktop file of the program you want to autostart into /home/[user]/.config/autostart? The .desktop files can be found in /usr/share/applications. Once the program's .desktop file is in /home/[user]/.config/autostart, you should be able to go to Menu > Preferences > Desktop Session Settings and enable/disable autostarting the program under Automatically Started Applications.

This method has worked well for me, but I found my way to this thread because I am currently having problems getting Thunderbird to autostart.
Locked

Return to “Software & Applications”