Most of the time Java or Python programs are launched via bash script in order to call the “java” or the “python3” commands.
So when an icon is attached to the bash script (which is launching the program), it’s well recognized at the “.sh” file level (“PC” icon for PyCharm below):
However once the program is launched, in the Deskbar we can see “java” or “python3” in the Deskbar with the default icon :
Would it be complex to have the possibility to override the Deskbar’s behavior, so that in some situations it will not display the “java” or “python3” name but instead the original script’s name which was called ?
Hence the correct icon would be displayed for the application.
What I did at one stage was write a little yab program that did little more than make a system call to the java app. Compile the yab app and you can give it an icon and a proper x-vnd app signature and so on with the FileTypes add-on. It then shows up in the Deskbar as a proper program. I suppose the same principle could apply with C++.
For Python scripts, one way to do it is how it is done for the monsterz game. Warning, can be addictive
Edit: if your Python scripts give you troubles when you double click them to start, you might want to take a look at this part of the patchset for monsterz.
Edit2: weird, installed Monsterz on a new install, and it doesn’t starts. Complains about not being able to find pygame, despite it being installed. Sigh… will try to find out what got broken there. Not actually broken for anyone but for silly me.
FWIW, haven’t been able to fix the pygame/Monsterz issue yet, but if one installs it with pkgman install -H monsterz (package ends up under $HOME/config/packages), it DOES works.
And yes… invoking it from Terminal only shows python3 and the generic icon. No idea if there’s any workaround for that, other than B_DONT_DO_THAT, and call it only from GUI, or writting a small c/c++ wrapper and adding the icon as a resource to it.
Edit: welp… the pygame/Monsterz not working was only a “me” thing. I had forgotten to remove a locally built Python 3.10.16 package (installed under $HOME) that I used for testing when I last updated that recipe. Sigh.
launch process: As per any POSIX setup, files are executed according to the two byte “magic number” header, and “#!” is the code for “interpreted file where # is a comment”; the path to the interpreter follows, and you get a optional command line argument. (So for example, sh is usually just #!/bin/sh and the system then launches /bin/sh /boot/home/config/non-published/bin/shscript or whatever your file, but for awk you need #!/bin/awk -f, so awk will know what’s going on when it comes up /bin/awk -f /boot/home/config/.....) The point being, at any rate, it’s just like invoking the same full command from the command line. Even though the full command line is determined by the interpreted file, the command that gets launched is /bin/python3 ... or whatever, and that’s what counts here.
launch vs. exec: Check me on this, but I think this is an important difference here: the application icons, file types etc. happens at launch, and you can exec to whatever other executable image afterwards without disturbing that. I’m talking about the execve(2) system call.
application icons, file types etc.: - attributes of the file that’s launched. The file can have been compiled from any language, but not interpreted, so that level of Haiku integration is achieved by an interpreted program by an auxiliary component that either execs the interpreter after the application signature etc. has been established, or (conceivably I guess but not typically) is linked into the same image and just calls it. I believe things like receiving file refs from the launch can be done from the interpreter later, if it has wrapper access to the necessary BApplication functionality.
I could be off on some of this, as it has been years since I did anything with it (other than shell and awk scripts, of course.)
Could you check if the next one works for you, used it already a few times on python scripts and saved (with tips from IRC) a “template” on my own wiki to quickly do a search for it.
This is used already for quite some recipes at haikuports: