How to Integrate .appimage files with antiX menu

Forum Forums General Tips and Tricks How to Integrate .appimage files with antiX menu

  • This topic has 13 replies, 4 voices, and was last updated Sep 1-5:44 pm by marcelocripe.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #38074
    Member
    PPC

      I intend to write a small yad script to integrate .appimages with antiX, but I haven’t quite gotten to it, so here’s the How-to I wrote down:

      How to integrate an .appimage with your system, making it available in the menu, also enabling you to easily create a desktop or toolbar icon for it:

      0- get the appimage file you want to use and don’t forget to make it executable:
      chmod u+x [full/path/to/name_of_file.appimage]
      (note you can do it from the file manager, if you want to)
      1- using your file manager, select the appimage you want, and copy it.
      2- Open a text editor (like geany) using “sudo” (ex: sudo geany) and paste there this text:

      [Desktop Entry]
      Encoding=UTF-8
      Type=Application
      Name=
      Icon=
      Categories=
      Exec=

      3- You’ll have to fill in the following lines:
      Name= [enter the name of the application]
      Icon= [you’ll have to find the icon you want for it. Take a look at /usr/share/icons/papirus-antix/32×32/apps if you find any icon you like, copy it and paste it in this line. If you don’t find, you’ll have to search for in on-line, in “.png” or “.svg” icon format]
      Categories= [you’ll have to choose one, of this: “Application|AudioVideo|Development|Education|Game|Graphics|Network|Office|Settings|System|Utility” ]
      Exec= [it’s the full path to your .appimage file, paste here the file you copied from the File Manager]

      4- save this text file to the folder /usr/share/applications and choose a name like this [application name]-appimage.desktop

      5- Make this appimage appear in you menu, in the chosen category:
      sudo desktop-menu --write-out-global
      (enter your password, if asked to)

      —–

      6-To see a list of all the appimages you made available to the menu, by creating a .desktop file:

      ls /usr/share/applications/*-appimage.desktop > /tmp/appslist.txt
      geany /tmp/appslist.txt

      7- To remove appimages from the menu:

      Copy, from the list above the line that referes to the app you want to remove and then do:
      sudo rm [paste the app you choose here]
      (enter your password if asked to)
      sudo desktop-menu --write-out-global
      (to update the menu)

      #38081
      Member
      Xecure

        Could the add-desktop app in antiX not help with this also? I haven’t tested this out myself as I do the same as you (create and add manually a .desktop file), but now that I am exploring the apps in antiX, I remembered when I read your post. Maybe this would prevent you from having to create a new yad script and re-use the one in antiX.

        antiX Live system enthusiast.
        General Live Boot Parameters for antiX.

        #38088
        Member
        PPC

          Thanks, Xecure, I know about add-desktop (I even mentioned it before, in my “little known antiX apps” thread)… I’ll basically just try to adapt it to automate the creation of the .desktop file (and also add the make executable bit and the “remove appimages from the menu” function.
          I could not get add-desktop to add a .desktop file, and I ‘ll have to parse it’s code to try to find out why… at first glance it should work…
          As always, even if this script isn’t picked up by anticapitalista (I’m betting it won’t and I understand why- to avoid bloating antiX with a never ending GUI’s for every single task a user may want to do- that’s more MX’s style).
          The script, if I end up writing it (more patching it together for several sources), will be for my own personal use, and also something we can point newbies to. Appimages are great for newbies, in my own humble opinion: they allow to run stuff like the latest LibreOffice or Gimp versions with zero chance of messing up the system… If I add a button to “http://appimage.github.io/” the script can become all in one, allowing newbies to experience the joys of running the safest, latest install free applications.
          As I understand anticapitalista’s point of view, usage of appimages is not favoured, because it can bloat the system, and also they are slower than the version of the applications installed using the package manager or package installer).

          P.

          #38089
          Member
          Xecure

            I even mentioned it before, in my “little known antiX apps” thread

            You are right. It is from there (and your linux newbie thread) where I am taking some of your explanations as a guide to build the welcome screen.

            I could not get add-desktop to add a .desktop file

            Just tested it out on my system and it creates a .desktop file in $HOME/Desktop. Tested it with the script I am working on and the only thing that i needed to change after was the terminal=true option.
            Is it possible that your system is in another language (português) and ~/Desktop is not your desktop folder (Área de Trabalho? no idea if that is so in Pt) and it either cannot create it or is in a different folder? No idea, really, as I only work with English in antiX.

            antiX Live system enthusiast.
            General Live Boot Parameters for antiX.

            #38091
            Member
            PPC

              @Xecure: I found a even easier way to create desktop files for appimages, and with the correct icon to boot!

              Simply uncompress the .desktop file and .png icon from the appimage you want to use, with 7z, like so:
              7z e [name_of_file].AppImage *.png *.desktop
              copy the icon to the folder where you want it to be (I have a “Appimages” folder, where most of my appimages are, if you do the same, it can be the same folder)
              Launch a text editor using sudo and edit the extracted .desktop file.
              Edit the “Exec=” field to point it to the appimage file and edit the “Icon=” to point to the icon you just exctrated. Save the .desktop file to “/usr/share/applications”.
              Update the menu with:sudo desktop-menu --write-out-global
              Done!

              How could I never have thought of that before?!

              P.

              #38095
              Member
              PPC

                @Xecure: and you were right- Duh! I forgot, that, when I tested add-desktop, it created the file in “~/Desktop”, not in “~/Área de trabalho”.
                I won’t, for now create a script, extracting the .desktop and .png files directly from the appimage and adapting the .desktop file by hand is the fastest way to go for now…

                P.

                #38099
                Member
                Xecure

                  Simply uncompress the .desktop file and .png icon from the appimage you want to use,

                  You are right. I was always searching the /usr/share/icons/ to catch the name for the program and then manually building the .desktop, when uncompressing the appimage was way easier. The .desktop file is almost already done. So simple! Thanks for pointing it out.

                  antiX Live system enthusiast.
                  General Live Boot Parameters for antiX.

                  #38102
                  Member
                  PPC

                    I wrote a tiny script to automate the extraction of .desktop files from appimages, that works (almost) every time:

                    ###### extract the .desktop file from appimage: 
                    # select file:
                    appimage_file=$(yad --title "Select a valid appimage file" --file-selection)
                    # try to extract the .desktop file:
                    eval 7z e $appimage_file *.desktop
                    eval 7z e $appimage_file usr/share/applications/

                    Now all the user has to do is edit the extracted file and substitute the EXE= with the full path of the .appimage (trying to automate that too, but it seems it’s more trouble than it’s worth)

                    Unfortunatly, automating the extraction of the icons is more problematic…

                    P.

                    #38104
                    Forum Admin
                    Dave

                      Maybe because you are selecting the app image already (and should have the full path?) you could simply use sed to write a new line?
                      sed "s|^EXEC=.*|EXEC=$appimage_file|g" -i $desktop_file

                      Or perhaps because there may be options in the exec line you should use the exec line already in the .desktop file as part of the new exec line.
                      Then you could extract the path to the appimage from the selection
                      path=${appimage_file%/*}
                      With the old exec stored in a variable
                      oldExec=$(grep "^EXEC=" test.txt |cut -d "=" -f2 )
                      and use sed or something similar to write the new line with the path like
                      sed "s|^EXEC=.*|EXEC=$path/$oldExec|g" -i $desktop_file

                      You might even be able to skip the retrieving of the oldExec by using sed against only the EXEC= portion rather than the whole line
                      sed “s|^EXEC=|EXEC=$path|g” -i $desktop_file.

                      Also it may be worth considering using a mime-filter on the yad selection dialog for the appimage mime type.

                      Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown

                      #38105
                      Member
                      PPC

                        Thanks for the suggestions Dave. I had already finished the script last night, but it was too late and I went to bed before publishing it!
                        I integrated your suggestions about file filtering.
                        There should probably also be a confirmation window before integrating the .desktop file, just to be on the safe side? The script already asks for the password…
                        Short explanation: where there are also menus for selecting the desktop and icon files? Because complex appimages (like LibreOffice’s) can have several desktop files, and sometimes the desktop file in the first level of the appimage merely points to the correct desktop file… Also there can be manyyyy icons. So I think it’s better that the user selects one…
                        So, right now the script works, flawless, until now in 3 easy steps: select appimage to integrate, select the correct .desktop file, select the icon you want to use. In 3 selections the user has the appimage correctly integrated in the menu. Better than running a daemon, in my opinion!
                        @Dave: do you know of any way to make the .desktop selection start, by default in the correct folder? “/tmp/[name_of_extracted_appimage]”?

                        Script (first fully working version, needs only correct icon and title, and some visual work- it’s ugly but functional):

                        # select appimage:
                        appimage_select=$(yad --center --form --field="Select the appimage you want to integrate:":FL '' --file-filter="Appimage Files (*.appimage)| *.AppImage *.Appimage")
                        ## if nothing selected, exit
                        [[ -z "$appimage_select" ]] && exit
                        #remove trailing character:
                        appimage_file=$(echo "${appimage_select::-1}")
                        # create and move to temporary folder, to avoid "poluting" the Home folder
                        #Remove path and extension:
                        file=${appimage_file%.desktop}
                        bare_file=$(echo ${file##*/})
                        #create temp folder and move to it:
                        mkdir /tmp/$bare_file
                        cd /tmp/$bare_file
                        #extract the .desktop file:
                        # try to extract .desktop file(s):
                        eval 7z e -y $appimage_file *.desktop
                        eval 7z e -y $appimage_file usr/share/applications/*.desktop
                        # try to extract icon(s)
                        eval 7z e -y $appimage_file *.png
                        eval 7z e -y $appimage_file *.svg
                        eval 7z X -y $appimage_file usr/share/icons/
                        sleep 1
                        # select the correct .DESKTOP file (usefull if the .appimage has more than one)
                        desktop_select=$(yad --center --form --field="Select the correct desktop file:":FL '/tmp/$bare_file/' --file-filter="Desktop Files (*.desktop)| *.desktop *.Desktop")
                        ## if nothing selected, exit
                        [[ -z "$desktop_select" ]] && exit
                        #remove trailing character:
                        desktop=$(echo "${desktop_select::-1}")
                        # Now the real usefull work: substitute, the Exec command inside the .desktop file!
                         # get the first line that contains "Exec=" (because there can be several EXEC's)
                         original_exec=$(grep "Exec=" $desktop | head -n1)
                        	echo $original_exec
                         #in case we want this:
                         sufix=" %U"	
                         new_Exec="Exec="$appimage_file
                        	echo $new_Exec
                        #replace the original EXEC with the one that runs the appimage:
                        sed -i "/$original_exec/c $new_Exec"  $desktop
                        	cat $desktop
                        sleep 0.5
                        #now select the ICON that the .desktop file will use (usefull if the .appimage has more than one)
                        icon=$(yad --title "Select the icon you want to use" --file-selection)
                        new_icon=$(echo Icon=$icon)
                        	echo $new_icon
                        ###strip path from $new_icon and move it to 	~/ then refer to it as "~/$ico" -- "$HOME/$icon"
                        ico=$(basename -- "$new_icon")
                        	echo $ico
                        cp $icon ~
                         # get the first line that contains "Icon="
                         original_icon=$(grep "Icon=" $desktop | head -n1)
                            echo $original_icon
                        #replace the original icon with the one the one extracted from the appimage:
                        ##TODO- copy the icon to a definitive folder, because its only in a temp one!!!!!!!!!!!!!! to ~/.config ??? or just ~?
                        if [ -z "$icon" ]
                        then
                              echo No new icon selected
                        else
                              new_icon="Icon="$HOME/$ico
                              sed -i "/$original_icon/c $new_icon"  $desktop
                        fi
                        # rename the new desktop file, so user can tell programs that run from desktop files from those that don't
                        desktop_bare=$(basename -- "$desktop")
                        mv $desktop appimage-$desktop_bare
                        	geany appimage-$desktop_bare
                        # then alter the .desktop file and copy it to usr/share/applications/
                        gksudo cp  appimage-$desktop_bare /usr/share/applications/
                        sudo desktop-menu --write-out-global
                        

                        P.

                        • This reply was modified 4 years ago by PPC.
                        • This reply was modified 4 years ago by PPC.
                        #38121
                        Member
                        PPC

                          Tiny change, that simplifies the process for most appimages: if the appimage only contains one .desktop file, automaticaly use it, and choose only the correct icon (I lost my gas while trying to do the same to the icons…) The script is now almost fully automated (except for the icon part, and even that, for the most common apps, the user can just cancel the Choose icon menu and use the icon from the default icon set…

                          Updated version:

                          
                          # select appimage:
                          appimage_select=$(yad --center --form --field="Select the appimage you want to integrate:":FL '' --file-filter="Appimage Files (*.appimage)| *.AppImage *.Appimage")
                          ## if nothing selected, exit
                          [[ -z "$appimage_select" ]] && exit
                          #remove trailing character:
                          appimage_file=$(echo "${appimage_select::-1}")
                          # create and move to temporary folder, to avoid "poluting" the Home folder
                          #Remove path and extension:
                          file=${appimage_file%.desktop}
                          bare_file=$(echo ${file##*/})
                          #create temp folder and move to it:
                          mkdir /tmp/$bare_file
                          cd /tmp/$bare_file
                          #extract the .desktop file:
                          # try to extract .desktop file(s):
                          eval 7z e -y $appimage_file *.desktop
                          eval 7z e -y $appimage_file usr/share/applications/*.desktop
                          # try to extract icon(s)
                          eval 7z e -y $appimage_file *.png
                          eval 7z e -y $appimage_file *.svg
                          eval 7z X -y $appimage_file usr/share/icons/
                          sleep 1
                          # check if threre's one .desktop top or more. If there's only one, use it, if not, open menu to select desktop:
                          number_of_dekstop_files=$(ls *.desktop | wc -l)
                          	echo $number_of_dekstop_files
                            if [ $number_of_dekstop_files -eq 1 ]; then
                          	file=$(ls *.desktop)
                          		echo $file
                          	desktop=$(echo /tmp/$bare_file/$file)
                          		echo $desktop
                          	 else 
                          	 echo 'Theres more than 1 desktop file, you have to select one'
                          	# select the correct .DESKTOP file (if the .appimage has more than one)
                          	desktop_select=$(yad --center --form --field="Select the correct desktop file:":FL '/tmp/$bare_file/' --file-filter="Desktop Files (*.desktop)| *.desktop *.Desktop")
                          	## if nothing selected, exit
                          	[[ -z "$desktop_select" ]] && exit
                          	#remove trailing character:
                          	desktop=$(echo "${desktop_select::-1}")
                            fi
                          # Now the real usefull work: substitute, the Exec command inside the .desktop file!
                           # get the first line that contains "Exec=" (because there can be several EXEC's)
                           original_exec=$(grep "Exec=" $desktop | head -n1)
                          	echo $original_exec
                           #in case we want this:
                           sufix=" %U"	
                           new_Exec="Exec="$appimage_file
                          	echo $new_Exec
                          #replace the original EXEC with the one that runs the appimage:
                          sed -i "/$original_exec/c $new_Exec"  $desktop
                          	cat $desktop
                          sleep 0.5
                          #now select the ICON that the .desktop file will use (usefull if the .appimage has more than one)
                          icon=$(yad --title "Select the icon you want to use" --file-selection)
                          new_icon=$(echo Icon=$icon)
                          	echo $new_icon
                          ###strip path from $new_icon and move it to 	~/ then refer to it as "~/$ico" -- "$HOME/$icon"
                          ico=$(basename -- "$new_icon")
                          	echo $ico
                          cp $icon ~
                           # get the first line that contains "Icon="
                           original_icon=$(grep "Icon=" $desktop | head -n1)
                              echo $original_icon
                          #replace the original icon with the one the one extracted from the appimage:
                          ##TODO- copy the icon to a definitive folder, because its only in a temp one!!!!!!!!!!!!!! to ~/.config ??? or just ~?
                          if [ -z "$icon" ]
                          then
                                echo No new icon selected
                          else
                                new_icon="Icon="$HOME/$ico
                                sed -i "/$original_icon/c $new_icon"  $desktop
                          fi
                          # rename the new desktop file, so user can tell programs that run from desktop files from those that don't
                          desktop_bare=$(basename -- "$desktop")
                          mv $desktop appimage-$desktop_bare
                          	geany appimage-$desktop_bare
                          # then alter the .desktop file and copy it to usr/share/applications/
                          gksudo cp  appimage-$desktop_bare /usr/share/applications/
                          sudo desktop-menu --write-out-global
                          • This reply was modified 4 years ago by PPC.
                          #38143
                          Forum Admin
                          Dave

                            @Dave: do you know of any way to make the .desktop selection start, by default in the correct folder? “/tmp/[name_of_extracted_appimage]”?

                            hmm, not certain what you are asking for because it seems you have it already. At least the yad selection opens in /tmp for me, but I do not have any appimages to try so I copied it out of the script….
                            I think you are trying to open the yad dialog in the /tmp/$bare_file directory? If so and it is not working with what you have; you probably need to add your “cd /tmp/$bare_file” that is done before the extraction to the beginning of the newly spawned bash/yad call.
                            desktop_select=$(cd /tmp/$bare_file; yad --center --form --field="Select the correct desktop file:":FL --file-filter="Desktop Files (*.desktop)| *.desktop *.Desktop")

                            Of course this should work if you are trying to get rid of the form action and go back to just the selection dialog.
                            desktop_select=$(cd /tmp/$bare_file/; yad --title "Select a valid desktop file" --file-selection --file-filter="Desktop Files (*.desktop)| *.desktop *.Desktop")

                            Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown

                            #41003
                            Member
                            marcelocripe

                              Hello PPC, Xecure and Dave.

                              I am arriving almost three months late in this post (laughs) and in Linux distributions, the impression I have is that I am late my whole life.

                              The Xecure who was kind enough to send me the link to this topic, thanks.

                              The script, if I end up writing it (more patching it together for several sources), will be for my own personal use, and also something we can point newbies to.

                              You can be sure that novice users will like this tool, especially if you don’t need to install anything for it to work.

                              I can quote my own example, I am new to this “Linux world” (gigantic!), Coming from the “MS Windows world”, whenever I read Dave’s signature I start to go alone …, I thought that only I I thought it was funny, but other colleagues who are no longer using “visor halters or blinders”, yes, what they put on the horse so they don’t see sideways, they also laugh … we are learning to remove the visor, thanks to people like you who have patience and teach newbies, my thanks to the three.

                              Xecure has developed or is almost ready the portable or executable program to download antiX program packages and updates and will end my great difficulty and many others to do local or offline installations, something that should be super simple for the most experienced, for those arriving, it is very confusing and difficult these dependencies … dependencies of dependencies …

                              Xecure, “Desktop” in Portuguese is “Área de Trabalho”, I hope I am not to blame for that …

                              Offline installation is what I always did, I think that is how most of those who work with Windows should do, all my colleagues who work in the computer area do offline installations.

                              The “.AppImage”, portable or executable for some Linux distro, are the way I like it, each program in its proper place and without having to install anything. I hope one day to learn how to package “.AppImage” (32-bit and 64-bit) and contribute to the Probono project, for me this is the way, nothing to share dependencies for programs, just share dependencies for the operating system.

                              The “.AppImage” icons I was editing from the ones that already existed, for the other browsers I used as a reference the file.desktop that already exists in antiX full, for example Firefox. I copy in another directory, open with the leafpad, change paths (url) and names, normally I put them in the apt folder, along with the google-chrome folder, in each folder its respective “.AppImage”, icon and a copy of “shortcut.desktop”, this is what I managed to do, but I don’t know if other colleagues can do the same. That’s where your program comes in, whether it is portable or executable and does it automatically, I believe that several beginners will want to use this tool, so don’t be discouraged.

                              Just let everyone know that the tool exists, then they will certainly want to use it. How can I want to use a tool that I don’t know exists?

                              My thanks to the three.

                              marcelocripe

                              ————

                              Olá PPC, Xecure e Dave.

                              Estou chegando quase três meses atrasado nesta postagem (risos) e nas distribuições Linux, a impressão que eu tenho que é eu estou atrasado a minha vida inteira.

                              O Xecure que fez a gentileza de me enviar o link deste tópico, obrigado.

                              The script, if I end up writing it (more patching it together for several sources), will be for my own personal use, and also something we can point newbies to.

                              Pode ter certeza que usuários iniciantes irão gostar sim desta ferramenta, principalmente se não precisar instalar nada para ela funcionar.

                              Eu posso citar o meu próprio exemplo, sou recém chegado neste “mundo Linux” (gigantesco!), vindo do “mundo MS Windows”, sempre que eu leio a assinatura do Dave começo a ir sozinho …, eu pensava que só eu achava engraçado, mas outros colegas que estão deixando de usar “cabresto de viseira ou antolhos”, sim, aquilo que colocam no cavalo para não enxergar para os lados, eles também dão risadas … estamos aprendendo a tirar a viseira, graças a pessoas como vocês que tem paciência e ensinam os novatos, meus agradecimentos aos três.

                              O Xecure desenvolveu ou está quase pronto o programa portátil ou executável para baixar pacotes de programas e atualizações do antiX e acabará com a minha grande dificuldade e de tantos outros de fazer instalações locais ou offline, algo que deve ser super simples para os mais experientes, para quem está chegando, é muito confuso e difíceis essas tais dependências … dependências de dependências …

                              Xecure, “Desktop” em idioma português é “Área de Trabalho”, espero não ser o culpado por isso …

                              Instalação offline é o que sempre eu fiz, eu acho que é assim que a maioria dos que trabalham com Windows devem fazer, todos os meus colegas que atuam na área de informática fazem instalações offline.

                              Os “.AppImage”, portátil ou executável para algumas distro Linux, são do jeito que eu gosto, cada programa no seu devido lugar e sem precisar instalar nada. Eu espero um dia aprender a empacotar “.AppImage” (32 bits e 64 bits) e contribuir com o projeto do Probono, para mim este é o caminho, nada de compartilhar dependências para programas, apenas compartilhar dependências para o sistema operacional.

                              Os ícone dos “.AppImage” eu estava editando a partir dos que já existiam, para os outro navegadores eu usei como referência o arquivo.desktop que já existe no antiX full, por exemplo do Firefox. Eu copio em outro diretório, abro com o leafpad, altero caminhos (url) e nomes, normalmente eu os coloco na pasta apt, junto com a pasta do google-chrome, em cada pasta o seu respectivo “.AppImage”, ícone e uma cópia do “atalho.desktop”, isso foi o que eu consegui fazer, mas eu não sei se outros colegas conseguem fazer o mesmo. É aí que entra o seu programa, se for portátil ou executável e fazer automaticamente, acredito que vários iniciantes irão querer usar esta ferramenta, por tanto não desanime.

                              Basta que todos saibam que a ferramenta existe, aí certamente irão querer usá-la. Como posso querer usar uma ferramenta que eu não sei que existe?

                              Meus agradecimentos aos três.

                              marcelocripe

                              • This reply was modified 3 years, 10 months ago by marcelocripe.
                            Viewing 13 posts - 1 through 13 (of 13 total)
                            • You must be logged in to reply to this topic.