Integrating Appimages

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
CrashedAgain
Posts: 187
Joined: Wed Jan 15, 2020 8:39 pm

Integrating Appimages

Post by CrashedAgain »

OS: Ubuntu 20.04.3 LTS (MATE/mate)
Word size of FreeCAD: 64-bit
Version: 0.20.26202 (Git) AppImage
Build type: Release
Branch: master
Hash: ca6d49d080dea0abc23d954743eca7c46f33469b
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: English/Canada (en_CA)

I use Freecad appimages on Linux Ubuntu so that I can get a more up-to-date version than stable, and I also so I can update my other computer using a file on a stick since it does not have an adequate internet connection. I found out the hard way that it is very important to be using the same Freecad version if you are going to transfer work between computers.

One of the inconveniences of using appimages is that the files are not integrated into the system – the system considers them generic compressed files and tries to open them with a file archive application. Setting the “open with” property is not an adequate solution because it will then try to open all compressed files in Freecad.

There are “appimage integration” programs which will set them up as a distinct filetype and assign an appropriate icon to them. These will also automatically update to a new appimage version when it is installed.

I tried one.

However, I also have a custom application launcher on the menu bar, and the integration app did not upgrade that, which caused some serious problems and trashed a bunch of files. If the file was opened by clicking on the filename, it opened in the newest version, however, if it was opened by using the custom application launcher, it opened in an older, incompatible, version.

The result was a trashed file.

Therefore I came up with the following method of manually integrating Freecad files into the system. I am not a Linux expert by any means and this took quite a bit of searching so I am sharing it here in case anyone else finds it useful.

Note that the following is for Ubuntu 20. Other Linux systems will be similar but the commands may differ slightly.

Preparation: Because the launcher files must point to a specific file, a consistent filename is needed for the target Freecad appimage file. I use "FreeCAD_LatestAppImage" and it is always in the "Appimages" folder on my home directory.

So, the first step is to rename your newly downloaded appimage to "FreeCAD_Latest.AppImage" (or whatever name you choose), change permissions to "allow executing as a program", and move it you your chosen location. You will, of course, have to remove or rename any existing files of that name first.

The files needed to integrate it into the system are:
freecad.xml
freecad.desktop
scalablefreecad.svg

Copies are attached. Make a new folder and copy all the files into it. Then open a terminal and cd to that folder.

Notice that the "freecad.desktop" file is posted here as "freecad.txt". Either my system or this forum got silly about copying files of the type ".desktop" and would not upload them.

First, register Freecad files as a distinct filetype:

Code: Select all

 sudo cp freecad.xml  /usr/share/mime/packages/freecad.xml 
then, associate application with the filetype. Edit the "Exec" line in the following file to your filename and path instead of "home/crashedagain/Appimages/FreeCAD_Latest.AppImage", then copy it:

Code: Select all

 sudo cp freecad.txt /usr/share/applications/freecad.desktop 
Update the databases to activate the changes:

Code: Select all

 sudo update-mime-database /usr/share/mime 

Code: Select all

 sudo update-desktop-database /usr/share/applications 
Check that it worked.

Select a Freecad .FCStd file, click on permissions -> open with. It should now say "files of type Freecad document files" instead of "files of type Zip archive".
Click on "add" then "custom command".
Navigate to your appimage file and select it. Clicking on the file should now open it in Freecad.

Now we want to associate the freecad icon with the file, so copy the icon:

Code: Select all

 sudo cp scalablefreecad.svg /usr/share/icons/hicolor/scalable/apps/freecad.svg 
and update the icon database:

Code: Select all

 sudo update-icon-caches /usr/share/icons/* 
Finally, add a custom application launcher to the desktop or menu bar, browse to your appimage to select the command, and set the launcher icon to freecad.svg.

If you prefer, you could use a freecad.desktop file on your Desktop instead.

Done.
Attachments
freecad.txt
(332 Bytes) Downloaded 212 times
scalablefreecad.svg
(10.93 KiB) Downloaded 209 times
freecad.xml
(329 Bytes) Downloaded 185 times
Last edited by CrashedAgain on Fri Nov 12, 2021 2:58 pm, edited 5 times in total.
User avatar
bambuko
Veteran
Posts: 2185
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Integrating Appimages

Post by bambuko »

I know enough to be dangerous :mrgreen: , so take what I do with a pinch of salt...
It is similarly simple - I add .desktop file - FreeCAD_0.20.desktop and FreeCAD_link_daily.desktop
shown below for link version

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=FreeCAD_link
Icon=/home/bambuko/Applications/FreeCAD_link_daily/freecad_link.png
Exec=/home/bambuko/Applications/FreeCAD_link_daily/FreeCAD-asm3-Daily-Conda-Py3-Qt5-20211015-glibc2.12-x86_64.AppImage %F
Terminal=false
Categories=Graphics
%F appended at the end of Exec line was very important.

The only thing I haven't done is the mime bit - might have a go following your advice ;)
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
User avatar
adrianinsaval
Veteran
Posts: 5551
Joined: Thu Apr 05, 2018 5:15 pm

Re: Integrating Appimages

Post by adrianinsaval »

It's probably better to place those in the equivalent user level folders (I think it will be ~/.local/share instead of /usr/share)
CrashedAgain
Posts: 187
Joined: Wed Jan 15, 2020 8:39 pm

Re: Integrating Appimages

Post by CrashedAgain »

bambuko: Your freecad.desktop file is essentially the same as Ubuntu's application launcher - starts the application it is pointed at (....daily builds...) in your case. Mine points to a specific version because I cannot use daily builds as I have another computer with no internet as the two must be kept in sych with regard to Freecad version. Thus I update manually (occasionally).

I do like the "mime" setup (and, not knowing enough to even be dangerous, it took quite a while to figure it out) because it makes it a lot easier to organize, find and start my Freecad files.

adrianinsaval: The advantage of putting them in .....usr/share instead of .....local/share is that the Freecad setup will then be available to all users. Doesn't make any difference on a single user system but it might to some.

And thank you both for replying. Means at least somebody is noticing my post.
User avatar
adrianinsaval
Veteran
Posts: 5551
Joined: Thu Apr 05, 2018 5:15 pm

Re: Integrating Appimages

Post by adrianinsaval »

CrashedAgain wrote: Wed Nov 10, 2021 2:14 am bambuko: Your freecad.desktop file is essentially the same as Ubuntu's application launcher - starts the application it is pointed at (....daily builds...) in your case
not at all, look again, the Exec line points to a specific appimage, I would personally point it to a versionless name like FreeCAD-asm3.Appimage and rename the appimage to that whenever I update rather than having to edit the .desktop file every time, in fact that's what I do, I have a .desktop file pointing to FreeCAD.Appimage (the weekly builds) and another pointing to FreeCAD-asm3.Appimage (realthunder branch)
adrianinsaval: The advantage of putting them in .....usr/share instead of .....local/share is that the Freecad setup will then be available to all users. Doesn't make any difference on a single user system but it might to some.
the disadvantage is that you could cause conflict with a package manager, or mess up every user's config instead of just yours, is not a big deal but I personally like to go the safe route and don't manually put files in root owned folders also because it's easier to clean up afterwards (because it's separated from the system provided files) if you don't want to have that anymore.
CrashedAgain
Posts: 187
Joined: Wed Jan 15, 2020 8:39 pm

Re: Integrating Appimages

Post by CrashedAgain »

adrianinsaval , you are right.

THANK YOU for noticing and pointing it out!

I had discovered that issue some time ago and "fixed" it by renaming the appimage "FreeCad_LatestAppimage" then forgot to include it in the write-up above. I'm currently trying to edit the write up but won't be able to finish it until tomorrow.

Since the daily builds are also named as a specific version, (eg, the current one is FreeCAD_weekly-builds-26306-Linux-Conda_glibc2.12-x86_64.AppImage) you must also have to edit your desktop file (or rename the appimage) with each update??? Is there an easier way?

I found that to be a nuisance and I forgot about it. I don't update very often (literally it's been months) because of having to keep a computer with no internet in sych.

Ubuntu doesn't like ".desktop" files, it won't edit or copy them (which is why I have to post it as a ".txt" file above).

"Application Launcher" is their version of a .desktop file, but they are editable, movable and copy-able. If you look at the "properties" of a ".desktop" file it shows the exact same dialog box as used for their "launcher" file.

Is there an easier way?
User avatar
bambuko
Veteran
Posts: 2185
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Integrating Appimages

Post by bambuko »

adrianinsaval wrote: Wed Nov 10, 2021 2:42 am ...not at all, look again, the Exec line points to a specific appimage...
yeap!


adrianinsaval wrote: Wed Nov 10, 2021 2:42 am ...I would personally point it to a versionless name like FreeCAD-asm3.Appimage and rename the appimage to that whenever I update rather than having to edit the .desktop file every time, in fact that's what I do...
What an excellent idea! - thank you!
(why didn't I think of that? :lol: )
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
User avatar
bambuko
Veteran
Posts: 2185
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Integrating Appimages

Post by bambuko »

CrashedAgain wrote: Wed Nov 10, 2021 3:15 am ...Ubuntu doesn't like ".desktop" files, it won't edit or copy them (which is why I have to post it as a ".txt" file above)...
Strange, my distro is elementary OS (Ubuntu 20.04.2 LTS based) and I have no problem at all in creating, editing or copying of .desktop files.
I have used both terminal and GUI for that and it is working OK... :ugeek:

I don't like https://github.com/TheAssassin/AppImageLauncher - much easier to do things manually ;)
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
User avatar
onekk
Veteran
Posts: 6205
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Integrating Appimages

Post by onekk »

I usually use a desktop file pointing to a "stable" shell script, in freecad-stable.sh (or dev or ls3), the file is a thing like this:

Code: Select all

#!/bin/bash

export FREECAD_USER_HOME="/home/common/FreeCAD/config-dev"
urxvt -T "FreeCAD-launcher" -e "/home/common/FreeCAD/FreeCAD_weekly-builds-26202-Linux-Conda_glibc2.12-x86_64.AppImage"

When changing the AppImage, i simplky change the version number in the freecad-stable.sh.


You could not pass through a terminal and simply run the Appimage file or not set FREECAD_USER_HOME to have different places where setting are saved "per AppImage"

All the references are done to the desktop file, and so no other changes are needed, shell script is very easy to change, You could even decide what application will launch the FCStd file, using some facilities of the "file manager", some file manager permit to specify a default application and some other application that are associated with same extension, but you mileage may vary.


Side note I have put this file not in user dir but in a shared dir between different distributions and then in each distro I link /home/common/FreeCAD to a FreeCAD dir in my home dir, to have them in a handy place.

This way changes are "spread between" distros.

Hope it will be useful for someone

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
bambuko
Veteran
Posts: 2185
Joined: Thu Oct 24, 2019 12:53 pm
Location: UK, England, North Devon

Re: Integrating Appimages

Post by bambuko »

onekk wrote: Wed Nov 10, 2021 7:58 am ...Hope it will be useful for someone...
as usual with Linux, there so many ways... :lol:
sometimes too many for us new boys and girls
Thank you Carlo!
I am using Link branch and Assembly3
you can also download ... and try it here
excellent Assembly3 tutorials here
Post Reply