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.
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.
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)
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.
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.
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)
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…
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…
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.
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
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 )
You can open .deb packages with an archive manager as that is what they are.
To be this… [ -e "$LIBS/gb.$LCASE.webview.component" ] && AGUIS="$AGUIS$gui;"
Then as Benoit stated it more accurately checks that webview exists as the toolkit can be present but missing webkit so the ide won't use that toolkit.
That is probably a way better solution as the packaging solution is not sinking in with Benoit somehow, no matter the amount of post I spend on explain the matter
That is probably a way better solution as the packaging solution is not sinking in with Benoit somehow, no matter the amount of post I spend on explain the matter
Yes, I had a look at it (saw mailing list first) and I like the implementation That would solve it for all circumstances and the package solution wouldn't be needed.
Here is the updated function from the IDE as a gbs gambas script file
The advantages of the gbs script are as follows.. It uses DesktopFile.class and DesktopActions.class to make the file.
it checks for an existing icon and pre-loads it before adding missing toolkit Actions or removing superfluous ones. thus preserving any existing other Actions you may have set.
It works outside of the IDE like the other script. Just run it to update your desktop menu icon toolkits.
I'm not so sure it's any good to use during an install like the other script because gambas scripting (gbs3) might not be installed. Attachment
Here is the updated function from the IDE as a gbs gambas script file
The advantages of the gbs script are as follows.. It uses DesktopFile.class and DesktopActions.class to make the file.
it checks for an existing icon and pre-loads it before adding missing toolkit Actions or removing superfluous ones. thus preserving any existing other Actions you may have set.
It works outside of the IDE like the other script. Just run it to update your desktop menu icon toolkits.
I'm not so sure it's any good to use during an install like the other script because gambas scripting (gbs3) might not be installed. Attachment
Gambas script running from the installer might be problematic, unless gbs3 is installed. Safer to use bash scripts. But in theory it should be possible, a matter of trying I guess.
The function is now a small program (8.8kb compressed) I made it detect if being run from a GUI environment or terminal and use either Message() or Print respectively.
the script can just unpack the archive to /tmp and use gbx3 to run the project dir , gbx3 WILL be installed
With the attached archive in the app/desktop folder the script can be just this…
So instead of using a compressed archive of the project it now creates a project on the fly by copying the source module and making a .project file. that is much faster.
The source module is this…
Code
Public Sub Main()
Component.Load("gb.desktop") Dim hExisting, hNew As DesktopFile Dim sTemp As String = File.SetExt(Temp("gambas3"), "desktop") Dim sGui, sExisting As String Dim aToolkits As String[] = ["GTK3", "GTK4", "QT4", "QT5", "QT6"] Dim aActions As String[] Dim iChanges As Integer Dim bCanWrite As Boolean
If Exist(sTemp) Then Kill sTemp
For Each sExisting In ["~/.local/share/applications/gambas3.desktop", "/usr/local/share/applications/gambas3.desktop", "/usr/share/applications/gambas3.desktop"] If Exist(sExisting) Then hExisting = New DesktopFile(sExisting) bCanWrite = Access(sExisting, gb.Write) Break Endif sExisting = "" Next
If sExisting And If Not bCanWrite Then hExisting.Save(sTemp) Else If sExisting And If bCanWrite Then hNew = hExisting Else File.Save(sTemp, "[Desktop Entry]\n" "Name=Gambas 3\n" "Exec=gambas3\n" "GenericName=Gambas 3 IDE\n" "GenericName[fr]=EDI Gambas 3\n" "GenericName[ru]=Gambas 3 IDE(ИСР)\n" "GenericName[nl]=Gambas 3 IDE\n" "Comment=Gambas3 Integrated Development Environment\n" "Comment[fr]=Environnement de développement intégré Gambas3\n" "Comment[ru]=Gambas3 IDE(ИСР) - альтернатива для Visual Basic\n" "Comment[nl]=Gambas3 Geïntegreerde Ontwikkel Omgeving\n" "Icon=gambas3\n" "Terminal=false\n" "Type=Application\n" "Categories=Development;IDE;\n" "StartupNotify=true\n") Endif
If Not bCanWrite Then hNew = New DesktopFile(sTemp) aActions = Split(hNew.Actions.Join("]"), "]", Null, True) If Not aActions Then aActions = []
For c As Integer = aToolkits.Max DownTo 0 sGui = aToolkits[c]
If Exist(Component.Path &/ "gb." & LCase(sGui) & ".webview.component") Then
If Not aActions.Exist(sGui) Then Inc iChanges aActions.Add(sGui, 0) hNew.DesktopActions.Add(sGui, "Run with " & sGui, "env GB_GUI=gb." & LCase(sGui) & " gambas3") hNew.DesktopActions[sGui]["Name[fr]"] = "Exécuter avec " & sGui hNew.DesktopActions[sGui]["Name[nl]"] = "Uitvoeren met " & sGui hNew.DesktopActions[sGui]["Name[it]"] = "Esegui con " & sGui Endif
Else
If aActions.Exist(sGui) Then Inc iChanges aActions.Remove(hNew.Actions.Find(sGui)) hNew.DesktopActions[sGui].Delete Endif aToolkits.Remove(c)
Endif Next
If sExisting And If iChanges = 0 Then Error.Raise("No changes made to desktop menu icon") hNew.Actions = aActions hNew.Save If Not bCanWrite Then Shell "xdg-desktop-menu uninstall gambas3.desktop\nxdg-desktop-menu install --novendor " & Shell(sTemp) & "\nxdg-desktop-menu forceupdate" Wait Kill sTemp Else Shell "xdg-desktop-menu forceupdate" Wait Endif Print "gambas3.desktop menu " & If(bCanWrite, "reconfigured", "rebuilt") & " with toolkits: " & aToolkits.Join(", ")
Catch Print Error.Text If Exist(sTemp) Then Kill sTemp
End
Now if an existing icon is found and it is writable it will modify it instead of using xdg to re-install also i use one Shell Wait command instead of multiple Exec Wait commands.
during install there is no lag now, the info text appears instantly.
the attached archive script can be run standalone but it no longer uses Message for results just Print.
tested working okay on debian / ubuntu / fedora / manjaro and opensuse
Component.Load("gb.desktop") Dim hExisting, hNew As DesktopFile Dim sTemp As String = File.SetExt(Temp("gambas3"), "desktop") Dim sGui, sExisting As String Dim aToolkits As String[] = ["GTK3", "GTK4", "QT4", "QT5", "QT6"] Dim aActions As String[] Dim iChanges As Integer Dim bCanWrite As Boolean
If Exist(sTemp) Then Kill sTemp
For Each sExisting In ["~/.local/share/applications/gambas3.desktop", "/usr/local/share/applications/gambas3.desktop", "/usr/share/applications/gambas3.desktop"] If Exist(sExisting) Then hExisting = New DesktopFile(sExisting) bCanWrite = Access(sExisting, gb.Write) Break Endif sExisting = "" Next
If sExisting And If Not bCanWrite Then hExisting.Save(sTemp) Else If sExisting And If bCanWrite Then hNew = hExisting Else File.Save(sTemp, "[Desktop Entry]\n" "Name=Gambas 3\n" "Exec=gambas3\n" "GenericName=Gambas 3 IDE\n" "GenericName[fr]=EDI Gambas 3\n" "GenericName[ru]=Gambas 3 IDE(ИСР)\n" "GenericName[nl]=Gambas 3 IDE\n" "Comment=Gambas3 Integrated Development Environment\n" "Comment[fr]=Environnement de développement intégré Gambas3\n" "Comment[ru]=Gambas3 IDE(ИСР) - альтернатива для Visual Basic\n" "Comment[nl]=Gambas3 Geïntegreerde Ontwikkel Omgeving\n" "Icon=gambas3\n" "Terminal=false\n" "Type=Application\n" "Categories=Development;IDE;\n" "StartupNotify=true\n") Endif
If Not bCanWrite Then hNew = New DesktopFile(sTemp) aActions = Split(hNew.Actions.Join("]"), "]", Null, True) If Not aActions Then aActions = []
For c As Integer = aToolkits.Max DownTo 0 sGui = aToolkits[c]
If Exist(Component.Path &/ "gb." & LCase(sGui) & ".webview.component") Then
If Not aActions.Exist(sGui) Then Inc iChanges aActions.Add(sGui, 0) hNew.DesktopActions.Add(sGui, "Run with " & sGui, "env GB_GUI=gb." & LCase(sGui) & " gambas3") hNew.DesktopActions[sGui]["Name[fr]"] = "Exécuter avec " & sGui hNew.DesktopActions[sGui]["Name[nl]"] = "Uitvoeren met " & sGui hNew.DesktopActions[sGui]["Name[it]"] = "Esegui con " & sGui Endif
Else
If aActions.Exist(sGui) Then Inc iChanges aActions.Remove(hNew.Actions.Find(sGui)) hNew.DesktopActions[sGui].Delete Endif aToolkits.Remove(c)
Endif Next
If sExisting And If iChanges = 0 Then Error.Raise("No changes made to desktop menu icon") hNew.Actions = aActions hNew.Save If Not bCanWrite Then Shell "xdg-desktop-menu uninstall gambas3.desktop\nxdg-desktop-menu install --novendor " & Shell(sTemp) & "\nxdg-desktop-menu forceupdate" Wait Kill sTemp Else Shell "xdg-desktop-menu forceupdate" Wait Endif Print "gambas3.desktop menu " & If(bCanWrite, "reconfigured", "rebuilt") & " with toolkits: " & aToolkits.Join(", ")
Catch Print Error.Text If Exist(sTemp) Then Kill sTemp
End ' >/tmp/GambasDesktop/.src/GambasDesktop.module