Skip to content

Instantly share code, notes, and snippets.

@CosmicToast
Last active March 4, 2020 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CosmicToast/a895fa347300e8acee7f8f024723e7aa to your computer and use it in GitHub Desktop.
Save CosmicToast/a895fa347300e8acee7f8f024723e7aa to your computer and use it in GitHub Desktop.
Useful plasma5 service menus

Some useful ServiceMenus for plasma5

A small collection, because reasons.

Installation

To apply these, place the .desktop file you're interested in in ~/.local/share/kservices5/ServiceMenus/, then run kbuildsycoca5 (failures are ok). For each of them, the binary in question (specified under TryExec=) must be in the systemwide $PATH. You can expand it in the plasma5 env files, or via PAM. Or just, you know, symlink it into /usr/local/bin.

Optionally, you can download/place a compliant icon into ~/.local/share/icons/. E.g when Icon=asciidoctor is specified, you can place an asciidoctor.png in that directory.

Notes

These are some useful notes for people that want to write their own.

  • this is the list of supported X-KDE extension keys I could find, see KIO/src/widgets/kfileitemactions.cpp
    • X-KDE-Priority (pin to top, per .desktop file)
    • X-KDE-Submenu (place everything in a submenu, per .desktop file, multiple files can share the same submenu)
    • X-KDE-ShowIfRunning (does something weird with dbus, idk)
    • X-KDE-ShowIfDBusCall (I REALLY don't know)
    • X-KDE-Protocol and X-KDE-Protocols (no clue)
    • X-KDE-Require (all this seems to do is if you have "Write" in there, it makes sure you can write to the file?)
    • X-KDE-RequiredNumberOfUrls (if you set it to 2, you need to have 2 files selected for it to show up in the menu, etc)
    • X-KDE-GetActionMenu | Actions | ServiceTypes | MimeType - these are all kinda bundled together
    • X-KDE-ServiceTypes basically a combination of ServiceTypes and MimeType, but with , separators
  • TryExec does work, but it's on a per-file basis. I looked at it, and to enable it on a per-action basis you'd basically need to patch two components (KService, to extend KServiceAction to have a tryexec() func, and then plug that in / add-in a isValid() to it too. Then you'd need to make KIO use that in KDesktopFileActions::userDefinedServices() to skip over the invalid ones.

License

Consider all of these licensed under the unlicense.

[Desktop Entry]
Actions=CreateAsciidoctorPDF;
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=text/plain;
X-KDE-Submenu=Asciidoctor
TryExec=asciidoctor-pdf
[Desktop Action CreateAsciidoctorPDF]
Name=Create PDF file with asciidoctor-pdf
Exec=asciidoctor-pdf %F
Icon=asciidoctor
[Desktop Entry]
Actions=CreateAsciidoctorHTML;
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=text/plain;
X-KDE-Submenu=Asciidoctor
TryExec=asciidoctor
[Desktop Action CreateAsciidoctorHTML]
Name=Create HTML file with asciidoctor
Exec=asciidoctor %F
Icon=asciidoctor
[Desktop Entry]
Actions=ThunderbirdAttachment;ThunderbirdMessage;
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=text/plain;
X-KDE-Submenu=Thunderbird
TryExec=thunderbird
X-KDE-RequiredNumberOfUrls=1
[Desktop Action ThunderbirdAttachment]
Name=Send file as an attachment in Thunderbird
Exec=thunderbird -compose "attachment=%f"
Icon=thunderbird
[Desktop Action ThunderbirdMessage]
Name=Send file as the message in Thunderbird
Exec=thunderbird -compose "message=%f"
Icon=thunderbird
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment