Bug 459843

Summary: Display output of command in a notification
Product: [Plasma] krunner Reporter: Michael D <nortexoid>
Component: generalAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: wishlist CC: alexander.lohnau, natalie_clarius, nate
Priority: NOR    
Version First Reported In: 5.25.5   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Michael D 2022-09-30 08:15:17 UTC
It would be nice if krunner's could output the result of a command, such as "free -h", as a notification. At the moment it runs the command but output is shown. I'm not sure whether this is even possible.
Comment 1 Natalie Clarius 2022-10-26 14:28:52 UTC
For the shell command plugin you mean? This is already possible by hitting Shift+Enter, or the terminal button in the result.
Comment 2 Natalie Clarius 2022-10-26 14:29:21 UTC
This will not trigger a notification but open a terminal window.
Comment 3 Alexander Lohnau 2022-10-30 16:53:18 UTC
@MichaelD Does the "Run in Terminal Window" solution that Natalie mentioned work for you?

TBH, I think implementing it as a notification would not work well. Especially if you think of long-running processes.
Comment 4 Michael D 2022-10-30 18:34:48 UTC
Sorry for the delay. I think a notification would work better in certain situations where you don't need a terminal window spawning, just a transient notification giving the output. I think this would be fine even for long-running processes as it would just output the first n characters of output as a notification.
Comment 5 Alexander Lohnau 2022-11-01 06:45:38 UTC
>I think this would be fine even for long-running processes as it would just output the first n characters of output as a notification.

Though where would you draw the line on when to output the notification? Limits like 100 or 200 characters seem arbitrary. And how would we handle the use case where the command outputs some info, runs for a while and then outputs other information.

Having a notification each few seconds might be annoying too :D.
Comment 6 Michael D 2022-11-01 13:07:06 UTC
Set the character limit to be roughly the limit of the notification osd. Also, show the notification only once, e.g. after the first line of output. Seems reasonable, but I see there are choices to be made.
Comment 7 Nate Graham 2022-11-04 19:29:23 UTC
To me it definitely makes sense to send a notification with command output for commands that write to STDOUT and then exit. Once the process exits, we can gather up the output and stick it right in a notification.

If the command keeps running, I think it could still make sense if we have the ability to keep the notification with command output visible on screen and update its text in real time as the process writes more text. If we don't have the technical ability to do that, or it's not feasible, IMO it's sane enough to preserve the status quo and let the process just keep running silently, as this is a very niche use case and I think it's safe to assume that a user who does this knows what they're doing!
Comment 8 Michael D 2022-11-04 19:46:01 UTC
Sounds like a great idea, and think it would make for a very nice new feature for the command plugin that many would find useful and welcome.