Blitzmax launch icon and register file extension?

Archives Forums/Linux Discussion/Blitzmax launch icon and register file extension?

JoshK(Posted 2013) [#1]
Is there any way to make a BlitzMax launch icon appear in the app launcher in Ubuntu 12.04, and make *.bmx files automatically opened by BlitzMax?


dawlane(Posted 2013) [#2]
Yes there is but it require some file creation.

First prepare the icon you will need a 48x48 png. Tip copy the one from breakout sample and resize it and place it in the BlitzMax directory.

All the user desktop stuff is in hidden directories in the user home folder. You should always install user specific applications launchers etc like BlitzMax in the users home folder. The only exceptions are those applications that require system wide access. What will be done here can be applied with a little modification in the /usr/shared/applications and /usr/shar/mime, but for now I will explain only what to do in the users own home directory.

Application launchers are found in /usr/share/application and file associations in /usr/share/mime, but for user specific they are in a hidden directory called .local/share
It is in this directory where we need to place our launcher and mime type files.
In a fresh install some of these files and directories do not exist and will have to be created.

Create the application launcher
This should go into .local/share/applications if this directory doesn't exist then it needs to be created.

All application launchers end with .desktop . Information can be found here about the structure and tokens. Alter the path names in Exec, Icon to suite you installation. Remember paths with spaces need to be enclosed in quotes.

In a text editor
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/jason/programs/BlitzMax/MaxIDE
Name=Blitz Max IDE
Comment=Blitz Max Intergrated Development Environment
Icon=/home/jason/programs/BlitzMax/icon.png
MimeType=application/x-BlitzMax; charset=binary
Categories=Development

Save this as MaxIDE.desktop in .local/share/applications
Do not be alarmed if the file name changes to what's in the Name item. It still is called MaxIDE.desktop it's just that the file browser uses whats in the Name item.

You will need to log out for this to be found in the menu/search box.

File Association
Mime types are stored as a xml file in .local/share/mime/applications and .local/share/mime/packages. For more information on mime types see here.
We only need to place our xml file in .local/share/mime/packages and use update-mime-database in a terminal to update the database.
First make sure that these directories exist .local/share/mime/packages and .local/share/mime/applications.

In a text editor
<?xml version="1.0"?>
 <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
   <mime-type type="application/x-BlitzMax">
   <comment>Blitz Max File</comment>
   <comment xml:lang="en">Blitz Max File</comment>
   <glob pattern="*.bmx"/>
  </mime-type>
 </mime-info>

Save this as user-extension-bmx.xml in .local/share/mime/packages

Now in a terminal
update-mime-database ~/.local/share/mime


Almost done
There is one more file that needs to be created for the file manager to associate any *.bmx with the application.
In a text editor
[Default Applications]
application/x-BlitzMax=MaxIDE.desktop

[Added Associations]
application/x-BlitzMax=MaxIDE.desktop;

Save this as mimeapps.list in .local/share/applications

The next time you open a file browser you should now have *.bmx files launche MaxIDE and a application launcher that can be found by searching.
Adding a launcher to Ubuntu's side bar would require a little more research.


JoshK(Posted 2013) [#3]
Thanks!


dawlane(Posted 2013) [#4]
This should explain how to set up a launcher onto the dash launcher bar https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles


dawlane(Posted 2013) [#5]
If yo wish to change the icons displayed in the file browser then make a directory in ./local/share and name it pixmaps.

Copy the icon into this directory and name it BlitzMax.png

Open a text editor and re-open the MaxIDE.desktop file
change the Icon tokens path to just
Icon=x-BlitzMax
and save.

Reopen the user-extension-bmx.xml file in .local/share/mime/packages and add after the comment tags
<icon name="x-BlitzMax"/>
and save.

Open a terminal and execute the commands below
update-mime-database ~/.local/share/mime
xdg-icon-resource install --size 48 ~/.local/share/pixmaps/BlitzMax.png x-BlitzMax


Executing xdg-icon-resource should create a new directory .local/share/icons. This is where the application icons are stored.

You can also add these option to Exec in .desktop if the application supports arguments.

%f a single filename.
%F multiple filenames.
%u a single URL.
%U multiple URLs.
%d a single directory. Used in conjunction with %f to locate a file.
%D multiple directories. Used in conjunction with %F to locate files.
%n a single filename without a path.
%N multiple filenames without paths.
%k a URI or local filename of the location of the desktop file.
%v the name of the Device entry.