Using MimeType text/xml is not really usefull. Suggest specific application mime types.
Mime type text/xml is far too generic to allow making file association with hydrogen.
I'd suggest defining clear mime types, such as
-
application/hydrogen-music-h2playlist -
application/hydrogen-music-h2drumkit -
application/hydrogen-music-h2song -
application/hydrogen-music-h2theme -
application/hydrogen-music-h2pattern
Since I found no installation scripts for the appimage, I created my own script to create better mime types and application desktop entries.
After running this script any h2song will be opened by hydrogen on double-click in file managers.
Please feel free to use this as template for your own installation script:
#!/bin/bash
#----------------------------------
# get the icons from github
#----------------------------------
ICONS="icon16.png icon24.png icon32.png icon48.png icon64.png"
for icon in $ICONS
do
if [ ! -f "$icon" ]
then
wget "https://raw.githubusercontent.com/hydrogen-music/hydrogen/refs/heads/master/data/img/gray/$icon"
fi
done
#----------------------------------
# install icons
#----------------------------------
for png in icon*.png
do
echo "png='${png}'"
name=$(basename "${png}" ".png")
size=$(convert "${png}" -print "%w" /dev/null)
item=hydrogen-music
echo "name='${name}' item='${item}' size='${size}'"
xdg-icon-resource install --mode user --size ${size} ${png} ${item}
done
#----------------------------------
# define mime type with icon
#----------------------------------
function create_mime
{
echo "-- create mime type application/hydrogen-music-$1 --"
cat << -EOF- > /tmp/hydrogen-music-$1.xml
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/hydrogen-music-$1">
<comment>$2</comment>
<glob pattern=$3/>
<icon name="hydrogen-music"/>
</mime-type>
</mime-info>
-EOF-
xdg-mime install --mode user /tmp/hydrogen-music-$1.xml
}
create_mime "h2song" "Hydrogen-Song" '"*.h2song"'
create_mime "h2pattern" "Hydrogen-Pattern" '"*.h2pattern"'
create_mime "h2playlist" "Hydrogen-Playlist" '"*.h2playlist"'
create_mime "h2drumkit" "Hydrogen-Drumkit" '"*.h2drumkit"'
create_mime "h2theme" "Hydrogen-Theme" '"*.h2theme"'
#----------------------------------
# define desktop file
#----------------------------------
echo "-- create application type --"
cat << -EOF- > /tmp/hydrogen-music-hydrogen.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
MimeType=application/hydrogen-music-h2song;application/hydrogen-music-h2pattern;application/hydrogen-music-h2playlist;application/hydrogen-music-h2drumkit;
Exec=hydrogen %F
Categories=AudioVideo;Audio;Qt;
Terminal=false
Icon=hydrogen-music
Name=Hydrogen
-EOF-
chmod +x /tmp/hydrogen-music-hydrogen.desktop
xdg-desktop-menu install --mode user /tmp/hydrogen-music-hydrogen.desktop
DESKTOP=$(xdg-user-dir DESKTOP)
cp /tmp/hydrogen-music-hydrogen.desktop ${DESKTOP}/
Hey @bassklampfe,
Since I found no installation scripts for the appimage, I created my own script to create better mime types and application desktop entries.
It's been a while since I read the AppImage specification. But AFAIR the resulting .AppImage should be self contained. It contains .desktop file (see https://github.com/hydrogen-music/hydrogen/blob/master/linux/org.hydrogenmusic.Hydrogen.desktop) registering all supported media types (see https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html).
Apart from the AppImage, the Windows .exe and the macOS .dmg should be self contained too. The meta data entering the repositories of various Linux distributions, on the other hand, are in the domain of the corresponding maintainers.
Mime type text/xml is far too generic to allow making file association with hydrogen.
How do you make or want to use such associations? And which OS / Window manager / file browser are you using? Usually associating a software with a specific file format can be done based on the file suffix as well.
@theGreatWhiteShark First of all : My OS is linux (mostly in the flavor of xubuntu or mint). And on linux (or at least on this distribution) the way, filetypes are defined for desktops, is declared in the Freedesktop.org Specification.
But if you follow the normal usecase for appimages (download, chmod +x, start) nothing is done to make filetypes or program associations known to the system. Either appimage must support some kind of "--install-mime-types" command or similar, but I don't now how to setup an appimage during make to support this.
Instead I use my script (or similar for other applications with appimage).
Usually associating a software with a specific file format can be done based on the file suffix as well.
Yes, on Windows, but not on linux. This is cumbersome. As long as no mime-types are specified for your file extensions, e.g. h2song files will be opened by the standard text/xml application, which is in most cases some kind of web browsers. If you now tell the system to open text/xml with hydrogen, then the system will open ALL text/xml files with hydrogen, even the file contains something completely different.
If on a virgin system you
- download the hydrogen app image
- chmod +x the appimage
- make a symbolic link
~/bin/hydrogen-> the appimage (~/binmust be in PATH) - download a h2song
- try to open h2song with the file-manager (regardless which) => I bet it will open with the internet browser
After you run my script, then
- h2song will be shown with the hydrogen icon and as "Hydrogen-Song" in the file-manager
- on open in a file-manager it will be opened with hydrogen.
I will not insist on my solution is perfect or the best one. Maybe there is an "official" way to declare mime-types for files handled by appimages. But I havn't found any specification for this and for now and for me my script is the best solution I can find.
But I'm willing to discuss this and make further investigations.
By the way, also on Windows custom filetypes must be declared to the system. Normally this is done by the installer (setup-xyz.exe), which creates registry entries. Or the programm does it by itself on the first run.
On Linux this is done by an install script, if .deb format is used. An appimage must do it by itself.
This is to the best of my knowledge. Feel free to extend for iOS.
| Windows | Linux | |
|---|---|---|
| Filetype location | Registry | /usr/share/mime/… and ~/.local/share/mime/… |
| Command to install | regedit |
xdg-mime |
| Icon locations | anywhere | /usr/share/icons/… and ~/.local/share/icons/… |
| Icon filetypes | .ico or embedded in DLL or EXE resources | .png or .svg |
| Command to install | regedit |
xdg-icon-resource (does not support svg) |
| Start menu entries | .lnk files | .desktop files |
| Start menu location | ProgramData/Microsoft/Windows/Start Menu/Programs |
/usr/share/applications/… and ~/.local/share/applications/… |
| Command to install | copy 😜 |
xdg-desktop-menu |
| File->Programm associations | registry | ~/.config/mimeapps.list |
| Command to install | Filemanager or regedit |
Filemanager or xdg-mime |
Yes, on Windows, but not on linux. This is cumbersome. As long as no mime-types are specified for your file extensions, e.g. h2song files will be opened by the standard text/xml application, which is in most cases some kind of web browsers.
You are right. nautilus shows the same behavior. (I usually don't spent much time outside of either emacs or a web browser and am not that familiar with freedesktop stuff 😅 ). But the application starting up on my machine when double clicking a .h2song file is https://github.com/muse-sequencer/muse. Seems like they are doing exactly the same as we currently do.
You know, to be honest, I'm a little reluctant on this one because with such little changes I usually annoy maintainers instead of really fixing something. E.g. the people over at Fedora do explicitly remove our current MIME type (see https://src.fedoraproject.org/rpms/hydrogen/blob/rawhide/f/hydrogen.spec#_63). And this is a behavior hasn't changed over more than 25 years.
I'm also not sure which people do you the AppImage. My naive assumption was that those capable of compiling the application themselves will always opt for a classic make && make install. Maybe I'm wrong. But about a third of the people creating issues in here won't be able to handle bash scripts, let alone to deal with things like installing missing dependencies, like wget or imagemagick tools.
Maybe this is something for our wiki. This probably will help more experienced non-AppImage users too.
let alone to deal with things like installing missing dependencies, like wget or imagemagick tools.
wget is install by default on the most linux distributions (in contrast to IOS, where curl is the preferred tool).
Imagemagick is not needed, if we replace
size=$(convert "${png}" -print "%w" /dev/null)
by
size=${name#icon}
If the script were run from inside the appimage, then even wget is not needed, because the icon*.png files are present in the appimage container.
@theGreatWhiteShark : I will try to figure out, how to embed my script into the appimage and come back to you.
I'm also not sure which people do you the AppImage. My naive assumption was that those capable of compiling the application themselves will always opt for a classic make && make install. Maybe I'm wrong.
I prefer using appimage for many kinds of software. But mostly I only use the software and do not contribute, because I'm happy with the software as it is.
When I start to add something (mostly by creating handy lua scripts for my own use), I often clone the repo to get more understanding of how the software is working. And then m a y b e I will start to build the software on my build machine to check for further improvements. But this is only the last resort, if nothing else helps.
make && make install
As far as I can see, even the make install does not install custom mime types or menu entries.