I went on a little adventure today. For a long time I had seen the “Create New” menu in Dolphin as something of limited use, mainly for creating new folders. I knew there was more to that, as I had seen screenshots showing all sorts of different entries besides the default “New folder”, “Text file” and “HTML file”. So I decided to find out how I could add my own. Turns out it’s not well documented.
First, I opened Dolphin’s help tool. This opens an offline version of KDE’s online help documentation. As you can see, the “Create New” entry just points you to the older Konqueror documentation for create new. Neither explain how to add items to the menu, even though it hints that it is possible. To the DuckMobile!
Turns out, some packagers on different distributions have been adding to this menu when various applications get installed. For instance, when you install LibreOffice, you may get entries to create new documents that LibreOffice can edit. For some reason openSuSE doesn’t, nor would I imagine ArchLinux, but that’s okay, because we can do it ourselves!
What I found was this. Each item should be an XDG Desktop file located in a special folder in either your home directory, or in the system shared template folder. You can see where those are by running:
$ kf5-config --path templates /home/ndegruchy/.local/share/templates/:/usr/share/templates/ # This is what I get on my system
This shows you, in POSIX-y PATH format that my template folder(s) are located in the local shared folder and in the system shared folder. Nice. Now I know where to put these files. Now, to figure out how to make them:
# ~/.local/share/templates/LibreOffice\ Writer.desktop [Desktop Entry] Name=LibreOffice Writer... Comment=Enter LibreOffice Writer filename: Type=Link # Point this to a file that exists, in this case, the file is located in a # new directory adjacent to templates, called template-sources. URL=../template-sources/writer.odt Icon=libreoffice-oasis-text
That’s simple! It’s a basic desktop entry linking to a file. So I created some blank LibreOffice files, dropped them into (in my case) template-sources folder, wired up all the desktop files to the right file and viola!
You can do this for all sorts of files. I did one for Fish Shell scripts, too. I’m thinking about one for LaTeX documents and some other simple tools.
Hope this helps someone!
Attached are my templates, in case you want to just drop them in.