Discussion:
opening files in a nominated application
Robin Paulson
2010-12-16 01:37:16 UTC
Permalink
i have some data files for an audio design package called pure data
[1]. they are text files, and if i open them from the window manager,
they are loaded into my text editor, currently gedit

how would i make them open inside pure data? if i use the 'file'
application to examine them, they are not listed as a specific type of
text file, so by my understanding, i can't force them to open in pure
data without making *all* text files open in that application.

any suggestions? is there a way to manually define file types, and
then give 'file' some clues as to what is what?

[1] https://secure.wikimedia.org/wikipedia/en/wiki/Pure_data
--
robin

http://tangleball.co.nz/ - Auckland's Creative Space
http://bumblepuppy.org/blog/

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Nick Rout
2010-12-16 02:05:18 UTC
Permalink
Post by Robin Paulson
i have some data files for an audio design package called pure data
[1]. they are text files, and if i open them from the window manager,
they are loaded into my text editor, currently gedit
how would i make them open inside pure data? if i use the 'file'
application to examine them, they are not listed as a specific type of
text file, so by my understanding, i can't force them to open in pure
data without making *all* text files open in that application.
any suggestions? is there a way to manually define file types, and
then give 'file' some clues as to what is what?
This is dependent on which desktop you use I believe, (ie gnome/kde/etc)

Also there are two ways to detect files, by file extension (eg the
.doc or .torrent extension), or by looking inside the file to see what
it contains. most file specs have a header - look at an avi file and
it starts "RIFF...%AVI LIST"

In addition if the files are served by an http server they are often
specified in the http header as being of a certain mime type.

Do your files have a specific extension?

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Robin Paulson
2010-12-16 02:09:25 UTC
Permalink
Post by Nick Rout
This is dependent on which desktop you use I believe, (ie gnome/kde/etc)
gnome
Post by Nick Rout
Also there are two ways to detect files, by file extension (eg the
.doc or .torrent extension), or by looking inside the file to see what
it contains. most file specs have a header - look at an avi file and
it starts "RIFF...%AVI LIST"
In addition if the files are served by an http server they are often
specified in the http header as being of a certain mime type.
Do your files have a specific extension?
.pd

as far as i can tell, the system won't detect based upon extensions
(although i am happy to be proven wrong), preferring instead the other
method,as do i. there is unique info at the start of the files, but i
have no idea what to do with it to create a new file type
--
robin

http://tangleball.co.nz/ - Auckland's Creative Space
http://bumblepuppy.org/blog/

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Robin Paulson
2010-12-16 02:16:52 UTC
Permalink
Post by Nick Rout
Also there are two ways to detect files, by file extension (eg the
.doc or .torrent extension), or by looking inside the file to see what
it contains. most file specs have a header - look at an avi file and
it starts "RIFF...%AVI LIST"
example file:
#N canvas 47 52 722 449 12;
#X text 460 422 updated for Pd version 0.26;
#X text 35 28 Use the "random" object to make pseudo-random integers.
To get continuously variable random numbers \, make a random number
in a large range and divide:;
#X obj 103 121 random 5;
#X msg 103 95 bang;
#X floatatom 103 147 0 0 0;
#X text 137 147 outputs from 0 to 4;
#X msg 337 87 bang;
#X floatatom 336 165 0 0 0;
#X obj 337 113 random 1000;
#X obj 336 141 / 1000;
#X text 402 166 from 0 to 0.999;
#X obj 71 324 random 5;
#X msg 162 255 bang;
#X floatatom 71 350 0 0 0;
#X obj 71 244 loadbang;
#X obj 71 274 timer;
#X text 204 255 <-- click to seed;
#X msg 71 299 seed \$1;
#X msg 163 299 bang;
#X text 204 300 <-- click to get random numbers;
#X text 24 382 If you give two randoms the same seed they give the
same sequence. If you never seed them \, you'll get different sequences
out of each one.;
#X text 34 197 If you don't want the same behavior every time you run
the patch \, use the time from load to first click as a seed:;
#X connect 2 0 4 0;
#X connect 3 0 2 0;
#X connect 6 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 7 0;
#X connect 11 0 13 0;
#X connect 12 0 15 1;
#X connect 14 0 15 0;
#X connect 15 0 17 0;
#X connect 17 0 11 0;
#X connect 18 0 11 0;

so, looking a bit deeper, it appears there isn't any unique,
consistent info defining the file. the '#X' or '#N' at the beginning
of each line defines a sound module within the structure. i'm not sure
where to go from here - any ideas anyone?

if there is a way to open in pure data based solely on the .pd
extension, i'd be keen to hear it
--
robin

http://tangleball.co.nz/ - Auckland's Creative Space
http://bumblepuppy.org/blog/

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Steve Holdoway
2010-12-16 03:03:14 UTC
Permalink
It's my understanding that linux use the concept of 'magic numbers'
rather that file extensions to identify the file's contents. What does

file yourfile

come up with? There should be info on associating with applications in
the binfmt ( ?-misc ?-support - sorry it's been a while ) documentation.

hth,

Steve
Post by Robin Paulson
Post by Nick Rout
Also there are two ways to detect files, by file extension (eg the
.doc or .torrent extension), or by looking inside the file to see what
it contains. most file specs have a header - look at an avi file and
it starts "RIFF...%AVI LIST"
#N canvas 47 52 722 449 12;
#X text 460 422 updated for Pd version 0.26;
#X text 35 28 Use the "random" object to make pseudo-random integers.
To get continuously variable random numbers \, make a random number
in a large range and divide:;
#X obj 103 121 random 5;
#X msg 103 95 bang;
#X floatatom 103 147 0 0 0;
#X text 137 147 outputs from 0 to 4;
#X msg 337 87 bang;
#X floatatom 336 165 0 0 0;
#X obj 337 113 random 1000;
#X obj 336 141 / 1000;
#X text 402 166 from 0 to 0.999;
#X obj 71 324 random 5;
#X msg 162 255 bang;
#X floatatom 71 350 0 0 0;
#X obj 71 244 loadbang;
#X obj 71 274 timer;
#X text 204 255 <-- click to seed;
#X msg 71 299 seed \$1;
#X msg 163 299 bang;
#X text 204 300 <-- click to get random numbers;
#X text 24 382 If you give two randoms the same seed they give the
same sequence. If you never seed them \, you'll get different sequences
out of each one.;
#X text 34 197 If you don't want the same behavior every time you run
the patch \, use the time from load to first click as a seed:;
#X connect 2 0 4 0;
#X connect 3 0 2 0;
#X connect 6 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 7 0;
#X connect 11 0 13 0;
#X connect 12 0 15 1;
#X connect 14 0 15 0;
#X connect 15 0 17 0;
#X connect 17 0 11 0;
#X connect 18 0 11 0;
so, looking a bit deeper, it appears there isn't any unique,
consistent info defining the file. the '#X' or '#N' at the beginning
of each line defines a sound module within the structure. i'm not sure
where to go from here - any ideas anyone?
if there is a way to open in pure data based solely on the .pd
extension, i'd be keen to hear it
--
Steve Holdoway BSc(Hons) MNZCS <***@greengecko.co.nz>
http://www.greengecko.co.nz
MSN: ***@greengecko.co.nz
Skype: sholdowa
Robin Paulson
2010-12-16 03:06:14 UTC
Permalink
Post by Steve Holdoway
It's my understanding that linux use the concept of 'magic numbers'
rather that file extensions to identify the file's contents. What does
 file yourfile
it does indeed, and i tried that. it's a text file, no MIME or other
info, just plain text - i assume because no-one has defined this file
type in the mime database

i found an application called assogiate [1]. i'll give that a go,
although it looks a bit clumsy in that it relies on file extensions as
far as i can tell

[1] http://packages.ubuntu.com/lucid/assogiate
--
robin

http://tangleball.co.nz/ - Auckland's Creative Space
http://bumblepuppy.org/blog/

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Nick Rout
2010-12-16 03:15:29 UTC
Permalink
Post by Robin Paulson
Post by Nick Rout
Also there are two ways to detect files, by file extension (eg the
.doc or .torrent extension), or by looking inside the file to see what
it contains. most file specs have a header - look at an avi file and
it starts "RIFF...%AVI LIST"
#N canvas 47 52 722 449 12;
#X text 460 422 updated for Pd version 0.26;
#X text 35 28 Use the "random" object to make pseudo-random integers.
To get continuously variable random numbers \, make a random number
in a large range and divide:;
#X obj 103 121 random 5;
#X msg 103 95 bang;
#X floatatom 103 147 0 0 0;
#X text 137 147 outputs from 0 to 4;
#X msg 337 87 bang;
#X floatatom 336 165 0 0 0;
#X obj 337 113 random 1000;
#X obj 336 141 / 1000;
#X text 402 166 from 0 to 0.999;
#X obj 71 324 random 5;
#X msg 162 255 bang;
#X floatatom 71 350 0 0 0;
#X obj 71 244 loadbang;
#X obj 71 274 timer;
#X text 204 255 <-- click to seed;
#X msg 71 299 seed \$1;
#X msg 163 299 bang;
#X text 204 300 <-- click to get random numbers;
#X text 24 382 If you give two randoms the same seed they give the
same sequence. If you never seed them \, you'll get different sequences
out of each one.;
#X text 34 197 If you don't want the same behavior every time you run
the patch \, use the time from load to first click as a seed:;
#X connect 2 0 4 0;
#X connect 3 0 2 0;
#X connect 6 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 7 0;
#X connect 11 0 13 0;
#X connect 12 0 15 1;
#X connect 14 0 15 0;
#X connect 15 0 17 0;
#X connect 17 0 11 0;
#X connect 18 0 11 0;
so, looking a bit deeper, it appears there isn't any unique,
consistent info defining the file. the '#X' or '#N' at the beginning
of each line defines a sound module within the structure. i'm not sure
where to go from here - any ideas anyone?
if there is a way to open in pure data based solely on the .pd
extension, i'd be keen to hear it
what application opens it? and how did you install that app? what distro?

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Nick Rout
2010-12-16 03:47:15 UTC
Permalink
Post by Nick Rout
Post by Robin Paulson
Post by Nick Rout
Also there are two ways to detect files, by file extension (eg the
.doc or .torrent extension), or by looking inside the file to see what
it contains. most file specs have a header - look at an avi file and
it starts "RIFF...%AVI LIST"
#N canvas 47 52 722 449 12;
#X text 460 422 updated for Pd version 0.26;
#X text 35 28 Use the "random" object to make pseudo-random integers.
To get continuously variable random numbers \, make a random number
in a large range and divide:;
#X obj 103 121 random 5;
#X msg 103 95 bang;
#X floatatom 103 147 0 0 0;
#X text 137 147 outputs from 0 to 4;
#X msg 337 87 bang;
#X floatatom 336 165 0 0 0;
#X obj 337 113 random 1000;
#X obj 336 141 / 1000;
#X text 402 166 from 0 to 0.999;
#X obj 71 324 random 5;
#X msg 162 255 bang;
#X floatatom 71 350 0 0 0;
#X obj 71 244 loadbang;
#X obj 71 274 timer;
#X text 204 255 <-- click to seed;
#X msg 71 299 seed \$1;
#X msg 163 299 bang;
#X text 204 300 <-- click to get random numbers;
#X text 24 382 If you give two randoms the same seed they give the
same sequence. If you never seed them \, you'll get different sequences
out of each one.;
#X text 34 197 If you don't want the same behavior every time you run
the patch \, use the time from load to first click as a seed:;
#X connect 2 0 4 0;
#X connect 3 0 2 0;
#X connect 6 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 7 0;
#X connect 11 0 13 0;
#X connect 12 0 15 1;
#X connect 14 0 15 0;
#X connect 15 0 17 0;
#X connect 17 0 11 0;
#X connect 18 0 11 0;
so, looking a bit deeper, it appears there isn't any unique,
consistent info defining the file. the '#X' or '#N' at the beginning
of each line defines a sound module within the structure. i'm not sure
where to go from here - any ideas anyone?
if there is a way to open in pure data based solely on the .pd
extension, i'd be keen to hear it
what application opens it? and how did you install that app? what distro?
answering my own question...

the app is actually called puredata and so is the package (on ubuntu).

Clearly file extension is relevant on modern linux distros

touch Desktop file.doc

couble clieck and it opens in openoffice, despite being zero length
and therefore having no magic number or other hints within it. Gnome
also gives it an icon that looks like a W (for Word no doubt).

I just can't suss the logic of how it comes to that conclusion. I used
to think this was all in the /usr/share/applications/*.desktop files,
but I can't see it there.

right click a .pd file and choose "open with other application" and it
asks you to remember that for all plain text files, not what we want!

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Hadley Rich
2010-12-16 04:11:18 UTC
Permalink
Post by Nick Rout
Clearly file extension is relevant on modern linux distros
touch Desktop file.doc
couble clieck and it opens in openoffice, despite being zero length
and therefore having no magic number or other hints within it. Gnome
also gives it an icon that looks like a W (for Word no doubt).
I just can't suss the logic of how it comes to that conclusion. I used
to think this was all in the /usr/share/applications/*.desktop files,
but I can't see it there.
right click a .pd file and choose "open with other application" and it
asks you to remember that for all plain text files, not what we want!
I did this not long ago for zpl files (Zebra printer codes) which are
also plain text.

I created the file /usr/share/mime/packages/zpl.xml with the following
content;

<?xml version="1.0" encoding="UTF-8"?>

<mime-info
xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="text/zpl">
<sub-class-of type="text/plain"/>
<comment>Zebra Printer File</comment>
<glob pattern="*.zpl"/>
</mime-type>
</mime-info>

and then used update-mime-database to make the desktop aware of the
addition.

That makes the desktop aware that it's not just a plain text file so
then you can associate the files with your program of choice.

This should be done by the programs package I believe.

Cheers,

hads
--
http://nicegear.co.nz
New Zealand's Open Source Hardware Supplier


_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Robin Paulson
2010-12-16 21:01:34 UTC
Permalink
Post by Hadley Rich
I did this not long ago for zpl files (Zebra printer codes) which are
also plain text.
<snip>
Post by Hadley Rich
and then used update-mime-database to make the desktop aware of the
addition.
That makes the desktop aware that it's not just a plain text file so
then you can associate the files with your program of choice.
excellent, cheers. i'll give this a go
Post by Hadley Rich
This should be done by the programs package I believe.
it should. actually, they should allow the file to be recognised
without the extension being defined from unique headers
--
robin

http://tangleball.co.nz/ - Auckland's Creative Space
http://bumblepuppy.org/blog/

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Nick Rout
2010-12-16 21:04:37 UTC
Permalink
Post by Robin Paulson
Post by Hadley Rich
I did this not long ago for zpl files (Zebra printer codes) which are
also plain text.
<snip>
Post by Hadley Rich
and then used update-mime-database to make the desktop aware of the
addition.
That makes the desktop aware that it's not just a plain text file so
then you can associate the files with your program of choice.
excellent, cheers. i'll give this a go
Post by Hadley Rich
This should be done by the programs package I believe.
it should. actually, they should allow the file to be recognised
without the extension being defined from unique headers
there did not appear to be any unique headers in the sampe file,
unless perhaps the file format provides that each file starts with a
#N canvas line...

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Robin Paulson
2010-12-16 21:11:06 UTC
Permalink
Post by Nick Rout
Post by Robin Paulson
it should. actually, they should allow the file to be recognised
without the extension being defined from unique headers
there did not appear to be any unique headers in the sampe file,
unless perhaps the file format provides that each file starts with a
#N canvas line...
i think that line represents an object which may or may not be there,
so actually implementing correct recognition of the files is tricky
without changing their structure, which of course in turn creates
problems of backwards-compatibility.

more testing and an entry in their bugtrack system perhaps
--
robin

http://tangleball.co.nz/ - Auckland's Creative Space
http://bumblepuppy.org/blog/

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Nick Rout
2010-12-16 22:38:52 UTC
Permalink
Post by Robin Paulson
Post by Nick Rout
Post by Robin Paulson
it should. actually, they should allow the file to be recognised
without the extension being defined from unique headers
there did not appear to be any unique headers in the sampe file,
unless perhaps the file format provides that each file starts with a
#N canvas line...
i think that line represents an object which may or may not be there,
so actually implementing correct recognition of the files is tricky
without changing their structure, which of course in turn creates
problems of backwards-compatibility.
more testing and an entry in their bugtrack system perhaps
Well that just reinforces that not all file recognition in unix is
done via magic numbers, as my experiment with a zero length .doc file
showed. I suspect that historically the introduction of programs in
unix that would read windows file formats meant that magic number or
other internal recognition systems [1] would no longer work in all
cases.

It sounds like Hadley's method is the correct one, and that the
packager needs to implement it. i also suspect that freedesktop.org
would reveal further info. They seem to mandate standards for desktop
integration.

[1] such as reading the shebang line in a script, eg #!/usr/bin/python

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug

Continue reading on narkive:
Loading...