Can I add custom servicemenu items to Gwenview?


I made a simple kio servicemenu addition for Dolphin, and it works just fine when I put it either ~/.local/share/kio/servicemenus/touch_file.desktop or /usr/share/kservices5/ServiceMenus/touch_file.desktop. As the name implies, it allows me to change a file’s timestamp (using the “touch” command").

Now, i’d like to be able to do the same in Gwenview, either while viewing a single file, or in browse mode. I tried adding a “servicemenus” directory under ~/.local/gwenview (it didn’t exist by default) and copying the .desktop file in there, but it doesn’t seem to work. Is there some documentation about this? Can it be done in the same way as for Dolphin, or is this a development task?

I doubt you can add it as a servicemenu. I’m not sure what exactly your desktop file does and how it works but I added some functionality to gwenview in terms of “set as wallpaper” ( which is lacking in Gwenview for some reason). But that is a desktop application I made in ~/.local/share/applications and uses a script. If you can use the touch command, either as a script or as direct exec in the desktop file, you can use it in Gwenview in “open with”.
Example with the wallpaper thingie.

@dzon Thanks for the quick reply! I like the alternative approach via “open with” for Gwenview. I was just hoping that KDE would have standardized all this by now, but there’s more important things to do.

My little .desktop file is as as follows…

#Place in ~/.local/share/kio/servicemenus/touch_file.desktop or /usr/share/kservices5/ServiceMenus/touch_file.desktop

[Desktop Entry]

[Desktop Action touchFile]
Name=Change File Timestanp With Touch
Exec=touch %U

When placed in the correct directory, it adds a context menu item to Dolphin, as you can see in the attached screenshot…and that’s what I’d like for gwenview…

Like I said, you can make an app desktop file for it. Assuming that’s a working command, it would be something like in the screenshot. Make sure to make the file executable and add it to the programs, associations ( image) in system settings so that it pops up in Gwenview. No idea if that will work as far as the command goes, but you get the idea.
TouchStuff. What an idea to name it like that :rofl:


any KDE app, that somehow supports / provides file (system) actions should have the ability to get exetended by service menus and that’s what the name implies. Gwenview does(!) allow the creation of directories and moving or renaming files, so it qualifies easily for the extensibilty as defined. actualy i would like to believe, that this was the original concept of service menus. a simple key in the desktop entry files filters the apps, that display a specific menu item, such as: Apps=dolphin;konquerer;gwenview;ark;

No, as servicemenus as such wouldn’t work depending on the app ( I’m thinking keyboard emulating commands with xdotool for example). However, what WOULD be a biiiiiig + is a customizable toolbar button. This has been on a wishlist for yeeears and at some point there was a git version of dolphin that allowed just that, adding custom made actions to the toolbar. There are many file managers that have that function ( nowadays thunar, always caja, nemo, pcmanfm-qt, krusader,sweet lord spacefm…). But this functionality shouldn’t be restricted to the file manager but implemented in any kde “core” app. Sure, you can add some to kate but…that’s about it.

@dzon how do you pass the filename (or any argument) to your script?

Script? There’s no script involved here. I used the same command for the desktop application. Put it in ~/.local/share/applications. Make it executable. Afterwards go to system settings and add it to any file type you wanna use it with. Works both on thumbnails as main image in Gwenview.

[Desktop Entry]
Exec=touch %U

Of course, if you want a more elaborate ( dunno, something which requires a yad or kdialog or whatever) thing which does require a script, point the exec to the script.
As an example: