Application icons in Linux

Deploying to Linux? Get penguinated here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Tue Dec 25, 2018 1:54 pm

All high fives enthusiastically returned, I wouldn't have ever made it for myself :D

Not all of what is in the file is necessary for a launcher strictly speaking, if you have any questions about the logic behind it or what is the bare minimum needed or anything like that, feel free to ask.

Other than that, I can't wait to hear how it works out for you :D

Edit - I should have mentioned, it should be desktop agnostic, but this was not thoroughly tested by me. If you find a glitch for a specific 'nix desktop, please let me know :mrgreen:

*Edit 2 - In the writeMe function, I forgot to set the itemDelimiter to /, if you decided to change the saving to the 2 lines in the comment it would fail. The corrected files are now here.

**Edit 3 - if you decide to change categories AND automate the file, here is a list of the main categories that you can use...
Selection_001.png
Main categories for menu entries...
Last edited by bogs on Sun Jan 13, 2019 2:17 pm, edited 4 times in total.
Image

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Tue Dec 25, 2018 11:00 pm

Caught an error in my original code, see edits above :oops:
Image

sphere
Posts: 954
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Application icons in Linux

Post by sphere » Tue Dec 25, 2018 11:35 pm

Hi Bogs,

thanks for your effort.
I resaved it as a 64bit standalone.
It sees the program and the png like in your screenshot.
Then i choose the catgory like Office.
Then push write. After that it seems to write something, but appears to me that nothing is happening furter.
I will check your code out tomorrow, to see what route is youǘe written.

thanks mate !
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Wed Dec 26, 2018 12:16 pm

sphere wrote:
Tue Dec 25, 2018 11:35 pm
Then push write. After that it seems to write something, but appears to me that nothing is happening furter.
I will check your code out tomorrow, to see what route is youǘe written.
Actually, you can see the changes in the preview field (one at the bottom). The specific change is to 'Categories=' and 'Comment=' (if you fill out a comment). These two screen shots were made using Andy P's excellent launcher program as the base program.

The code I corrected was in case you decide you want to automate the whole thing on launch (no user interaction). The path failed because I forgot to set the itemDelimiter :oops:

So before -
Create Linux Desktop Launcher Automatically..._001.png
Default file written...
And after -
Create Linux Desktop Launcher Automatically..._002.png
Category and comment changed....
I probably should have included some kind of instructions for use, but hey, this had taken me half a day already, and that might have added another 10 or so seconds :P

To give a short breakdown, the top field is the template text. It gets put into the bottom field, which is the preview of what is written. This could just as easily go into a cProp, but I was looking for expediency in editing it (was simple to switch to run, make the edit, switch back).

The category combobox just selects where in the menu the program will show up, the comment really isn't necessary at all, but offers a nice tooltip when the menu item is hovered over.

If you choose to change the category, but not add a comment, the comment line is left empty in the final entry (also shown in the preview pane).

Hope that clarifies it some.

*Edit - as I am looking over the pictures I posted, I see I also forgot to add a line to copy the name to the StartupWMClass line :oops: Not vital or crippling, but lets the window manager know what to tie the entry too by name.
Image

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Wed Dec 26, 2018 3:11 pm

Updated to take into account wmclass and some extraneous code being removed.

*Edit - both stacks are now here.
Last edited by bogs on Sun Jan 13, 2019 2:16 pm, edited 3 times in total.
Image

sphere
Posts: 954
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Application icons in Linux

Post by sphere » Wed Dec 26, 2018 9:47 pm

thanks Bogs, i will check it out.
I saw that a startup file is been created. That startsup the executable fine. But i see no icon appearing. The image is mentioned in the lower part of the screen but not in the upper.
I don;t think i have to copy that line to the auppre, as you've said, the lower is what is written to the startup file.

Happy days!
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Wed Dec 26, 2018 9:59 pm

Happier days yet, I spent an additional half a day cleaning it up (code wise) and turning it into a completely automated file maker, but I think I'll take a full day (or at least, the rest of this day) to test it out :wink:
sphere wrote:
Wed Dec 26, 2018 9:47 pm
But i see no icon appearing.
Where exactly are we looking when we don't see the icon? In the menu, or for the file itself?

*Edit - I forgot to answer this...
I don;t think i have to copy that line to the auppre, as you've said, the lower is what is written to the startup file.
No, you absolutely shouldn't have to copy any part of any field to anywhere else :)
Since the launcher is put (by default) into the resource folder, though, if you want it added to the menu you have to copy it to your ~/.local/share/applications folder.

Just uncomment the lines in the writeMe() marked for automating marked by the arrows -

Code: Select all

   /* for writing to actual location for menu icon directly change the above line to the following 2 lines 
   -> put item 1 to 3 of tmpPath & "/.local/share/applications/" into tmpLocalFolder 
   ->  put field 1 into url("file:" & tmpLocalFolder & tmpName) "
   */
*Edit - later that day, I'm satisfied it is working as I expect it to. Turn off messages before opening it in the IDE, and I would suggest setting a break point and going step by step the first few times you run it.

Also, comment out the last line that closes the stack (destroy is set for both stack and window).

*Edit - both stacks are now here.
Last edited by bogs on Sun Jan 13, 2019 2:16 pm, edited 3 times in total.
Image

sphere
Posts: 954
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Application icons in Linux

Post by sphere » Wed Dec 26, 2018 11:08 pm

Where exactly are we looking when we don't see the icon? In the menu, or for the file itself?
at the place where the starter script is being created.

Iw ill test out some more and let you know.
Thanks a lot in advance for all effort you put in to this, just great and highly appreciated!
Doing me and other community members a big favour!
thx.jpg
thx.jpg (9.51 KiB) Viewed 1854 times
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Wed Dec 26, 2018 11:34 pm

Thanks for the thanks, but lets make sure this will actually help out and not hurt more than it helps :wink:
sphere wrote:
Wed Dec 26, 2018 11:08 pm
Where exactly are we looking when we don't see the icon? In the menu, or for the file itself?
at the place where the starter script is being created.
Are you talking about the file in this folder?
Selection_006.png
Here ?
Selection_006.png (8.16 KiB) Viewed 1853 times
If there is no icon showing up, does it look like this instead?
Selection_007.png
I didn't make this one...
Selection_007.png (4.31 KiB) Viewed 1853 times
If it does, the only way to tell if we have the icon working correctly on your system is to put it into this folder -
Selection_008.png
Yah, this one!
After you put the icon in there, give it a few seconds (depending on how your desktop looks for it) and see if it shows up in the menu. If it shows up in the menu, your good to go. If not, I may need to install whatever OS your using and see if I can figure out why not.
Image

sphere
Posts: 954
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Application icons in Linux

Post by sphere » Thu Dec 27, 2018 9:07 pm

Are you talking about the file in this folder?
yes indeed
I'm on Ubuntu Mate latest version 64bit
in the folder you show your icon , i see this:
Schermafdruk op 2018-12-27 20-49-15.png
Schermafdruk op 2018-12-27 20-49-15.png (8.96 KiB) Viewed 1810 times
So in fact it is blank

i did not yet uncomment the lines as youǘe mentioned, so i will try and see what it does.
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Thu Dec 27, 2018 10:09 pm

Well, uncommenting them won't ( I think ) fix that. Lemme run a test on your desktop in a Vm, and see what happens. If I remember my last time with Ubuntu, it will probably be tomorrow before I get back to this.

*Edit, may get to it tonight, but it is going to be close :D
Image

sphere
Posts: 954
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Application icons in Linux

Post by sphere » Fri Dec 28, 2018 10:58 am

bogs wrote:
Thu Dec 27, 2018 10:09 pm
*Edit, may get to it tonight, but it is going to be close :D
Don't forget to sleep and relax these days :mrgreen:
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Fri Dec 28, 2018 5:13 pm

sphere wrote:
Fri Dec 28, 2018 10:58 am
Don't forget to sleep and relax these days
I wasn't able to complete testing last night, you know, wife impatient with my foolishness and the like :twisted:

But I did complete testing today!
StepOsTesters [Running] - Oracle VM VirtualBox_002.png
Whoomp there it is!
Ok, so, that is how the Mate desktop does indeed do .desktop launchers for the menu. In the picture above, I used the downloads folder as the folder holding the livecode exe file. I renamed the livecode file to remove the .x64 extension to make sure makeLauncher would read it correctly (this behavior can be changed by modifying the code to pick up any exe file by property, but we can look into this later if it is required).

When I ran the program, it correctly picked up the Lc setup file, and the icon I put into the folder next to it, and placed those into the menu (see highlighted menu entry).

When I clicked on the menu entry, it did indeed launch the livecode installer. Let me know if this is not the behavior your seeing, far as I can tell here, it is working as I expect it to on Ubuntu bionic with the Mate Desktop.

Some things to note about using the Standard Launcher Maker or the
Semi-auto Launcher Maker program which you can get here:
  1. The folder makeLauncher is in (which can be renamed to anything you like) needs to be put inside the folder with the exe file you want to make the launcher for (looks like you did this correctly).
  2. The icon image needs to be in the folder that contains the program your trying to create the launcher for. If there is more than one icon image in that folder, the program will cycled to the last image and use it in this order - .png, then .svg. so if you have 2 .png files, and 1 .svg file, you'll *wind up with whatever the first file read was.
  3. This will work correctly for only one linux executable currently, which should be a bare name with no extension attached, for instance, 'myProgram' will work, 'myProgram.x64' will not (again, looks like your setup is fine, this is for people who hit it later in time).

* because of the loop the statements are in, which reads -

Code: Select all

   // find and set the path to the icon file...
   repeat for each line x in the files
      if ".png" is among the characters of x then put x & cr into tmpFiles
      if ".svg" is among the characters of x then put x & cr into tmpFiles      
   end repeat
   put  the defaultFolder & slash & line 1 of tmpFiles after line 5 of field 1
so which you wind up with will depend on how they are listed in the files, which depends on the way the os lists them, not by extension :)
Last edited by bogs on Sun Jan 13, 2019 2:14 pm, edited 3 times in total.
Image

sphere
Posts: 954
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Application icons in Linux

Post by sphere » Fri Dec 28, 2018 9:04 pm

That's familiar...
you know, wife impatient with my foolishness and the like
and i'm not even allowed to explain, as they (yes they, wife & daughter) don't care :lol:

anyway i'm half way:
kantoorentry.png
the entry is in Office, so that worked. I also now for simplicity sake putted the files in the download folder.
But no icon yet.

Is there a limit on px size what i can use before it is accepted as icon?
I used a PNG and you used a SVG file ( i can try again with a svg if that might be the issue) ***edit--this does'nt matter, as expected
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

bogs
Posts: 3921
Joined: Sat Feb 25, 2017 10:45 pm

Re: Application icons in Linux

Post by bogs » Fri Dec 28, 2018 9:51 pm

sphere wrote:
Fri Dec 28, 2018 9:04 pm
and i'm not even allowed to explain, as they (yes they, wife & daughter) don't care
Good, we're really on the same playing field now :twisted:
sphere wrote:
Fri Dec 28, 2018 9:04 pm
I also now for simplicity sake putted the files in the download folder.
I am sorry, I used the download folder to show it should make no difference where you launch the makeLauncher from, nor should it matter what is in the file below (as long as it is an exectuable and a picture :wink: )

Spaces in the path to the exe, for instance, should make no difference since I enclose the entry in quotes for the exe (not necessary for the icon).

I tested the png size it will accept by going into rediculous mode. I am pretty sure I can confidently say that size should not matter 8)

Here was the test run.

I took this picture which is 2048x2048 ...
StepOsTesters [Running] - Oracle VM VirtualBox_001.png
2048x2048 resolution...
StepOsTesters [Running] - Oracle VM VirtualBox_001.png (102.91 KiB) Viewed 1511 times
I then moved everything needed to a folder I created on the desktop and put plenty of spaces in the name...
StepOsTesters [Running] - Oracle VM VirtualBox_002.png
Space, the final frontier...
Lastly, I clicked on make launcher and voila, the picture for the icon showed in the menu...
StepOsTesters [Running] - Oracle VM VirtualBox_003.png
Not bad eh?
I really can't think of any reason size should be an issue, or whether the image is png or svg. I just like svg icons because of their scaling ability.
Image

Post Reply

Return to “Linux”