@@ -28,8 +28,19 @@ class DesktopEntry: public QObject {
2828 Q_PROPERTY (QString comment MEMBER mComment CONSTANT);
2929 // / Name of the icon associated with this application. May be empty.
3030 Q_PROPERTY (QString icon MEMBER mIcon CONSTANT);
31- // / The raw `Exec` string from the desktop entry. You probably want @@execute().
31+ // / The raw `Exec` string from the desktop entry.
32+ // /
33+ // / > [!WARNING] This cannot be reliably run as a command. See @@command for one you can run.
3234 Q_PROPERTY (QString execString MEMBER mExecString CONSTANT);
35+ // / The parsed `Exec` command in the desktop entry.
36+ // /
37+ // / The entry can be run with @@execute(), or by using this command in
38+ // / @@Quickshell.Quickshell.execDetached() or @@Quickshell.Io.Process.
39+ // / If used in `execDetached` or a `Process`, @@workingDirectory should also be passed to
40+ // / the invoked process. See @@execute() for details.
41+ // /
42+ // / > [!NOTE] The provided command does not invoke a terminal even if @@runInTerminal is true.
43+ Q_PROPERTY (QVector<QString> command MEMBER mCommand CONSTANT);
3344 // / The working directory to execute from.
3445 Q_PROPERTY (QString workingDirectory MEMBER mWorkingDirectory CONSTANT);
3546 // / If the application should run in a terminal.
@@ -46,6 +57,16 @@ class DesktopEntry: public QObject {
4657 void parseEntry (const QString& text);
4758
4859 // / Run the application. Currently ignores @@runInTerminal and field codes.
60+ // /
61+ // / This is equivalent to calling @@Quickshell.Quickshell.execDetached() with @@command
62+ // / and @@DesktopEntry.workingDirectory as shown below:
63+ // /
64+ // / ```qml
65+ // / Quickshell.execDetached({
66+ // / command: desktopEntry.command,
67+ // / workingDirectory: desktopEntry.workingDirectory,
68+ // / });
69+ // / ```
4970 Q_INVOKABLE void execute () const ;
5071
5172 [[nodiscard]] bool isValid () const ;
@@ -54,7 +75,7 @@ class DesktopEntry: public QObject {
5475
5576 // currently ignores all field codes.
5677 static QVector<QString> parseExecString (const QString& execString);
57- static void doExec (const QString& execString, const QString& workingDirectory);
78+ static void doExec (const QList< QString> & execString, const QString& workingDirectory);
5879
5980public:
6081 QString mId ;
@@ -64,6 +85,7 @@ class DesktopEntry: public QObject {
6485 QString mComment ;
6586 QString mIcon ;
6687 QString mExecString ;
88+ QVector<QString> mCommand ;
6789 QString mWorkingDirectory ;
6890 bool mTerminal = false ;
6991 QVector<QString> mCategories ;
@@ -82,8 +104,19 @@ class DesktopAction: public QObject {
82104 Q_PROPERTY (QString id MEMBER mId CONSTANT);
83105 Q_PROPERTY (QString name MEMBER mName CONSTANT);
84106 Q_PROPERTY (QString icon MEMBER mIcon CONSTANT);
85- // / The raw `Exec` string from the desktop entry. You probably want @@execute().
107+ // / The raw `Exec` string from the action.
108+ // /
109+ // / > [!WARNING] This cannot be reliably run as a command. See @@command for one you can run.
86110 Q_PROPERTY (QString execString MEMBER mExecString CONSTANT);
111+ // / The parsed `Exec` command in the action.
112+ // /
113+ // / The entry can be run with @@execute(), or by using this command in
114+ // / @@Quickshell.Quickshell.execDetached() or @@Quickshell.Io.Process.
115+ // / If used in `execDetached` or a `Process`, @@DesktopEntry.workingDirectory should also be passed to
116+ // / the invoked process.
117+ // /
118+ // / > [!NOTE] The provided command does not invoke a terminal even if @@runInTerminal is true.
119+ Q_PROPERTY (QVector<QString> command MEMBER mCommand CONSTANT);
87120 QML_ELEMENT;
88121 QML_UNCREATABLE (" DesktopAction instances must be retrieved from a DesktopEntry" );
89122
@@ -94,6 +127,9 @@ class DesktopAction: public QObject {
94127 , mId(std::move(id)) {}
95128
96129 // / Run the application. Currently ignores @@DesktopEntry.runInTerminal and field codes.
130+ // /
131+ // / This is equivalent to calling @@Quickshell.Quickshell.execDetached() with @@command
132+ // / and @@DesktopEntry.workingDirectory.
97133 Q_INVOKABLE void execute () const ;
98134
99135private:
@@ -102,6 +138,7 @@ class DesktopAction: public QObject {
102138 QString mName ;
103139 QString mIcon ;
104140 QString mExecString ;
141+ QVector<QString> mCommand ;
105142 QHash<QString, QString> mEntries ;
106143
107144 friend class DesktopEntry ;
0 commit comments