3

Running lubuntu desktop on samsung N145 netbook.

I got so far as /etc/xdg/lxsession/Lubuntu/autostart and added the line

@home/magpie/touchpad_settings.sh

Where the name of my file is touchpad_settings.sh and it does execute and work if clicked then executed.

This meant I could no longer login and get my panels though, so I undid it with my USB booter and came here to see if anyone could clarify.

Lubuntu does not use a startup manager and this is a home-made file so it won't be in Desktop session settings either.

As suggested in answers below I tried

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/bin/sh /home/magpie/touchpad_settings.sh
exit 0

I also tried the lines:

/bin/bash /home/magpie/touchpad_settings.sh

and

sh /home/magpie/touchpad_settings.sh

which did not work.

Magpie
  • 1,285
  • I've added another way that might work, based on two excellent articles on creating .desktop entries on the Lxde desktop. –  Jul 22 '12 at 21:08
  • I have used this way before for my eclipse installation. I will try the other way. Thanks. Can I ask does it have to be desktop or can it be a made-up folder like applications? I hate desktop clutter... – Magpie Jul 22 '12 at 21:58
  • No its not on the desktop- you need to create a file called whatever.desktop and place that in a folder called autostart and place all that in the .config folder in your home folder -see the articles and my post for how to create a .desktop entry. –  Jul 22 '12 at 22:03
  • That makes a bit more sense. LXDE has a few differences to the others but I created desktop thing before with my eclipse, so I think it should be ok to do again just by looking at my terminal history. Hopefully after that the start-up setting will be clear after that. Though I am cautiously optimistic as I am wondering why I have to create a file to do it, surely there is a file that handles this stuff in lubuntu too? I will report how I got on anyway – Magpie Jul 22 '12 at 22:21

5 Answers5

6

In the file manager, go to /usr/share/applications. Open it with root access (Tools -> Open Current Folder as Root)

Open as root

In your root access file manager window, create a new file (File -> Create New -> Blank File)

blank file

Name the new file touchpad.desktop.

file name

Find your newly created file, right-click it, edit it with leafpad.

enter image description here

In leafpad, paste the following:

[Desktop Entry]
Name=Touchpad Autostart
Exec=/home/magpie/touchpad_settings.sh
Type=Application
Terminal=false

Save it. If you can't save it, you are not in the window with root access. Start over again and follow the directions really carefully.

Again, find your file in the root access file manager window. Right-click and copy.

Copy

Now navigate your root window to the autostart folder:

/etc/xdg/autostart/

Finally, paste in your desktop file you created earlier.

Autostart File

If you did everything correctly, you should see a lot of other autostart files, but you will also see the file, "Touchpad Autostart"

It's there...

This is not the fastest way to do things, but you seemed to be struggling with a lot of steps in the other answers, so I wanted to take it slow with a lot of details. If your script is still not running after rebooting (do not simply logout and back in), it's a problem with your script. Maybe double check?

4

Open /etc/rc.local in your editor with root permission and add the command you want to execute at startup before the line exit 0 in that file.

In your case it is

sh home/magpie/myfile.sh
Anwar
  • 76,649
Sarowar
  • 336
  • 4
  • 8
1

There are several ways of doing it; the easiest may be to follow these instructions at this page and this one and create a folder called autostart to go in the .config folder and then create a .desktop entry with your text editor and save it in the autostart folder. The desktop entry should have the following lines

  [Desktop Entry]
  Name=script.sh
  Exec=/home/mike/script.sh
  Type=Application
  Terminal=false

Another way is by using the rc.local file:

You usually add the complete path of your script to the rc.local file at /etc/rc.local; rc.local is executed only after everything else has started up, and must be made executable (sudo chmod +x), if it isn't already. (Sudo is necessary as the script is owned by root, and that is why some may see it as a security issue for root to start a users's script, but for home desktop users it is reasonable to use the rc.local method.)

However, make sure that you leave the exit 0 as the last line of the rc.local script: for example, my rc.local file contains the location of a script and two other commands. If you want to make sure your script is run by /bin/sh or /bin/bash, put that in front of the path; e.g. /bin/bash /home/mike/script.

Finally, use either sudo vi /etc/rc.local or gksudo gedit /etc/rc.local to edit the file.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing
# my script here
/bin/bash /home/mike/bin/script
exit 0
  • hi thanks I am about to have a try of this but firslty can you tell me what the setkeycodes bit is about ? – Magpie Jul 22 '12 at 18:38
  • No don't use the setkeycodes bit-that's just my own personal additions in my rc.local file, I'll edit it out of the post. –  Jul 22 '12 at 18:40
  • yeah that might be best, it's a little confusing! Thanks. I'm trying now I'll let you know if it worked on reboot! – Magpie Jul 22 '12 at 18:43
  • no unfortnately that didnt work but now when I open the file manager it gives error sign saying "Transport endpoint is not connected" any ideas? – Magpie Jul 22 '12 at 19:16
  • 1
    It should work and if it didn't nothing will have changed in your system. I have experimented many times with giving rc.local commands and scripts to run. I have never heard of the error, but it is unrelated to rc.local. –  Jul 22 '12 at 19:20
  • yeah sorry. I got rid of the error, it was a bin/bash line I had put in the script from myfile.sh file. I got rid of it now. Unfortunately the file still seems to need to be executed manually to work :( – Magpie Jul 22 '12 at 19:22
  • What does the script do? –  Jul 22 '12 at 19:24
  • it's a touchpad configuration to fix the taptoclick and another annoying default settings it contains: "synclient MaxTapTime=0" and a few other commands for synclient and that is all. It works when I click it and execute it but I am starting to think maybe an .sh file is not as suitable for Lubuntu or something ? – Magpie Jul 22 '12 at 19:43
  • You could try /bin/sh –  Jul 22 '12 at 20:01
  • I've tried both and the suggestion made by sarowar too nothing has worked. I used my root privs to edit the file in etc/rc.local and only edited the line. I will edit my post to show what I put because that's easier to see. I have not a clue why it's not working for me. Could it be that I need to have my .sh somewhere else in the first place? – Magpie Jul 22 '12 at 20:05
1

Here is the simplest way i've been adding autostart programs in LXDE environment.

  1. make 'the.sh' to execute the program you want and save it to /home/user/.config/autostart/the.sh (remember tomake it executeable)
  2. now add to the /home/user/.config/lxsession/LXDE/autostart file a line @sh /home/user/.config/autostart/the.sh and restart the computer. thats it.

NB! some programs need to be delayed at startup so for an example the 'conky.sh' must be

#!/bin/sh

sleep 3
conky

--so maybe the first way you tried to autostart 'touchpad_settings.sh' just needs a delay in .sh file.

user672009
  • 125
  • 1
  • 7
0

You just used a wrong path in /etc/xdg/lxsession/Lubuntu/autostart:
In the line:

@home/magpie/touchpad_settings.sh 

the @ will be removed, and the rest executed as a shell command.

It uses a relative path:

home/magpie/touchpad_settings.sh 

So if the current working directory is /home/magpie, the script it runs is /home/magpie/home/magpie/touchpad_settings.sh

Add a / to fix it, and make sure the script has the execute permission:

@/home/magpie/touchpad_settings.sh

(The @ means it will get restarted if it exits.)

Volker Siegel
  • 13,065
  • 5
  • 49
  • 65