Bug 367561 - "KDEInit could not launch..." error when calling programs through shell scripts
Summary: "KDEInit could not launch..." error when calling programs through shell scripts
Status: RESOLVED INTENTIONAL
Alias: None
Product: plasmashell
Classification: Plasma
Component: Application Launcher (Kickoff) (show other bugs)
Version: 5.5.5
Platform: openSUSE Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-19 11:31 UTC by Tristan Miller
Modified: 2016-08-28 12:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tristan Miller 2016-08-19 11:31:08 UTC
Many KDE applications produce annoying console output, so I wrap them in shell scripts and put them in some directory in my $PATH, as follows:

$ cat >~/bin/kwrite
#!/bin/bash
/usr/bin/kwrite "$@" >&/dev/null &

This way I can launch kwrite, kate, kontact, etc. from the command line without worrying about them spewing logging data in my terminal.  However, the scripts cause errors when I try to launch the corresponding programs from the Application Menu or when using Alt+F2, KDE throws up an error dialog before successfully launching the program.  For Alt+F2, the error dialog is as follows:

Sorry - krunner
KDEInit could not launch '/home/miller/bin/kwrite'

And for the Application Menu, the error dialog is as follows:

Sorry - Plasma
KDEInit could not launch '/home/miller/bin/kwrite'

I am using Plasma 5.5.5 now but the problem previously existed in Plasma 4 (see Bug 353454).

Reproducible: Always

Steps to Reproduce:
1. Create a shell script that launches (say) kwrite, and put the script in some directory on your PATH.
2. Press Alt+F2, type "kwrite", and press Enter.  (Or, launch KWrite from the Application menu.)


Actual Results:  
3. Error dialog appears which says, "KDEInit could not launch '/home/miller/bin/kwrite'"
4. KWrite is launched.

Expected Results:  
Step 3 above should not happen.
Comment 1 David Edmundson 2016-08-28 00:34:27 UTC
Then don't do that. You break kinit; it's a broken setup.

Use alias' or only set the PATH

Also you'll find launching
kinit5_wrapper kwrite

achieves the same thing and will be considerably faster; (it'll fork from a process with Qt and everything preloaded, rather than forking from bash)
Comment 2 Tristan Miller 2016-08-28 12:17:18 UTC
It is not possible to use an alias with output redirection, so I don't think that's an acceptable solution.

Regarding kdeinit5_wrapper (I assume "kinit5_wrapper" was a typo), thanks for the tip.  But it has the disadvantage of invoking the command using $HOME as the current working directory. This means it's not possible to pass relative-path arguments to commands like kwrite (unless you happen to launch it from your home directory).  That is, the following doesn't work:

$ cd /tmp
$ echo "Hello world" > foo.txt
$ kdeinit5_wrapper kwrite foo.txt

Is there any way of altering kdeinit5_wrapper's behaviour so that it doesn't change the working directory?  (If not, would it be acceptable to file a feature request for a command-line parameter implementing this?)