This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Adding my own templates to 'Create New' menu

Tags: None
(comma "," separated)
kde-deshmukh
Registered Member
Posts
184
Karma
0
I am running KDE 4.11.3 on Kubuntu 13.10.

In Dolphin, on right click, there is a 'Create New' menu with pre-defined options like a directory/ folder, text file, etc.

How can I add my own templates to this? Say, a personal letter, etc.?

Elsewhere on the forum, there was a mention of /usr/share/kde/templates. But there is no such directory on my computer.

I created a ~/.kde/share/templates and added a file there. It does show in the 'Create New' menu now. But selecting it does nothing.

So, how do I add my own templates to 'Create New' menu?

By the way, Gnome has a simple solution --- all files in ~/Templates show up in the right click menu.


--
Manjaro KDE. Kernel 4.19.244-1-MANJARO. 64-bit. Plasma 5.24.5. KDE Frameworks 5.94.0. Qt 5.15.4. 8GB RAM and more than 100GB free on the hard disk.
wolfi323
Registered Member
Posts
1129
Karma
11
OS
kde-deshmukh wrote:Elsewhere on the forum, there was a mention of /usr/share/kde/templates. But there is no such directory on my computer.

Well, I guess it would be /usr/share/kde4/templates/. At least it is on my system.

You can find out which directories are searched for templates by running:
Code: Select all
kde4-config --path templates


I created a ~/.kde/share/templates and added a file there. It does show in the 'Create New' menu now. But selecting it does nothing.

This should work.

But what kind of file did you add there?

The templates should be *.desktop files of type "Link". The easiest way to create one would be to copy an already existing one from /usr/share/kde4/templates/ and modify it accordingly. But don't forget to change its filename, otherwise it will override the global one.

A minimal example would look like this:
Code: Select all
[Desktop Entry]
Name=my_file
Comment=My own template
Type=Link
URL=path_to_a_file_with_the_default_file_content
Icon=text-plain
kde-deshmukh
Registered Member
Posts
184
Karma
0
That did the trick. Thanks. I am accepting your answer and marking this as solved.

But again, IMHO, adding files to a specific directory is MUCH simpler.


--
Manjaro KDE. Kernel 4.19.244-1-MANJARO. 64-bit. Plasma 5.24.5. KDE Frameworks 5.94.0. Qt 5.15.4. 8GB RAM and more than 100GB free on the hard disk.
wolfi323
Registered Member
Posts
1129
Karma
11
OS
kde-deshmukh wrote:That did the trick. Thanks. I am accepting your answer and marking this as solved.

But again, IMHO, adding files to a specific directory is MUCH simpler.

A maybe easier way to create such a template would be this:
- navigate dolphin to the ~/.kde/share/templates/ folder
- right-click and choose "Create New"->"Link to Location (URL)..."
- enter something.desktop as name and select a file as location.

You should then have a new template that creates the file you selected.
kde-deshmukh
Registered Member
Posts
184
Karma
0
wolfi323 wrote:A maybe easier way to create such a template would be this:
- navigate dolphin to the ~/.kde/share/templates/ folder
- right-click and choose "Create New"->"Link to Location (URL)..."
- enter something.desktop as name and select a file as location.

You should then have a new template that creates the file you selected.


This does not work. I did exactly as suggested by you. The file I selected was a file in ~/Templates.

In ~/.kde/share/templates, now I see a folder icon with the test1.desktop as name.

On right clicking in ~, there is no test1 in the 'Create New' menu.

Something missing?


--
Manjaro KDE. Kernel 4.19.244-1-MANJARO. 64-bit. Plasma 5.24.5. KDE Frameworks 5.94.0. Qt 5.15.4. 8GB RAM and more than 100GB free on the hard disk.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Please open "test1.desktop" in a text editor and post it's contents here so we can examine it.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
kde-deshmukh
Registered Member
Posts
184
Karma
0
My apologies.

I think I did not restart the file manager.

It works just as expected. The file contens are:

[Desktop Entry]
Icon=folder
Type=Link
URL[$e]=file://$HOME/Templates/empty.txt

I am marking this as answered.


--
Manjaro KDE. Kernel 4.19.244-1-MANJARO. 64-bit. Plasma 5.24.5. KDE Frameworks 5.94.0. Qt 5.15.4. 8GB RAM and more than 100GB free on the hard disk.
rockscient
Registered Member
Posts
5
Karma
0
wolfi323 wrote:You can find out which directories are searched for templates by running:
Code: Select all
kde4-config --path templates


Hello,

since this is one of the first results that show up on Google, on KDE5 that command does not work.

You can put your templates in the directory returned by

Code: Select all
xdg-user-dir TEMPLATES


Which generally will be "/home/<USERNAME>/Templates".

You need to create both the template (the empty file that will be used when you right click->create new->file) and the .desktop file for the template.

For instance, this is my .desktop file for LibreOffice Writer templates:

Code: Select all
[Desktop Entry]
Name=Document
Comment=LibreOffice Writer
Type=Link
URL=Document.odt
Icon=libreoffice-writer


Where "Document.odt" is an empty file in the same folder


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], daret, Evergrowing, Google [Bot], lockheed, mesutakcan, sandyvee, Sogou [Bot]