the Gambas desktop icon actions (Run with..)

Post

Posted
Rating:
#1 (In Topic #1864)
Guru
BruceSteers is in the usergroup ‘Guru’
I made a little script to make the "Run with …" actions of the desktop icon only show the available installed toolkits and not all of them.

Code

#!/usr/bin/env bash

LIBS=$(gbx3 -e 'Component.Path')

for gui in GTK3 QT4 QT5 QT6; do [ -e "$LIBS/gb.${gui,,}.component" ] && AGUIS="$AGUIS$gui;"; done
AGUIS=${AGUIS%;*}

ENTRY="[Desktop Entry]
Name=Gambas 3
Exec=gambas3
GenericName=Gambas 3 IDE
GenericName[fr]=EDI Gambas 3
GenericName[ru]=Gambas 3 IDE(ИСР)
GenericName[nl]=Gambas 3 IDE
Comment=Gambas3 Integrated Development Environment
Comment[fr]=Environnement de développement intégré Gambas3
Comment[ru]=Gambas3 IDE(ИСР) - альтернатива для Visual Basic
Comment[nl]=Gambas3 Geïntegreerde Ontwikkel Omgeving
Icon=gambas3
Terminal=false
Type=Application
Categories=Development;IDE;
StartupNotify=true
Actions=$AGUIS
"
OIFS=$IFS
IFS=';'
for gui in $AGUIS; do
ACTIONS="$ACTIONS
[Desktop Action $gui]
Name=Run with $gui
Name[fr]=Exécuter avec $gui
Name[nl]=Uitvoeren met $gui
Name[it]=Esegui con $gui
Exec=env GB_GUI=gb.${gui,,} gambas3
"
done
IFS=$OIFS

#echo "$ENTRY$ACTIONS"
echo "$ENTRY$ACTIONS" >/tmp/gambas3.desktop
xdg-desktop-menu uninstall /tmp/gambas3.desktop # remove old before installing new.
xdg-desktop-menu install --novendor /tmp/gambas3.desktop


If you run this script as it is it will update the ~/.local/share/applications/gambas3.desktop file Actions

To only test it, comment out the last 2 xdg-desktop-menu lines and inspect /tmp/gambas3.desktop after running it

I have used this script in my bruces-patched fork makefile.am so it now does it automatically during make install.
make desktop icon show installed gui toolkits not all of them. (4b838ef8) · Commits · Bruce Steers / gambas · GitLab
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
Update.

I removed thew bash reliant code that conveted text to lower case and used tr command instead.
tr is a POSIX command so it makes the script more compatible than relying on bash being installed.

Code


LIBS=$(gbx3 -e 'Component.Path')

for gui in GTK3 QT4 QT5 QT6
do
LCASE=$(echo -n $gui | tr '[:upper:]' '[:lower:]')
[ -e "$LIBS/gb.$LCASE.component" ] && AGUIS="$AGUIS$gui;"
done
AGUIS=${AGUIS%;*}

ENTRY="[Desktop Entry]
Name=Gambas 3
Exec=gambas3
GenericName=Gambas 3 IDE
GenericName[fr]=EDI Gambas 3
GenericName[ru]=Gambas 3 IDE(ИСР)
GenericName[nl]=Gambas 3 IDE
Comment=Gambas3 Integrated Development Environment
Comment[fr]=Environnement de développement intégré Gambas3
Comment[ru]=Gambas3 IDE(ИСР) - альтернатива для Visual Basic
Comment[nl]=Gambas3 Geïntegreerde Ontwikkel Omgeving
Icon=gambas3
Terminal=false
Type=Application
Categories=Development;IDE;
StartupNotify=true
Actions=$AGUIS
"
OIFS=$IFS
IFS=';'
for gui in $AGUIS; do
LCASE=$(echo -n $gui | tr '[:upper:]' '[:lower:]')
ACTIONS="$ACTIONS
[Desktop Action $gui]
Name=Run with $gui
Name[fr]=Exécuter avec $gui
Name[nl]=Uitvoeren met $gui
Name[it]=Esegui con $gui
Exec=env GB_GUI=gb.$LCASE gambas3
"
done
IFS=$OIFS

#echo "$ENTRY$ACTIONS"

echo "$ENTRY$ACTIONS" >/tmp/gambas3.desktop

# UNCOMMENT THE LINE BELOW TO FORCE RE-INSTALL OF ALREADY EXISTING ICON.
#xdg-desktop-menu uninstall /tmp/gambas3.desktop # remove old before installing new.

xdg-desktop-menu install --novendor /tmp/gambas3.desktop

Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
If you want to use a script as part of the Gambas3 packages for Debian/Ubuntu you can simply use bash.
I can make it run after Gambas3 is installed, so all checks and balances can be done and changes applied.

I posted you some links on mailing list to see what debian requires.

If you have a script, that you think complies to debian rules, I'm willing to add it to my recipe for running some package and installation tests in vm to see if it works. 
After that, it's a matter of me adapting the recipe for OSB in master branch, do a merge request and Debian Ubuntu will be done, at least if Benoit thinks it's a good idea ;)

No idea on how it works for the other distro's but it is possible there as well.

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#4
Guru
BruceSteers is in the usergroup ‘Guru’
Cheers Willy.

I wonder if the use of xdg-desktop-menu or gbx3 breaks it's compliance?

All other commands are POSIX.

I re-added the #!shebang line i'd previously removed and added 'set -e' command.  that seemed to be all the vitals the page you pointed me to said was needed.

So i'm fairly sure it's all good (apart from the use of xdg-utils and gbx3)
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

BruceSteers said

Cheers Willy.

I wonder if the use of xdg-desktop-menu or gbx3 breaks it's compliance?

All other commands are POSIX.

I re-added the #!shebang line i'd previously removed and added 'set -e' command.  that seemed to be all the vitals the page you pointed me to said was needed.

So i'm fairly sure it's all good (apart from the use of xdg-utils and gbx3)


xdg-utils is a dependency that will be installed when installing gambas3 (the complete IDE that is).
Only then the desktop entry for gambas3 is created.

Now, I suppose that once installed and at the moment the postinst script is run, the system will be aware of both xdg-utils and gbx3.
If not, it is probably easily solved by a full path reference to gbx3 (for example) in the script.

So, what script do you want me to use for testing and what distro you prefer debian13/12/11 OR/AND Ubuntu 24.04/22.04/20.04.
I will do one or two simultanious builds, all amd64 for testing, so make your pick.
I'll publish a working result if I get one, for you to test as well.
 

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
Okay well lets see if it works then :)  And thank you, i couldn't get my head around creating my own repository :(

Attachment

make.gambas3desktop.tar.gz


I have commented out the line that uninstalls the icon first.
This means it will probably only do it's job if the icon does not already exist (I think xdg-desktop-menu does not reinstall over existing)

added code to remove the temp file from /tmp/ and check it does not exist before attempting writing it.

I guess before thinking of submitting a merge to Ben We should think about naming?
maybe make.gambas3desktop is not the best name?

something more like…
MakeDesktopIcon.sh

BTW in my branch the script lives in gambas-source/app/desktop/ folder and the app/Makefile.am has a line to run it from there.
app/desktop/ is where all the other .desktop related files reside so it made sense to put it there.
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’
Re: distro, just do whatever you prefer m8
I'm fairly sure if it works on one of them it should work on them all as they are all deb based packagers.
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’

BruceSteers said


I have commented out the line that uninstalls the icon first.
This means it will probably only do it's job if the icon does not already exist (I think xdg-desktop-menu does not reinstall over existing)


Hmm thinking about it you may have to un-comment that line so it works.

I'm thinking if the installer installs it's own icon and then the script is run after that then it probably won't overwrite it.

Unless you can stop the packager trying to install the static gambas3.desktop file and leave it to the script.
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
We got a winner

winner.png

I packaged your bruces-patched for debian 12 and 13 and Ubuntu 24.04 (all amd64).Tested on Linux Mint 22 VM. Made sure no gambas was installed, so it's a virgin install and the desktop file is as should be (no more QT4 ;))
I will be testing some more later, first gonna create me some dinner…


 

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#10
Guru
BruceSteers is in the usergroup ‘Guru’

gbWilly said

We got a winner

I packaged your bruces-patched for debian 12 and 13 and Ubuntu 24.04 (all amd64).Tested on Linux Mint 22 VM. Made sure no gambas was installed, so it's a virgin install and the desktop file is as should be (no more QT4 )
I will be testing some more later, first gonna create me some dinner…


 

Awesome stuff :)

I've tested the autotools method so far on debian/trixie ubuntu/noble fedora42 and manjaro.  all working as expected :)

did you have to add it to the postinst or did it just work from the makefile?
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

BruceSteers said

did you have to add it to the postinst or did it just work from the makefile?


I renamed your script to postinst, did some minor modification and language additions, added it to the recipe and packaged it for bookworm, trixie and noble.
Next I created a repository (see my mail to you) and installed from repo. Works as a charm and has nothing to do with the Gambas source.

script.png

I switch to using bash and added a comment with a short description, autor and copyright. I hope you can agree with the content and license, if not just let me know.
In this form it can be part of the recipe for debian/ubuntu package creation (also for previous Gambas versions).
I will be using it in my recipes as I very much like the solution being tailored to the sytem, good job :thumbs:

Below the content of the Gambas3.deb package and it now has a script named postinst that will run at the end of the gambas3 install (post install :lol:)


gambas3.deb.png  

You can open .deb packages with an archive manager as that is what they are. :thumbs:

 

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#12
Guru
BruceSteers is in the usergroup ‘Guru’
Excellent  :)

You could also tailor yours a bit more to add some other actions (GambOS related)

Online now: No Back to the top
1 guest and 0 members have just viewed this.