How to autorun applications after x starts?


12 posts
by ShuttleMunky » Mon Oct 01, 2012 7:59 pm
Hi.. I am a total linux, therefore raspbian noob.

I have four questions actually id appreciate answers...

1: Currently i only have 1 keyboard and using it for my main windows pc... I don't want to plug it to Rpi everytime i switch the display to it from my monitor...
So i installed Matchbox-Keyboard application.
I need to type "Matchbox-Keyboard" in the terminal to start it... But i want it automatically start when Desktop UI starts. How can i do it?

2: And how exactly i can control my pi from my Windows 7 pc? I heard SSH and Putty stuff. But i am completely clueless about those. I really need some detailed "how to" to it...

3: How can i change my screen resolution? As it says "couldn't detect monitor" or something like that when i open monitor settings... The display is not fitted to my 1080p screen...

4: And how do i access that config file everybody is talking about, where you can config a lot of things?


Thanks...
Last edited by ShuttleMunky on Mon Oct 01, 2012 8:01 pm, edited 1 time in total.
Posts: 9
Joined: Sat Sep 29, 2012 12:03 am
by penguintutor » Wed Oct 03, 2012 11:09 am
1/ To start an application when the GUI starts add a .desktop file to the autostart directory

Code: Select all
mkdir ~/.config/autostart
touch ~/.config/autostart/matchbox-keyboard.desktop


Then open the matchbox-keyboard.desktop file in your preferred editor (the .config folder is hidden so you may need to turn on show hidden files if you are looking in file manager) and add the details.

The format is available here http://standards.freedesktop.org/desktop-entry-spec/latest/

You probably need something like (not sure whether any additional entries required)
Code: Select all
[Desktop Entry]
Name=Matchbox-keyboard
Exec=matchbox-keyboard
Type=application


2/ To run ssh / vnc
SSH should be just a case of installying Putty on your Windows computer and entering the IP address of the Raspberry Pi - you can use
Code: Select all
ip addr
to get your IP address

For vnc I've written a guide http://www.penguintutor.com/linux/tightvnc

3/ Change resolution

You need to change the config.txt file
Details of the different resolutions available is on the wiki http://www.elinux.org/RPi_config.txt#Video_mode_configuration

4/ config.txt

It's in the /boot/ directory.

You can edit using

Code: Select all
sudo nano /boot/config.txt


You can also edit by taking the SD card out of the Pi and putting it into a Windows PC. The disk drive that mounts is the /boot partition.

Note this is completely different from the .config directory mentioned in section 1.
User avatar
Posts: 356
Joined: Tue May 08, 2012 9:11 am
Location: UK
by ShuttleMunky » Wed Oct 03, 2012 9:59 pm
Thank you MR!

looking forward to try those as soon as i get home...
Posts: 9
Joined: Sat Sep 29, 2012 12:03 am
by GrayHatter » Wed Oct 03, 2012 11:24 pm
you should also read http://askubuntu.com/questions/47642/ho ... pc-via-ssh it might actually be how you want to handle using your pi.

putty is a way to interact with your pi from a different computer via the command line (the way everything is done in linux)

ssh or SSH: Secure SHell is the method for talking from computer to computer. Like http(s) is your web browser.

and... http://www.amazon.com/107-Key-Windows-K ... B0038M3YM8
Posts: 18
Joined: Tue Sep 25, 2012 6:29 pm
by jakep » Wed Feb 20, 2013 11:30 am
hello, just wondering if you got Match-box to load from start up ? i am trying myself to do this but aimlessly failing! any help would be appreciated!!
Posts: 4
Joined: Tue Feb 19, 2013 10:56 am
by GrayHatter » Wed Feb 20, 2013 5:30 pm
jakep wrote:hello, just wondering if you got Match-box to load from start up ? i am trying myself to do this but aimlessly failing! any help would be appreciated!!


What OS are you running?
Posts: 18
Joined: Tue Sep 25, 2012 6:29 pm
by asilrohit » Fri Jul 18, 2014 10:48 am
hi renguintutor!
This works! thanks for the knowledge sharing!
I a trying to run an application on startup but also want to disable xsession or basically user should not be able to access taskbar or other gui apps. How do i go about it?

Thanks, help much appreciated!
Posts: 2
Joined: Fri Jul 18, 2014 8:53 am
by Casey Scalf » Sun Apr 19, 2015 7:50 pm
[quote="penguintutor"]1/ To start an application when the GUI starts add a .desktop file to the autostart directory

Code: Select all
mkdir ~/.config/autostart
touch ~/.config/autostart/matchbox-keyboard.desktop


Then open the matchbox-keyboard.desktop file in your preferred editor (the .config folder is hidden so you may need to turn on show hidden files if you are looking in file manager) and add the details.

The format is available here http://standards.freedesktop.org/desktop-entry-spec/latest/

You probably need something like (not sure whether any additional entries required)
Code: Select all
[Desktop Entry]
Name=Matchbox-keyboard
Exec=matchbox-keyboard
Type=application


How would one add a command to be executed in this .desktop file?

I am trying to run:

Code: Select all
sudo python /home/pi/pipresents/pipresents.py -o /home/pi -p Kiosk -g -b -f
Posts: 19
Joined: Wed Apr 15, 2015 5:31 pm
by eabasir » Sat Jul 11, 2015 8:08 am
jsut follow this link :
http://www.raspberrypi-spy.co.uk/2014/05/how-to-autostart-apps-in-rasbian-lxde-desktop/

assuming you have test.txt on desktop, an example could be:
Code: Select all
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
@leafpad /home/pi/Desktop/test.txt
Posts: 3
Joined: Wed Jun 10, 2015 8:09 am
by JimmyN » Sat Jul 11, 2015 9:26 am
If you want to add a shortcut on the desktop, or add an item to the menu then use a .desktop file. That allows you to specify an Icon for it, the location where it will appear in the menu, etc.

If you just want to run a script when the desktop starts then simply add the command to the autostart file, you don't need to create a .desktop file.
Posts: 1100
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA
by Joe Schmoe » Sat Jul 11, 2015 11:24 am
Note how much confusion and randomness there is abounding in this topic.

Lots of different directories and files to try editing - lots of trial-and-error looms.

See also my recent thread on this same topic - which basically ended in chaos (i.e., with no real, definitive, answer).
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm
by MelvinProject » Fri Aug 28, 2015 11:08 pm
As for your Putty question,

Simply connect your pi to the same WiFi network as your PC. Or with Ethernet, plug into the same router. From your Windows PC, Download this program: http://www.advanced-ip-scanner.com/down ... scan24.exe
(Link goes directly to download) This program is advanced IP scanner. Open it up and select portable. Then click scan. The listing labled Raspberry Pi Foundation is the one you want. Write down or copy the IP for that row. Open PuTTY and enter that IP. Make sure that SSH is selected. Click open and you are in! The attachment is a screenshot of PuTTY. Just put that IP in the hostname area.
Attachments
putty.gif
putty.gif (7.77 KiB) Viewed 16023 times
Posts: 6
Joined: Wed Aug 26, 2015 7:22 pm