Registering .gambas filetype without full install

Post your Gambas programming questions here.
Post Reply
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Registering .gambas filetype without full install

Post by BruceSteers »

Hi.
I've been testing my apps on systems without the main Gambas3 package installed.
Using a minimum requirement installer script that only installs the gambas components required by the app and the gambas runtime.

I've noticed if i 'apt-get install gamas3' something in the complete package installation sets up the gambas filetype on the system.
but if i only install the gambas-runtime then it doesn't get configured.

Anyone know what component sets the filetype up when it installs?
Or how to set the filetype up manually if it's the main IDE or something?

Thanks in advance :)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Registering .gambas filetype without full install

Post by BruceSteers »

I figured it out :)

I made a shell script Gambas application filetype installer if anyone wants it.

Requires xdg
Looks for xdg on start and lets you know if you don't have it.

Just run the "Install_Gambas_Filetype.sh" script in a terminal.

application-x-gambas3.png needs to be in the same folder as the install script.

uses "xdg-icon-resource" to install the default application-x-gambas3 icon
then uses "xdg-mime" to set up the filetype.

The bash script...
#!/usr/bin/env bash

# Install Script for Gambas3 application filetype using xdg

# Check xdg components are installed..
XDGYes=$(which xdg-mime)
if [ ! -z "$XDGYes" ]; then
XDGYes=$(which xdg-icon-resource)
fi
if [ -z "$XDGYes" ]; then
echo -ne "xdg not installed, cannot continue.\nPress return to finish."
fi

# Check application-x-gambas3.png icon exists in current folder and install it.
echo "Installing default filetype icon.."
if [ -e "./application-x-gambas3.png" ]; then
 sudo xdg-icon-resource install --context mimetypes --size 48 ./application-x-gambas3.png x-application-x-gambas3
else
 echo -ne "error, application-x-gambas3.png icon not found!\nPress return:"
 read
 exit
fi

echo -e "done.\n\nNow installing mime filetype and updating database..\nPlease wait a moment..."

# write temp default fyletype xml file from Gambas3 distro
echo -e '<?xml version="1.0" encoding="UTF-8"?>\n<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
	<mime-type type="application/x-gambas3">\n		<sub-class-of type="application/x-executable"/>
		<comment>Gambas 3 executable</comment>\n		<comment xml:lang="fr">Exécutable Gambas 3</comment>
		<magic priority="50">\n			<match type="string" value="#! /usr/bin/env gbr3" offset="0"/>\n		</magic>
		<glob pattern="*.gambas" />\n	</mime-type>\n</mime-info>' >/tmp/application-x-gambas3.xml

# install filetype and remove temp file
sudo xdg-mime install /tmp/application-x-gambas3.xml
rm /tmp/application-x-gambas3.xml

echo -ne "done.\napplcation-x-gambas3 filetype install completed.\nPress return to finish:"
read
script is in the archive along with the icon.
If at first you don't succeed , try doing something differently.
BruceS
Post Reply