]> pere.pagekite.me Git - homepage.git/blob - blog/archive/2016/06/06.rss
Generated.
[homepage.git] / blog / archive / 2016 / 06 / 06.rss
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
3 <channel>
4 <title>Petter Reinholdtsen - Entries from June 2016</title>
5 <description>Entries from June 2016</description>
6 <link>http://people.skolelinux.org/pere/blog/</link>
7
8
9 <item>
10 <title>A program should be able to open its own files on Linux</title>
11 <link>http://people.skolelinux.org/pere/blog/A_program_should_be_able_to_open_its_own_files_on_Linux.html</link>
12 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/A_program_should_be_able_to_open_its_own_files_on_Linux.html</guid>
13 <pubDate>Sun, 5 Jun 2016 08:30:00 +0200</pubDate>
14 <description>&lt;p&gt;Many years ago, when koffice was fresh and with few users, I
15 decided to test its presentation tool when making the slides for a
16 talk I was giving for NUUG on Japhar, a free Java virtual machine. I
17 wrote the first draft of the slides, saved the result and went to bed
18 the day before I would give the talk. The next day I took a plane to
19 the location where the meeting should take place, and on the plane I
20 started up koffice again to polish the talk a bit, only to discover
21 that kpresenter refused to load its own data file. I cursed a bit and
22 started making the slides again from memory, to have something to
23 present when I arrived. I tested that the saved files could be
24 loaded, and the day seemed to be rescued. I continued to polish the
25 slides until I suddenly discovered that the saved file could no longer
26 be loaded into kpresenter. In the end I had to rewrite the slides
27 three times, condensing the content until the talk became shorter and
28 shorter. After the talk I was able to pinpoint the problem &amp;ndash;
29 kpresenter wrote inline images in a way itself could not understand.
30 Eventually that bug was fixed and kpresenter ended up being a great
31 program to make slides. The point I&#39;m trying to make is that we
32 expect a program to be able to load its own data files, and it is
33 embarrassing to its developers if it can&#39;t.&lt;/p&gt;
34
35 &lt;p&gt;Did you ever experience a program failing to load its own data
36 files from the desktop file browser? It is not a uncommon problem. A
37 while back I discovered that the screencast recorder
38 gtk-recordmydesktop would save an Ogg Theora video file the KDE file
39 browser would refuse to open. No video player claimed to understand
40 such file. I tracked down the cause being &lt;tt&gt;file --mime-type&lt;/tt&gt;
41 returning the application/ogg mime type, which no video player I had
42 installed listed as a MIME type they would understand. I asked for
43 &lt;a href=&quot;http://bugs.gw.com/view.php?id=382&quot;&gt;file to change its
44 behavour&lt;/a&gt; and use the MIME type video/ogg instead. I also asked
45 several video players to add video/ogg to their desktop files, to give
46 the file browser an idea what to do about Ogg Theora files. After a
47 while, the desktop file browsers in Debian started to handle the
48 output from gtk-recordmydesktop properly.&lt;/p&gt;
49
50 &lt;p&gt;But history repeats itself. A few days ago I tested the music
51 system Rosegarden again, and I discovered that the KDE and xfce file
52 browsers did not know what to do with the Rosegarden project files
53 (*.rg). I&#39;ve reported &lt;a href=&quot;http://bugs.debian.org/825993&quot;&gt;the
54 rosegarden problem to BTS&lt;/a&gt; and a fix is commited to git and will be
55 included in the next upload. To increase the chance of me remembering
56 how to fix the problem next time some program fail to load its files
57 from the file browser, here are some notes on how to fix it.&lt;/p&gt;
58
59 &lt;p&gt;The file browsers in Debian in general operates on MIME types.
60 There are two sources for the MIME type of a given file. The output from
61 &lt;tt&gt;file --mime-type&lt;/tt&gt; mentioned above, and the content of the
62 shared MIME type registry (under /usr/share/mime/). The file mime
63 type is mapped to programs supporting the mime type, and this
64 information is collected from
65 &lt;a href=&quot;https://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/&quot;&gt;the
66 desktop files&lt;/a&gt; available in /usr/share/applications/. If there is
67 one desktop file claiming support for the MIME type of the file, it is
68 activated when asking to open a given file. If there are more, one
69 can normally select which one to use by right-clicking on the file and
70 selecting the wanted one using &#39;Open with&#39; or similar. In general
71 this work well. But it depend on each program picking a good mime
72 type (preferably
73 &lt;a href=&quot;http://www.iana.org/assignments/media-types/media-types.xhtml&quot;&gt;a
74 MIME type registered with IANA&lt;/a&gt;), file and/or the shared mime
75 registry recognizing the file and the desktop file to list the MIME
76 type in its list of supported MIME types.&lt;/p&gt;
77
78 &lt;p&gt;The &lt;tt&gt;/usr/share/mime/packages/rosegarden.xml&lt;/tt&gt; entry for
79 &lt;a href=&quot;http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec&quot;&gt;the
80 Shared MIME database&lt;/a&gt; look like this:&lt;/p&gt;
81
82 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;
83 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
84 &amp;lt;mime-info xmlns=&quot;http://www.freedesktop.org/standards/shared-mime-info&quot;&amp;gt;
85 &amp;lt;mime-type type=&quot;audio/x-rosegarden&quot;&amp;gt;
86 &amp;lt;sub-class-of type=&quot;application/x-gzip&quot;/&amp;gt;
87 &amp;lt;comment&amp;gt;Rosegarden project file&amp;lt;/comment&amp;gt;
88 &amp;lt;glob pattern=&quot;*.rg&quot;/&amp;gt;
89 &amp;lt;/mime-type&amp;gt;
90 &amp;lt;/mime-info&amp;gt;
91 &lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
92
93 &lt;p&gt;This states that audio/x-rosegarden is a kind of application/x-gzip
94 (it is a gzipped XML file). Note, it is much better to use an
95 official MIME type registered with IANA than it is to make up ones own
96 unofficial ones like the x-rosegarden type used by rosegarden.&lt;/p&gt;
97
98 &lt;p&gt;The desktop file of the rosegarden program failed to list
99 audio/x-rosegarden in its list of supported MIME types, causing the
100 file browsers to have no idea what to do with *.rg files:&lt;/p&gt;
101
102 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;
103 % grep Mime /usr/share/applications/rosegarden.desktop
104 MimeType=audio/x-rosegarden-composition;audio/x-rosegarden-device;audio/x-rosegarden-project;audio/x-rosegarden-template;audio/midi;
105 X-KDE-NativeMimeType=audio/x-rosegarden-composition
106 %
107 &lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
108
109 &lt;p&gt;The fix was to add &quot;audio/x-rosegarden;&quot; at the end of the
110 MimeType= line.&lt;/p&gt;
111
112 &lt;p&gt;If you run into a file which fail to open the correct program when
113 selected from the file browser, please check out the output from
114 &lt;tt&gt;file --mime-type&lt;/tt&gt; for the file, ensure the file ending and
115 MIME type is registered somewhere under /usr/share/mime/ and check
116 that some desktop file under /usr/share/applications/ is claiming
117 support for this MIME type. If not, please report a bug to have it
118 fixed. :)&lt;/p&gt;
119 </description>
120 </item>
121
122 </channel>
123 </rss>