probonopd
4/30/2016 - 4:19 PM

Automatically mark AppImages as executable and run them. NOTE: This might be dangerous. Think about what you are doing.

Automatically mark AppImages as executable and run them. NOTE: This might be dangerous. Think about what you are doing.


cat > /tmp/executable.desktop <<\EOF
[Desktop Entry]
Version=1.0
Name=executable
Exec=bash -c "FILE=%f;chmod a+x \\$FILE;exec \\$FILE"
Terminal=false
Type=Application
Categories=Application;
MimeType=application/x-iso9660-appimage;
NoDisplay=true
StartupNotify=false
EOF
sudo desktop-file-install /tmp/executable.desktop
rm /tmp/executable.desktop

cat > /tmp/appimagekit-appimage.xml <<\EOF
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
   <mime-type type="application/x-iso9660-appimage">
      <sub-class-of type="application/x-executable" />
      <sub-class-of type="application/x-iso9660-image" />
      <comment>AppImage</comment>
      <magic priority="50">
         <match value="ELF" type="string" offset="1" />
         <match value="CD001" type="string" offset="32769" />
         <match value="AppImage" type="string" offset="32809" />
      </magic>
      <magic priority="40">
         <match value="ELF" type="string" offset="1" />
         <match value="CD001" type="string" offset="32769" />
         <match value="APPIMAGE" type="string" offset="32809" />
      </magic>
      <glob pattern="*.appimage" />
      <glob pattern="*.AppImage" />
   </mime-type>
</mime-info>
EOF
sudo xdg-mime install --mode system /tmp/appimagekit-appimage.xml
rm /tmp/appimagekit-appimage.xml

update-mime-database.real /usr/share/mime
update-desktop-database

# To test:
# killall nautilus