Afternoon, gang.
Following a suggestion from bigpup - about turning some of the content of a post I made earlier today into a 'How-to' explainer - I decided it would be a good idea.
The subject is that perennial old chestnut; how to write a .desktop file that will generate a working Menu Entry in Puppy.....and how do you achieve it? I've been writing these things for years, and can almost do them in my sleep now, I've created so many of them.
I thought it might be nice to share that knowledge, in a clearly-written 'tutorial'. Very briefly:-
The files that generate Menu entries are called xxxxxxxxx.desktop files (where "xxxxx" will be the name of the application or program.)
The name is usually (though NOT always) the name of the app/program itself. (You CAN call it whatever you want, but short and to-the-point is usually best).
The .desktop files are in /usr/share/applications
A bit of background:-
The folks at FreeDesktop.org are the people in charge of maintaining cross-platform, cross-architecture specifications & standards. I'm sure most of us have looked at .desktop files from time to time; some of them, containing tons of localization stuff, designed to cater for all languages globally, can run into hundreds of lines.
Most of the big 'projects', when they release software, have to try and ensure their .desktop entries will be compatible with every possible combination of display server/window manager/filesystem manager/ desktop environment (DEs) you can imagine. Some of these use lines & categories that are specific to them, and them alone......but it all still has to be included.
Fortunately, we're not so constrained here in Puppyland. Much of this stuff can be 'junked'; all that Puppy requires to give a fully functional Menu entry boils down to a handful of lines.....which I will now demonstrate. This is just an example:-
audacity.desktop
Code: Select all
[Desktop Entry]
Encoding=UTF-8
Name=Audacity
Comment=Edit/record audio files...
Exec=audacity
Icon=audacity
Type=Application
Terminal=false
Categories=X-Multimedia
A quick explanation of each line:-
[Desktop Entry] - this is the bog-standard, default first-line entry for every .desktop file I've ever seen, as provided for in the freedesktop.org standards. This defines it as being a Menu entry configuration file.
Encoding=UTF-8 - this is the recommended character setting for defining ASCII characters. I never mess with this one.
Name - this will be the name of the entry as it appears in your Menu.
Comment - optional, but if you provide this, you get a wee tooltip showing the exact same text when browsing through the various .desktop files in /usr/share/applications.
Exec - the command/name of the executable that will launch your application. A properly-constructed standard .pet or .deb package - or an SFS - will place this command in one of a handful of standard locations (usually the 'bins'; /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin.....and a Puppy 'special', /root/my-applications/bin). These are always defined as being "in the $PATH"; I forget the specific file, but there is one in every Puppy, usually loaded at boot-time, that defines these '$PATHs' to the system.
When your executable lives 'in the $PATH', only its name is needed here. Nothing else. Puppy WILL find it.
(If your executable lives in a non-standard location - and there is no fixed requirement that it MUST be in a standard one; things will run from anywhere in a Linux system - simply provide the $PATH in full. We just want the Menu entry to find it when requested to do so.)
Icon - self-explanatory. The small image that sits in front of the Menu entry, and also displays with your .desktop file in /usr/share/applications. These often live in /usr/share/icons in the "big boys", under tons of sub-directories that specifically define them to particular parts of a mainstream distro. In Puppy, we use, usually, one of two locations; either /usr/share/pixmaps, or sometimes /usr/local/lib/X11/pixmaps.
(You can obtain icons for pretty much anything with a web-search for, say, "PNG icons for xxxxxxx (whatever)". I recommend PNG icons because of the transparency layer; these blend-in far better to any background you place them on. Size isn't too important; anywhere from 128x128 up to and including 512x512 will work. Larger icons give sharper detail when re-sized down to 48x48; ROX-filer will automatically do this where necessary.)
If you're really adventurous, and fairly competent with a vector or raster graphics editor, you could always make your own. I've done this on several occasions over the years.
Type - this, according to FreeDesktop.org, can be one of three things. 'Application' (almost always), 'link' or 'directory'. I've never seen either 2 or 3 used. Ever.
Terminal - defines whether or not the application runs in a terminal. Options are 'true' or 'false' - usually the latter - and this is the only one that is always written in small letters, for some reason.
Categories - defines which area of the Menu your application will occupy when 'installed'. Usually, it's sufficient - to get a 'working' entry - to simply stick "X-" in front of the required Menu category. E.g., "X-Desktop", "X-Utility", "X-System", etc. If you want to be more specific, find another app in the same place in the Menu, look up its .desktop file in /usr/share/applications, then open that up with Geany & 'borrow' the Categories line. It usually works.
Must make category one of the ones used in the Puppy main menu or sub menu. These are only ones available for making working entry to the menu.
Occasionally, an optional extra line - MimeType - is included. This is not compulsory, but can be used to associate a particular application with specific 'mime-type' files, as provided in /root/Choices/MIME-types.
These should be listed, and separated by semi-colons ";". Don't leave spaces between them.
If you write these from scratch, go into /usr/share/applications, rt-clk in an empty bit of the window->New->Blank file. It's NOT a script; rather, it's a set of instructions that tell the rest of the system where to look for stuff, and then what to actually DO with it. Don't forget to append the .desktop suffix when you name it. You'll need to rt-clk it fairly quickly when the file is blank and you're ready to write the lines out; hovering over the .desktop entry, the system attempts to 'parse' it.....and if it's blank, it moans that it can't read it & throws up an error message.
If you get the error message, just clear it and try again.....right-click a little bit quicker next time!
And that, mes amigos, is how to write a basic, functional Menu entry for Puppy Linux. After you've created your .desktop file, and placed a suitable icon in the desired location, all you need to do is to open a terminal, run
Code: Select all
fixmenus
.....and wait for it to come back to the prompt "#" (doesn't take many seconds), then re-start JWM:-
Code: Select all
jwm -restart
Less disruptive than re-starting the graphical server - which closes anything you may have open, and can lose work in the process - re-starting JWM will still place the Menu entry where we want it. After all this time, I've long had one-click scripts that do all this stuff for me.
Your Menu Entry should now be showing in the desired location, and should be fully functional.
Hope some of you guys find this helpful.
Mike.