Announcement

Collapse
No announcement yet.

My service menu doesn't work but the script it calls works in a terminal

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    My service menu doesn't work but the script it calls works in a terminal

    I have this script (courtesy of code from here):
    Code:
    #!/bin/sh
    for x
    do
    for i in 1 2 3 4 5
    do
    convert -brightness-contrast -${i}0x0 "$x" "${x%.png}-$i.png"
    done
    done
    And this (/home/vasa1/.local/share/kservices5/ServiceMenus/less-bright.desktop):
    Code:
    [Desktop Action less-bright]
    Exec=less-bright.sh %U
    Name=Reduce Brightness
    Icon=colorneg
    
    [Desktop Entry]
    Actions=less-bright
    MimeType=image/png;image/jpeg;
    ServiceTypes=KonqPopupMenu/Plugin
    Type=Service
    X-KDE-Priority=TopLevel
    If I run less-bright.sh from the terminal like this:
    less-bright.sh image.png
    As expected, I get 5 additional files, image-1.png through image-5.png of decreasing brightness.

    However, if I right-click image.png in Dolphin and choose "Reduce Brightness" from the context menu, all I get is just the one additional file, image-1.png. Why is that?
    Kubuntu 20.04

    #2
    (copy paste and it worked for me both ways, cp rather than convert)

    Clutching at straws... The environment that the script gets from dolphin may be different to that from a shell in the terminal. KDE doesn't run .profile or .bashrc and the like when starting these days. In particular, the $PATH might be different, causing a different version of the script to be run.

    (If you want stuff set up to affect .desktop files, you can put a script in ~/.config/plasma-workspace/env - note that the script will be run by dash, regardless of a shebang.)
    Regards, John Little

    Comment


      #3
      Thanks for looking into this!

      I don't know what you mean by
      (copy paste and it worked for me both ways, cp rather than convert)
      Re. the rest, I have two other service menus that use scripts. They work fine. It's not like the script is not working at all when called via the service menu. It just does the first instead of five cycles.

      I've put a copy of less-bright.sh in ~/.config/plasma-workspace/env and edited ~/.local/share/kservices5/ServiceMenus/less-bright.desktop accordingly. No improvement. I'll try a log out / log in and see.

      EDIT: nothing changed after logging out and logging in. Let's see what happens tomorrow when I restart my system.
      Last edited by chimak111; Jan 26, 2022, 04:43 AM.
      Kubuntu 20.04

      Comment


        #4
        Originally posted by chimak111 View Post
        Thanks for looking into this!
        I don't know what you mean by
        (copy paste and it worked for me both ways, cp rather than convert)
        I copied and pasted the scripts, and they both worked correctly.
        Regards, John Little

        Comment

        Working...
        X