toddak
Posts: 44
Joined: Wed Dec 30, 2015 10:10 pm
Location: Melbourne, Australia.

Automatically opening file once GUI has booted

Thu Dec 14, 2017 3:18 am

Hi all,

I know this is a super basic question, and I've spend the last few hours trying to google how to do this but I seem to missing some basic (and vital) language to get this to work.

All I'm trying to achieve is for my Raspberry pi 3 model b (running jessie) to open a pure data file I have on the desktop after it boots the GUI.

Can someone point me in the right direction for this? The only options I've found so far are editing the .bashrc file, but I'm not sure what I'm supposed to add to it...
rpi 2 model B, running raspbian jessie.

klricks
Posts: 4958
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Automatically opening file once GUI has booted

Thu Dec 14, 2017 4:28 am

toddak wrote:
Thu Dec 14, 2017 3:18 am
Hi all,

I know this is a super basic question, and I've spend the last few hours trying to google how to do this but I seem to missing some basic (and vital) language to get this to work.

All I'm trying to achieve is for my Raspberry pi 3 model b (running jessie) to open a pure data file I have on the desktop after it boots the GUI.

Can someone point me in the right direction for this? The only options I've found so far are editing the .bashrc file, but I'm not sure what I'm supposed to add to it...
What is a pure data file and what are you using to open it?

If booting to desktop then it is very easy to use autostart.

Code: Select all

nano /home/pi/.config/lxsession/LXDE-pi/autostart
Your entry in autostart should look something like this added to the end of what's there already:

Code: Select all

@lxterminal -e python /path/filename.py
The above line will be different depending on what app you are using......
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

toddak
Posts: 44
Joined: Wed Dec 30, 2015 10:10 pm
Location: Melbourne, Australia.

Re: Automatically opening file once GUI has booted

Thu Dec 14, 2017 4:46 am

Great, will try this when I get back to the studio!

Pure Data is an audiovisual programming language for media based projects (loosely speaking), made by Miller Puckette (the commercial version is called MAX/msp, also good but won't run on rpi to the best of my knowledge...).
https://puredata.info/

A puredata files is just filename.pd, and it opens in the Pure Data application.
rpi 2 model B, running raspbian jessie.

toddak
Posts: 44
Joined: Wed Dec 30, 2015 10:10 pm
Location: Melbourne, Australia.

Re: Automatically opening file once GUI has booted

Thu Dec 14, 2017 9:36 pm

So I opened up the autostart file, and I added this line to the end:

@lxterminal -e python /home/pi/Desktop/nz_install.pd

But nothing happens. I also tried it with a different file that has no underscore in the filename just to check if that was causing issues, but I had the same results, nothing happened.

The file is just sitting on my desktop, and I've associate all *.pd files with pure data, so when they're double clicked in the GUI they are automatically opening in Pure Data.

Any ideas as to why this isn't working?
rpi 2 model B, running raspbian jessie.

klricks
Posts: 4958
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Automatically opening file once GUI has booted

Thu Dec 14, 2017 10:39 pm

toddak wrote:
Thu Dec 14, 2017 9:36 pm
So I opened up the autostart file, and I added this line to the end:

@lxterminal -e python /home/pi/Desktop/nz_install.pd

But nothing happens. I also tried it with a different file that has no underscore in the filename just to check if that was causing issues, but I had the same results, nothing happened.

The file is just sitting on my desktop, and I've associate all *.pd files with pure data, so when they're double clicked in the GUI they are automatically opening in Pure Data.

Any ideas as to why this isn't working?
Remove python from the line and try again. Make sure there is no extra spaces.
What would you type from the command line in order to start pd and load the data file?
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

klricks
Posts: 4958
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Automatically opening file once GUI has booted

Fri Dec 15, 2017 1:08 am

The example I gave with python was only meant to be an example of the concept and only works with python scripts.

I found that you can't just type the name of a data or Doc file at the command line and have the app start, even if associated with an app in the GUI.
You need to find the command that will start the app and load the data file...... If a command exists... not all apps will allow this..........
Note that if your app does not start from the command line then you may need to use the full path.

The example below is very much like what you are trying to do only with a different app.
This will start LibreOffice Writer and also load an existing doc file from the command line:

Code: Select all

libreoffice --writer /home/pi/Desktop/this.odt
Now to autostart the above on boot or GUI login then the entry in autostart would look like this:

Code: Select all

@lxterminal -e libreoffice --writer /home/pi/Desktop/this.odt
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

toddak
Posts: 44
Joined: Wed Dec 30, 2015 10:10 pm
Location: Melbourne, Australia.

Re: Automatically opening file once GUI has booted

Fri Dec 15, 2017 1:20 am

Ah I see, sorry I'm fairly newb when it comes to the command line side of things, so didn't pick up on the python reference (Apart from knowing its a coding language).

I haven't been able to figure out the command line way of opening Pure Data, or if there is a way.

Frustratingly I have this working on one of my raspberry pi's at the moment, but didn't add it to my programming cheat sheet, so can't remember how it was done. Although I know it had to do with terminal.

Apart from autostart file, is there any other files that can be used to automate actions on startup? I've checked the autostart file on my other rpi, but I didn't do it that way last time...
rpi 2 model B, running raspbian jessie.

DirkS
Posts: 7733
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Automatically opening file once GUI has booted

Fri Dec 15, 2017 1:34 am

https://puredata.info/docs/faq/how-do-i ... mmand-line
To find the full path to pd use

Code: Select all

which pd

klricks
Posts: 4958
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Automatically opening file once GUI has booted

Fri Dec 15, 2017 1:40 am

Often times the real filename can be found in the [Help] --> [about] menu within the program.
Or
Find your app icon on the desktop or in the start menu then right click on that. [Properties] --> [Desktop Entry] --> [Command]
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

toddak
Posts: 44
Joined: Wed Dec 30, 2015 10:10 pm
Location: Melbourne, Australia.

Re: Automatically opening file once GUI has booted

Fri Dec 15, 2017 7:45 am

Thanks all, I'm finding this really helpful, and also developing my terminal skills more.

@Klricks what does the '--writer' line mean in that code?
libreoffice --writer /home/pi/Desktop/this.odt
I typed in the following into terminal to test: pd --writer /home/pi/Desktop/nz_install.pd

and got a lot of 'flags' but this is the first time I've seen them all. The flags make sense to me, in that they appear to be preferences for how pd should be opened. But how do I use them?

Also, pd still didn't open, so I assume the '--writer' part is specific to libreoffice?
rpi 2 model B, running raspbian jessie.

DirkS
Posts: 7733
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Automatically opening file once GUI has booted

Fri Dec 15, 2017 8:06 am

toddak wrote:
Fri Dec 15, 2017 7:45 am
Also, pd still didn't open, so I assume the '--writer' part is specific to libreoffice?
yes, it starts libreoffice writer.

Try

Code: Select all

pd /home/pi/Desktop/nz_install.pd

toddak
Posts: 44
Joined: Wed Dec 30, 2015 10:10 pm
Location: Melbourne, Australia.

Re: Automatically opening file once GUI has booted

Fri Dec 15, 2017 9:28 am

@DirkS many thanks!! That worked.

So with the 'flags' list that came up, how do you view the list of flags for an application?

And then add them to the command in autostart?
rpi 2 model B, running raspbian jessie.

klricks
Posts: 4958
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Automatically opening file once GUI has booted

Fri Dec 15, 2017 1:50 pm

toddak wrote:
Fri Dec 15, 2017 9:28 am

So with the 'flags' list that came up, how do you view the list of flags for an application?
--writer is a flag for LibreOffice.

This from the documentation link someone posted above:
pd -help
https://puredata.info/docs/faq/commandline

The flag symbol is not consistent between different apps. Some use - some use -- some use / some have space between filename and the symbol and some don't.
If I don't know then I try several ways -? or --? or -h or -help etc.
Often times the list is displayed when the app sees a flag that it does not understand so just typing a bogus character often works for example pd ?

Many apps and most Linux commands have a man (manual) page.
Try:

Code: Select all

man pd
Of course there is also Google.

Also clicking on the Properties of the start menu entry or desktop icon as I mentioned above will give a clue

Whatever works for the command line is what you use in autostart
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

toddak
Posts: 44
Joined: Wed Dec 30, 2015 10:10 pm
Location: Melbourne, Australia.

Re: Automatically opening file once GUI has booted

Wed Jan 03, 2018 5:20 am

@klricks thanks so much, and excuse the delay (Xmas...).

That really helped clarify things, and the list of flags very useful. Excuse my lack of knowledge, I did try google but I struggle without specific terminology.

That being said, the flags are working perfectly now, and will help me for a few future projects too. Thanks for your help!!
rpi 2 model B, running raspbian jessie.

Return to “Beginners”

Who is online

Users browsing this forum: mahjongg, pcmanbob, RspbrryPi and 46 guests