Bug 437880 - confusing error when adding a startup application that's not executable
Summary: confusing error when adding a startup application that's not executable
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_autostart (show other bugs)
Version: 5.21.5
Platform: Fedora RPMs Linux
: NOR minor
Target Milestone: ---
Assignee: Nicolas Fella
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-30 23:31 UTC by skierpage
Modified: 2021-06-06 11:57 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.83
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description skierpage 2021-05-30 23:31:41 UTC
SUMMARY
I created a script to run a program. When I went to + Add Application and browsed to it, I got an error alert "not found, please type a valid program name". Eventually I realized I had forgotten to make the script executable

STEPS TO REPRODUCE
1. Create a simple script, e.g. 
        #!/bin/sh
        echo "STDOUT from $0 : hello"

2. Save the file as /tmp/start_test.sh but don't make it executable.
3. Run System Settings > Startup and Shutdown > Autostart
4. Choose + Add... > + Add Application..., browse to the script, click [OK]

OBSERVED RESULT
You get an error alert
    '/tmp/start_test.sh' not found, please type a valid program name.
The workaround, obvious to more expert users, is `chmod a+x /path/to/script.sh`.

EXPECTED RESULT
The script was obviously found, but it's not valid because it's not executable.
The alert text (from https://invent.kde.org/frameworks/kio/-/blob/master/src/widgets/kopenwithdialog.cpp#L1009 ) should be something like
    "'%1' not found or is not executable , please type a valid program name."
or
    "'%1' is not an executable file, please type a valid program name."

Other things that would help, also in frameworks/kio which presents this KOpenWithDialog:
* the file browser could gray out non-executable programs so you see them but can't choose them
* the file browser could show permissions in a column


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.21.5
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2 64-bit, Wayland

ADDITIONAL INFORMATION
Maybe the bug is in kio not this KCM, but I'm not sure where else kio's KOpenWithDialog() is used.
Comment 1 Nicolas Fella 2021-05-31 13:33:25 UTC
Adding a  script via "Add application" is an interesting corner case that I had not considered.

I can adapt https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/878 to cover this as well
Comment 2 Nicolas Fella 2021-05-31 13:40:06 UTC
(In reply to Nicolas Fella from comment #1)
> Adding a  script via "Add application" is an interesting corner case that I
> had not considered.
> 
> I can adapt
> https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/878 to cover
> this as well

hmm no, it's not that easy unfortunately
Comment 3 Bug Janitor Service 2021-05-31 13:53:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/466
Comment 4 Nicolas Fella 2021-05-31 13:55:41 UTC
https://invent.kde.org/frameworks/kio/-/merge_requests/466 improves the error message in that case. I'm not sure a more invasive solution is justified given that for the user case of adding a script the "Add login script" option (which will get a proper executable check in https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/878) is preferred over the "Add application" option.
Comment 5 Nicolas Fella 2021-05-31 15:07:25 UTC
Git commit d57bb4cbd964ecdfc5a2b3c1f36469aeac8e960b by Nicolas Fella.
Committed on 31/05/2021 at 13:53.
Pushed by ahmadsamir into branch 'master'.

[kopenwithdialog] Show better error message when specifying a non-executable file

If the user uses the file picker to specify a file instead of an
application the file has to be executable.

If it isn't "$file not found, please type a valid program name" is
shown, which is confusing. Instead show that the file is not executable
so the user knows what's going on.

M  +9    -1    src/widgets/kopenwithdialog.cpp

https://invent.kde.org/frameworks/kio/commit/d57bb4cbd964ecdfc5a2b3c1f36469aeac8e960b
Comment 6 skierpage 2021-06-04 22:51:23 UTC
(In reply to Nicolas Fella from comment #4)
> ... for the user case of adding a script the "Add login
> script" option (which will get a proper executable check in
> https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/878) is
> preferred over the "Add application" option.

My years-old script launches Konsole with `konsole --tabs-from-file ~/dotfiles/session.konsole`. At some point in the upgrade to Fedora 34 on Wayland or afterwards, Konsole no longer appeared at startup (journalctl had errors "unknown: This compositor does not support the Plasma Window Management interface" as if the script was running too soon, or under sddm or something). So I assumed you _can't_ start applications from a login script any more, so I moved it to Autostart > + Add Application. Should I file a bug that Autostart > Login scripts can't launch programs in Fedora 34 Wayland?

Thanks for working on this!
Comment 7 Nate Graham 2021-06-05 13:17:27 UTC
Git commit 776f5c593ef8b1df40fae0961001e3e49c58aab4 by Nate Graham.
Committed on 05/06/2021 at 13:17.
Pushed by ngraham into branch 'master'.

[kopenwithdialog] Improve executable-related error messages

Use KUIT formatting and polish the error messages to be more
descriptive and more grammatically correct in English.

M  +2    -2    src/widgets/kopenwithdialog.cpp

https://invent.kde.org/frameworks/kio/commit/776f5c593ef8b1df40fae0961001e3e49c58aab4
Comment 8 Nicolas Fella 2021-06-06 11:57:03 UTC
(In reply to skierpage from comment #6)
> My years-old script launches Konsole with `konsole --tabs-from-file
> ~/dotfiles/session.konsole`. At some point in the upgrade to Fedora 34 on
> Wayland or afterwards, Konsole no longer appeared at startup (journalctl had
> errors "unknown: This compositor does not support the Plasma Window
> Management interface" as if the script was running too soon, or under sddm
> or something). So I assumed you _can't_ start applications from a login
> script any more, so I moved it to Autostart > + Add Application. Should I
> file a bug that Autostart > Login scripts can't launch programs in Fedora 34
> Wayland?
> 
> Thanks for working on this!

Login scripts don't work at all on current Fedora 34. That will be fixed in Plasma 5.22, to be released next week