Announcement

Collapse
No announcement yet.

Run executable script on double-click

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

    Run executable script on double-click

    Hi, just trying to find my feet in a KDE environment. I'm used to gnome, and have a bunch of scripts that I normally execute by double-clicking the icon (.sh), then choosing "run in terminal". I'm now trying to use my scripts in KDE.

    How do I execute the shell script so that I can see it run in a terminal. And don't say execute it from the terminal :P

    PS I miss the options you get from double-clicking a shell script icon in gnome (run, run in terminal, open in text editor), I know I can do right-click, open with, kate but I miss that little dialogue box.

    #2
    Re: Run executable script on double-click

    An ad-hack, er, ad-hoc workaround of sorts:

    To the folder /usr/share/apps/konqueror/servicemenus, add a file similar to the following (acting as "super user"):

    Code:
    # run-script.desktop
    
    [Desktop Entry]
    ServiceTypes=application/x-shellscript
    Actions=scriptRun
    
    [Desktop Action scriptRun]
    Exec=konsole -e "%f"
    Name=Execute Script
    Icon=konsole
    As a result, in the (Konqueror) context menu of a shell script, "Action - Execute Script" will show up ... go figure 8)

    Comment


      #3
      Re: Run executable script on double-click

      That's excellent. Much appreciated!

      Still miss that menu. In nautilus if I execute a script in the terminal it keeps running in terminal until I close it. In konqueror it was often quitting as I navigated away to another folder (accidentally)! Your little ad-hoc-hack is great as I can keep an eye on the process. Thanks again.

      edit: learned more about the command line options and changed it to
      Code:
      # run-script.desktop
      
      [Desktop Entry]
      ServiceTypes=application/x-shellscript
      Actions=scriptRun
      
      [Desktop Action scriptRun]
      Exec=konsole --noclose -e "%f"
      Name=Execute Script
      Icon=konsole
      --noclose means the terminal remains open and I can review the output

      Comment


        #4
        Re: Run executable script on double-click

        Originally posted by r76
        --noclose
        Good point

        In parallel to you, I've added "root vs. user" selection as well as "/bin/bash" (the latter for clarification) ...:

        Code:
        [Desktop Entry]
        ServiceTypes=application/x-shellscript
        Actions=UserMode;RootMode
        X-KDE-Submenu=Bash Script
        
        [Desktop Action UserMode]
        Exec=konsole --noclose -e "/bin/bash %f"
        Name=User Mode
        Icon=xeyes
        
        [Desktop Action RootMode]
        Exec=kdesu konsole --noclose -e "/bin/bash %f"
        Name=Root Mode
        Icon=gv

        Comment


          #5
          Re: Run executable script on double-click

          Damn you are good at this! Thanks again

          Comment

          Working...
          X