Bug 459865 - The Enter key is not always respected by Krunner.
Summary: The Enter key is not always respected by Krunner.
Status: CLOSED INTENTIONAL
Alias: None
Product: krunner
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 5.24.6
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-30 15:30 UTC by Little Girl
Modified: 2022-10-18 16:31 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Little Girl 2022-09-30 15:30:38 UTC
SUMMARY
The "Issue (shell) commands" section of the https://userbase.kde.org/Plasma/Krunner#Issue_.28shell.29_commands page in the KDE UserBase Wiki says that we can run shell commands from Krunner. I've tested it and have found that pressing the Enter key doesn't always cause the shell command to run.

As an example, I can type this command and press the Enter key and Kate will open:

kate

I can also kill that Kate window by typing this command and pressing the Enter key:

pkill kate

But if I type this command and press the Enter key, nothing happens:

which kate

Nothing happens if I type one of the wiki's example commands to list the contents of the Documents directory and press the enter key:

ls ~/Documents

I'm seeing the behavior when the shell command should produce output in a terminal window, but I haven't tested it thoroughly enough to determine whether this is directly connected only to Konsole or if the same thing would happen with other programs that are expected to produce output.

STEPS TO REPRODUCE
1. Open Krunner.
2. Type a shell command that is expected to produce output, like: which kate
3. Press the Enter key.
4. When nothing happens, open Krunner again.
5. Type a shell command that is expected to produce output, like: which kate
6. Click the Konsole icon in the Krunner search result.

OBSERVED RESULT
Step 3 result: Nothing happens.
Step 6 result: Konsole opens with output to the shell command.

EXPECTED RESULT
Konsole should open with output regardless of whether the Enter key is pressed or the Konsole icon is clicked.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.24.6
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION
This is in an up-to-date copy of Kubuntu 22.04 LTS.

As a work-around, if, instead of pressing the Enter key, I click the Konsole icon in the Krunner search result after typing a shell command, then a terminal window opens with the expected output.
Comment 1 Little Girl 2022-10-02 01:59:21 UTC
That summary wasn't quite clear. I've rewritten it, but can't figure out how to edit the existing one, so I'll post it in the next comment.
Comment 2 Little Girl 2022-10-02 02:00:55 UTC
UPDATED:

SUMMARY
The "Issue (shell) commands" section of the https://userbase.kde.org/Plasma/Krunner#Issue_.28shell.29_commands page in the KDE UserBase Wiki says that we can run shell commands from Krunner. I've tested it in an up-to-date copy of Kubuntu 22.04 LTS and have found that pressing the Enter key after putting a shell command into Krunner doesn't always cause the shell command to run. The failure can be consistently repeated by attempting to run shell commands that are expected to produce output and comparing that with the consistent success achieved by running shell commands that are not expected to produce output.

STEPS TO REPRODUCE
01. Press alt+F2 to open Krunner.
02. Type this shell command that's not expected to produce output: kate
03. Press the Enter key.
04. Observe the expected result (and don't close Kate).
05. Type this shell command that's expected to produce output: which kate
06. Press the Enter key.
07. Observe the unexpected result.
08. Press alt+F2 to open Krunner again.
09. Type this shell command that's expected to produce output: which kate
10. Click the Konsole icon in Krunner's "Run which kate" search result.
11. Observe the expected result.
12. Press alt+F2 to open Krunner again.
13. Type this shell command that's not expected to produce output: pkill kate
14. Press the Enter key.
15. Observe the expected result.

OBSERVED RESULT
Step 04 result: Success: Krunner closes and Kate opens (successful press of the Enter key).
Step 07 result: Failure: Krunner closes (unsuccessful press of the Enter key).
Step 11 result: Success: Krunner closes and Konsole opens with output (successful click of the Konsole icon).
Step 15 result: Success: Krunner closes and Kate closes (successful press of the Enter key).

EXPECTED RESULT
In step 07, Konsole should open with output when the Enter key is pressed.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:
KDE Plasma Version: 5.24.6
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION
As a result of testing this issue, I found the additional Krunner issues below that may be related. I'm not sure if they belong here or in two separate additional bug reports, so I'm leaving them here for now.
	* If you type which kate into Krunner and click the "Run which Kate" entry in its search results, Krunner closes and nothing else happens.
	* If you use the Krunner textbox in the K menu instead of opening Krunner with alt+F2, there's no way to run the which kate shell command because there's no Konsole button in the search result and neither pressing the Enter key nor clicking on the "Run which kate" search result do anything.
Comment 3 Nate Graham 2022-10-09 23:10:08 UTC
The default action for the enter key silently drops output; to see output, you use Shift+Enter, or click on the little terminal window icon on the right of the list item for the command.

I can't think of a way we could detect whether a command is going to produce output automatically without running the command and looking for STDOUT, and at that point it's too late. I think we'll have to use the tools we already have here, unless you think of something super clever. Did you have something in mind?
Comment 4 Little Girl 2022-10-18 02:53:38 UTC
Thank you for looking into this issue and considering it. Maybe this will help:

The https://userbase.kde.org/Plasma/Krunner#Issue_.28shell.29_commands page doesn't mention any exclusive or forbidden behaviors (like not being allowed to press the Enter key when output is expected or having to find and click on an icon in the search instead of clicking on the search result itself), so it's understandable that I'd assume I could use the Enter key, especially since it works some of the time.

There are additional inconsistent behaviors depending on whether you invoke Krunner with alt+F2, use it inside the K menu, or use it via the Search widget on the panel. Below is a simple, detailed summary that anyone can pretty quickly follow for testing and that makes the inconsistencies in behavior obvious at a glance:

====================
Using Krunner from alt+F2:

Success: Open Krunner with alt+F2, type kate, press Enter.
Success: Open Krunner with alt+F2, type kate, click its search result.
Success: Open Krunner with alt_F2, type kate, click the
Konsole icon.

Failure: Open Krunner with alt+F2, type which kate, press Enter.
Failure: Open Krunner with alt+F2, type which kate, click its search
result.
Success: Open Krunner with alt+F2, type which kate, click the Konsole
icon.
====================
Using Krunner in the K menu:

Success: Open K menu, type kate, press Enter.
Success: Open K menu, type kate, click its search result.
Failure: Open K menu, type kate, try to find a Konsole icon to click.

Failure: Open K menu, type which kate, press Enter.
Failure: Open K menu, type which kate, click its search result.
Failure: Open K menu, type which kate, try to find a Konsole icon to
click.
====================
Using Krunner from the Search widget on the panel:

Success: Click Search icon in panel, type kate, press Enter.
Success: Click Search icon in panel, type kate, click its search
result.
Success: Click Search icon in panel, type kate, click the Konsole
icon.

Failure: Click Search icon in panel, type which kate, press Enter.
Failure: Click Search icon in panel, type which kate, click its
search result.
Success: Click Search icon in panel, type which kate, click the
Konsole icon.
====================
Comment 5 Nate Graham 2022-10-18 16:30:54 UTC
In all of those cases, the pattern is what I already mentioned: when you run a command that you're expecting to produce terminal output, you need to explicitly invoke the "Run in terminal window" action -- either by clicking on the little Konsole icon in the list item, or by hitting Shift-Enter. The default action simply runs the command and discards output.

If https://userbase.kde.org/Plasma/Krunner#Issue_.28shell.29_commands is outdated, someone should update it. Maybe you? :) It is a wiki, after app.