]> pere.pagekite.me Git - homepage.git/blobdiff - blog/archive/2023/01/01.rss
Generated.
[homepage.git] / blog / archive / 2023 / 01 / 01.rss
index d07d10220886ac1cc2dbef2b3d5fde1f5edbb78a..8cf804c3acef690c2412dfbd2329aac8003b1002 100644 (file)
@@ -6,6 +6,86 @@
                 <link>https://people.skolelinux.org/pere/blog/</link>
 
        
+       <item>
+               <title>Is the desktop recommending your program for opening its files?</title>
+               <link>https://people.skolelinux.org/pere/blog/Is_the_desktop_recommending_your_program_for_opening_its_files_.html</link>        
+               <guid isPermaLink="true">https://people.skolelinux.org/pere/blog/Is_the_desktop_recommending_your_program_for_opening_its_files_.html</guid>
+                <pubDate>Sun, 29 Jan 2023 11:00:00 +0100</pubDate>
+               <description>&lt;p&gt;Linux desktop systems
+&lt;a href=&quot;https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html&quot;&gt;have
+standardized&lt;/a&gt; how programs present themselves to the desktop
+system.  If a package include a .desktop file in
+/usr/share/application, Gnome, KDE, LXDE, Xfce and the other desktop
+environments will pick up the file and use its content to generate the
+menu of available programs in the system.  A lesser known fact is that
+a package can also explain to the desktop system how to recognize the
+files created by the program in question, and use it to open these
+files on request, for example via a GUI file browser.&lt;/p&gt;
+
+&lt;p&gt;A while back I ran into a package that did not tell the desktop
+system how to recognize its files and was not used to open its files
+in the file browser and fixed it.  In the process I wrote a simple
+debian/tests/ script to ensure the setup keep working.  It might be
+useful for other packages too, to ensure any future version of the
+package keep handling its own files.&lt;/p&gt;
+
+&lt;p&gt;For this to work the file format need a useful MIME type that can
+be used to identify the format.  If the file format do not yet have a
+MIME type, it should define one and preferably also
+&lt;a href=&quot;https://www.iana.org/assignments/media-types/media-types.xhtml&quot;&gt;register
+it with IANA&lt;/a&gt; to ensure the MIME type string is reserved.&lt;/p&gt;
+
+&lt;p&gt;The script uses the &lt;tt&gt;xdg-mime&lt;/tt&gt; program from xdg-utils to
+query the database of standardized package information and ensure it
+return sensible values.  It also need the location of an example file
+for xdg-mime to guess the format of.&lt;/p&gt;
+
+&lt;pre&gt;
+#!/bin/sh
+#
+# Author: Petter Reinholdtsen
+# License: GPL v2 or later at your choice.
+#
+# Validate the MIME setup, making sure motor types have
+# application/vnd.openmotor+yaml associated with them and is connected
+# to the openmotor desktop file.
+
+retval=0
+
+mimetype=&quot;application/vnd.openmotor+yaml&quot;
+testfile=&quot;test/data/real/o3100/motor.ric&quot;
+mydesktopfile=&quot;openmotor.desktop&quot;
+
+filemime=&quot;$(xdg-mime query filetype &quot;$testfile&quot;)&quot;
+
+if [ &quot;$mimetype&quot; != &quot;$filemime&quot; ] ; then
+    retval=1
+    echo &quot;error: xdg-mime claim motor file MIME type is $filemine, not $mimetype&quot;
+else
+    echo &quot;success: xdg-mime report correct mime type $mimetype for motor file&quot;
+fi
+
+desktop=$(xdg-mime query default &quot;$mimetype&quot;)
+
+if [ &quot;$mydesktopfile&quot; != &quot;$desktop&quot; ]; then
+    retval=1
+    echo &quot;error: xdg-mime claim motor file should be handled by $desktop, not $mydesktopfile&quot;
+else
+    echo &quot;success: xdg-mime agree motor file should be handled by $mydesktopfile&quot;
+fi
+
+exit $retval
+&lt;/pre&gt;
+
+&lt;p&gt;It is a simple way to ensure your users are not very surprised when
+they try to open one of your file formats in their file browser.&lt;/p&gt;
+
+&lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
+activities, please send Bitcoin donations to my address
+&lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
+</description>
+       </item>
+       
        <item>
                <title>Opensnitch, the application level interactive firewall, heading into the Debian archive</title>
                <link>https://people.skolelinux.org/pere/blog/Opensnitch__the_application_level_interactive_firewall__heading_into_the_Debian_archive.html</link>        
@@ -20,7 +100,7 @@ description of the Little Snitch application for MacOS X.  It seemed
 like a very nice tool to have in the tool box, and I decided to see if
 something similar was available for Linux.&lt;/p&gt;
 
-&lt;p&gt;It did not took long to find
+&lt;p&gt;It did not take long to find
 &lt;a href=&quot;https://github.com/evilsocket/opensnitch&quot;&gt;the OpenSnitch
 package&lt;/a&gt;, which has been in development since 2017, and now is in
 version 1.5.0.  It has had a