• Create KDE Service Menu to Run Python App


    Finally, I found an alternative for grepwin - Rummage - and installed it. Now, I would like to create service (right-click) menu to start Rummage in selected directory. So after studying https://techbase.kde.org/Development/Tutorials/Creating_Konqueror_Service_Menus I created service menu:

    [Desktop Entry]
    Type=Service
    ServiceTypes=KonqPopupMenu/Plugin
    MimeType=inode/directory
    Actions=openRummage
    
    [Desktop Action openRummage]
    Name=Open Rummage
    Icon=edit-find-replace-symbolic
    Exec=python -m rummage
    

    The menu is then visible in Dolphin, but once I click it, nothing happens. Well, I actually see “Open Rummage” entry in task manager for a second, and then it auto-closes. Running the same command python -m rummage via konsole works fine.

    What do I miss here?

    By the way, Rummage user guide at https://facelessuser.github.io/Rummage/usage/ says I should be able to execute app using command rummage OR python -m rummage, but for some reason only python -m rummage works for me. Typing rummage returns error bash: rummage: command not found

    Maybe that’s related somehow?

  • P.S. I’m sure my service menu is OK, because if I replace python -m rummage with geany (or whatever app), it opens specified app without any problems.

  • I think the reason rummage doesn’t work but python -m rummage does it because different namespaces are being searched for the executable.
    When you type rummage all directories in the PATH environment variable are searched for an file marked executable and with name rummage.
    python -m searches the Python module namespace, which IIRC is the environment variable PYTHONPATH.

    As an experiment try changing Exec remove the -m rummage and enter the full path to the rummage.py
    If that works it means the somehow the PYTHONPATH setting when running from within the menu context isn’t quite right.
    At the moment I have no idea how to fix that.

  • Thanks for your help. Actually, I can’t find rummage.py in my system, but I can launch program by typing /home/MY_USERNAME/.local/bin/rummage into terminal.

    Sadly enough, Exec=/home/MY_USERNAME/.local/bin/rummage in service menu doesn’t work.

  • Got it solved by rebuilding KDE cache via kbuildsycoca5 command. As soon as rebuild was completed, service menu started working.

    While KDE documentation claims this command is not usually needed because OS rebuilds cache automatically when some change is detected, only a manual rebuild worked on my system for some reason.

  • Thanks for describing how you solved the issue.
    Just to satisfy my curiosity, how did you install rummage? pip, sudo pip, or some other way?
    The fact that rummage is in /home/MY_USERNAME/.local/bin/ leads me to conclude that it was a user only install, and this might be why things didn’t quite work out of the box.

  • I installed Rummage using pip. So yes, maybe that was the reason why rebuild was needed.

  • @toxpal Thank you for the useful information!

kde184 menu42 service15 python14 Posts 8Views 364
Bloom Email Optin Plugin

Looks like your connection to Antergos Community Forum was lost, please wait while we try to reconnect.