Need clarity on service menus

i’m aware of this article describing how to approach service menus within dolphin.

but how does it apply to the context menu when you right click on the desktop?

under configure desktop > mouse > right-button > standard menu > configure

i can see the check box for “other actions” which brings in a “Create New” service menu, among other things.

but i don’t see any way to add my own entry to the menu without clicking on a file or folder that matches the mime type specified in the .desktop file.

wondering how i can add a menu entry like the “Create New” one that is active with just a right click onto the desktop, and nothing selected.

or what if i wanted to add an entry to the context menu that pops up when you right click on a pinned icon in the task manager such as those listed under “Actions”.

can this be done? or are service menus limited to the context of an application, file or folder being clicked on?

You can’t add something to the right click desktop menu. As a matter of fact, a whole bunch of servicemenus that work on files in the desktop directory in dolphin won’t even show on the desktop itself. As for added entries in pinned tasks, those depend on how you edit the application.

I guess you could create an entire main application menu and add whatever you want besides applications…( like commands, scripts..)

As for the pinned ( or not) icons in the task manager…for example:


Just like they’d work in the application wherever it’s at, like in a app menu:

So, for example, the konsole one would look like:

Ok thanks for the info on the main context menu… so if there is no mime type under the cursor when you right-click, then you just get the generic hard coded desktop context menu, and nothing can be done about that.

but in your 3rd pic you show a context menu for an item in the taskmanager that looks a lot like this one from dolphin in my task manager… it has the same set of "Actions near the bottom.

but that whole section in your pic shows there are a half a dozen service menus above those default menu options… you even have a couple of your own separators in there.

the .desktop code snipit you showed does not detail those entries… the one’s for upload to google, or “Set as wall”, or “CopyTo” which is right there above the “Open in New Window” action i have on my pic.

that’s what i’m looking to do… how were those service menus achieved in the taskbar context menu like that?

Like I said, make them in the app. It doesn’t matter what they are. They could be stuff that otherwise would require to go in the app’s menu, scripts, open-with…Just edit the app ( located in ~/.local/share/applications) to your likings. That third pic is for qimgv which hardly contains, if any, right-ckick stuff. As for those upload to entries, they’re a cheat. Since I don’t use any G-account stuff ( which always breaks since the last ice age by the grace of some Google nerd having a bad day)) they’re simply commands to open those two ssb’s after which I can just drag 'n drop stuff ( see screenie).

This is piece of the desktop application qimgv. What counts are the actions. Those are the ones that will show in the right click of that app.
Note the actions part in the desktop entry:

[Desktop Entry]
Actions=1Gphotos;2GDrive;SEPARATOR;SetAsWall;Gimp;Brave;Ksnip;Kupscayl;Print;Slideshow;SEPARATOR;CopyTo;
Categories=Qt;Graphics;Viewer;
Comment=Qt image viewer
Exec=env QT_STYLE_OVERRIDE=Kvantum qimgv %f
GenericName=Image Viewer
Icon=/home/john/.icons/gwen.png
Keywords=image;view;qimgv;picture;gif;jpeg;webm;
MimeType=video/webm;image/jpeg;image/gif;image/png;image/bmp;image/webp;
Name=qimgv
NoDisplay=false
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
Version=1.0
X-KDE-SubstituteUID=false
X-KDE-Username=

And here are two examples of those actions:

[Desktop Action 2GDrive]
Exec=brave-browser --app=https://drive.google.com/drive/my-drive --class=WebApp-Drive9678 --user-data-dir=/home/john/.local/share/ice/profiles/Drive9678
Icon=/home/john/.icons/All Google/48/drive_48dp.svg
Name=Ulpoad to Google Drive

[Desktop Action SetAsWall]
Exec=xdotool key ctrl+w
Icon=/home/john/.icons/favs.png
Name=Set as wall

The structure of the customized application will always be the same. What you want in them depends on your needs.

Here’s the one for konsole:

[Desktop Entry]
Actions=NewWindow;NewTab;2X2;SEPARATOR;3Inxi;SEPARATOR;Shabbam;Htop;Speedtest;GDU;Ranger;Nmap;Cava;Flatpakup;Flatpakclean;SEPARATOR;FileTabs;
Categories=Qt;KDE;System;TerminalEmulator;
Comment=Toegang tot de opdrachtregel
Exec=konsole --new-tab
TryExec=konsole
GenericName[nl_BE]=Terminal
GenericName=Terminal
Icon=utilities-terminal
Name[nl_BE]=Konsole
Name=Konsole
NoDisplay=false
Path=
StartupNotify=true
StartupWMClass=konsole
Terminal=false
TerminalOptions=
TryExec=konsole
Type=Application
X-DBUS-StartupType=Unique
X-DocPath=konsole/index.html
X-KDE-AuthorizeAction=shell_access
X-KDE-SubstituteUID=false
X-KDE-Username=

[Desktop Action Cava]
Exec=konsole -e cava
Icon=amarok_playcount
Name=Cava

[Desktop Action Flatpakclean]
Exec=konsole -e /home/john/Scripts/Flatpakcleanup.sh
Icon=edit-clear-history
Name=Flatpak Cleanup

[Desktop Action Flatpakup]
Exec=konsole -e /home/john/Scripts/Flatpakupdate.sh
Icon=gtk-convert
Name=Flatpak Update

[Desktop Action GDU]
Exec=konsole -e gdu
Icon=drive-partition
Name=Gdu

[Desktop Action Htop]
Exec=konsole -e htop
Icon=utilities-system-monitor
Name=Btop

[Desktop Action 3Inxi]
Exec=konsole -e /home/john/Scripts/InxiShort.sh
Icon=computer
Name=Inxi

[Desktop Action NewTab]
Exec=konsole --new-tab
Icon=tab-new
Name[nl_BE]=Een nieuw tabblad openen
Name=Open a New Tab

[Desktop Action NewWindow]
Exec=konsole
Icon=window-new
Name[nl_BE]=Een nieuw venster openen
Name=Open a New Window

[Desktop Action 2X2]
Exec=konsole --layout /usr/share/konsole/2x2-terminals.json
Icon=tab-new
Name[nl_BE]=2X2
Name=2X2

[Desktop Action Ranger]
Exec=konsole -e ranger
Icon=folder
Name=Ranger

[Desktop Action Shabbam]
Exec=konsole -e /home/john/Scripts/shabbam.sh
Icon=alienarena
Name=Shabbam

[Desktop Action Speedtest]
Exec=konsole -e /home/john/Scripts/speedtest.sh
Icon=chronometer
Name=Speedtest

[Desktop Action FileTabs]
Exec=konsole --tabs-from-file /home/john/.konsole/current-tabs
Icon=utilities-terminal
Name=Tabs from File

[Desktop Action Nmap]
Exec=konsole --no-close -e nmap -sn 192.168.0.1/24
Icon=utilities-terminal
Name=Nmap

Just another example, smplayer.
For this entry I need to go into menu>playlist>add to playlist, quite a few steps. This adds a shortcut to the rightclick. Sure, I have an enqueue to smplayer playlist in dolphin, but you get the idea.

if i’m understanding this correctly (and i’m not at all sure that i am).

what you are saying is i can go into the KDE Menu Editor and add a new item like this

and it will create a new item at ~/.local/share/applications/test_app_menus.desktop which i can then add “Actions” to like this

[Desktop Entry]
Comment=
Exec=konsole
GenericName=app for menu testing
Icon=anjuta
Name=test_app_menus
NoDisplay=false
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=
###
# everything below this point was added via text editor to the .desktop
# created automatically by the KDE menu editor
###
Actions=installDeb;openKonsole
X-KDE-Priority=TopLevel
X-KDE-Submenu=SOME !! MENU !!

[Desktop Action installDeb]
Exec=qapt-deb-installer
Icon=install
Name=Install a Deb Package

[Desktop Action openKonsole]
Exec=konsole
Icon=org.gnome.Meld-symbolic
Name=Here is a console

which all makes a certain amount of sense to me, however when i launch my new custom app from the application menu it will only show up in the task bar for a few seconds before it disappears.

and if i use a different application, say cuttlefish, then when my custom application disappears from the task bar, the cuttlefish application appears… but it is not affected by these new “actions” at all.

how do i get MY custom application to be the one that stays in the taskmanager?

and then would my “actions” appear in the context menu when i right click on it?

If you want extra actions to an existing app, it’s easier to copy an existing app from /usr/share/applications to ~/.local/share/applications and edit it there instead of using the menu editor. That’s one of the reasons this one will only show a split second. It opens konsole. It will open konsole and “stick” with that one. Simply put, you’re telling it to open the default konsole app with the default actions. Same goes for cuttlefish. Furthermore, this ain’t a servicemenu. No X-KDE-Priority or Submenu.

Here’s an example of an app from scratch. Sure, it’s (mostly) system settings. But it opens a specific kcm setting on exec.

[Desktop Entry]
Actions=1Icons;2Plasma;3Windoz;Effects;Shortcuts;FileTypes;Mouse;SEPARATOR;DarkYellow;Light;DarkBleiuw;ConkyManager;
Comment=theming
Exec=systemsettings5 kcm_colors
GenericName=
Icon=/home/john/.icons/theming.png
MimeType=
Name=Theming
NoDisplay=false
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

[Desktop Action 1Icons]
Exec=systemsettings5 kcm_icons
Icon=blinken
Name=Icons

[Desktop Action 2Plasma]
Exec=systemsettings5 kcm_desktoptheme
Icon=blinken
Name=Plasma

[Desktop Action 3Windoz]
Exec=systemsettings5 kcm_kwindecoration
Icon=/usr/share/icons/breeze/applets/64/preferences-system-windows-effect-wobblywindows.svg
Name=Windoz

[Desktop Action DarkBleiuw]
Exec=plasma-apply-colorscheme SolusNewAppleFullyTrans && /usr/lib/x86_64-linux-gnu/libexec/plasma-changeicons testKora
Icon=folder-blue
Name=Den Bleiuwe (DarkBlue)

[Desktop Action DarkYellow]
Exec=plasma-apply-colorscheme SolusNewAppleFullyTrans && /usr/lib/x86_64-linux-gnu/libexec/plasma-changeicons kora-yellowTest
Icon=folder-black
Name=Den donkere (DarkYellow)

[Desktop Action Effects]
Exec=systemsettings5 kcm_kwin_effects
Icon=blinken
Name=Effects

[Desktop Action FileTypes]
Exec=systemsettings5 kcm_filetypes
Icon=preferences-desktop-filetype-association
Name=FileTypes

[Desktop Action Mouse]
Exec=systemsettings5 kcm_mouse
Icon=kmousetool
Name=Mouse

[Desktop Action Shortcuts]
Exec=systemsettings5 kcm_keys
Icon=yast-keyboard
Name=Shortcuts

[Desktop Action Light]
Exec=plasma-apply-colorscheme CakeUltra && /usr/lib/x86_64-linux-gnu/libexec/plasma-changeicons kora-yellowTest
Icon=/home/john/.icons/folder-white.svg
Name=Den Blieke (Light)

[Desktop Action ConkyManager]
Exec=conky-manager2
Icon=/home/john/.icons/conky.png
Name=ConkyManager

1 Like

Here’s what you’re doing. See that blue folder thing on the panel? That’s a custom desktop app for directories. The thing is set to open dolphin on left click. The actions are obviously on a rightclick.

Since it opens dolphin, dolphin will have a task. But that task will NOT have a rightclick like the custom one, but the default entries.

If you want extra entries in that dolphin task, you’ll have to add them to the dolphin application itself.

Like:

CLICK

ok, it’s making a lot more sense now.

i copied /usr/share/applications/org.kde.konsole.desktop to ~/.local/share/applications/org.kde.konsole.desktop

and changed the “Actions” key to
Actions=NewWindow;_SEPARATOR_;NewTab;_SEPARATOR_;

and now whenever i launch konsole (either from a service menu or from the applications menu) the context menu looks like this with the new SEPARATOR lines.

so now i know i can add my own custom actions in there to do whatever i want (except add a subfolder, apparently :frowning: ) , and i can just repeat this for any of the installed applications i want to modify.

i can even change their order by changing the order they are mentioned in the “Actions” key.

thanks for your patients and help, it is greatly appreciated.

Cool. It’s helpfull to look at shortcut commands in apps so that you can use (emulate) them
with tools like xdotool or kdotool as actions. It’s also helpfull to look at app --help to use custom commands as actions. Sometimes you also need to number actions to arrange them in the rightclick menu.
They’re sometimes misarranged.
For example:
[Desktop Action A] should be first to
[Desktop Action B]

But sometimes that not the case. Then you could do
[Desktop Action 1A]
[Desktop Action 2B]

Just small things. You got the main thing now.

yes, i see the ordering of how they appear in the context menu seems primarily alpha/numeric so choosing names for the Actions= in the alpha/numeric order of how you want them displayed seems to work more reliably.

back on regular dolphin service menus, there is another thing i’m seeing when using the X-KDE-Submenu to roll up a list of Actions=, the submenu will take on the Icon= value of the first Actions= value as defined in the [Desktop Action xxxx] section for that Action=.

placing an Icon= of its own under [Desktop Entry] section seems to have no effect.

am i missing something another key=value, or is this a bug?

how do i get the submenu to appear in the context menu without an icon, and all of the menu entries it contains to each have their own separate icons?

The icon, nothing you can do about it. Unless choosing the first one you want to see aka, edit the submenu as such.

1 Like

i have discovered that if you use that _SEPARATOR_ of yours as the first value assigned to the Actions= key, then it will suppress the bogus assignment of an icon to the submenu.

alternatively, the Icon= key found in the first of the Actions= values listed will always be the icon that gets assigned to the submenu (if you want it to have one).