Skip to content

Commit 3e921f4

Browse files
committed
service/polkit: use default path if not specified
1 parent ece3924 commit 3e921f4

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/services/polkit/qml.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,25 @@ void PolkitAgent::classBegin() {
112112
}
113113

114114
void PolkitAgent::componentComplete() {
115-
if (!mPath.isEmpty()) {
116-
qCDebug(logPolkit) << "registering listener on path" << mPath;
117-
if (qs_polkit_agent_register(listener)) {
118-
registeredAgentsByPath[mPath] = this;
119-
// If we were previously waiting to acquire this path, we no longer
120-
// are.
121-
if (auto it = waitingAgentsByPath.find(mPath);
122-
it != waitingAgentsByPath.end() && it->second == this)
123-
{
124-
waitingAgentsByPath.erase(it);
125-
}
126-
} else {
127-
qCWarning(logPolkit) << "failed to register listener on path" << mPath;
128-
// We may be able to register later if the current holder of the path
129-
// goes away.
130-
waitingAgentsByPath[mPath] = this;
115+
if (mPath.isEmpty()) {
116+
mPath = "/org/quickshell/Polkit";
117+
}
118+
119+
qCDebug(logPolkit) << "registering listener on path" << mPath;
120+
if (qs_polkit_agent_register(listener)) {
121+
registeredAgentsByPath[mPath] = this;
122+
// If we were previously waiting to acquire this path, we no longer
123+
// are.
124+
if (auto it = waitingAgentsByPath.find(mPath);
125+
it != waitingAgentsByPath.end() && it->second == this)
126+
{
127+
waitingAgentsByPath.erase(it);
131128
}
132129
} else {
133-
qCWarning(logPolkit) << "no path set, not registering listener.";
130+
qCWarning(logPolkit) << "failed to register listener on path" << mPath;
131+
// We may be able to register later if the current holder of the path
132+
// goes away.
133+
waitingAgentsByPath[mPath] = this;
134134
}
135135
}
136136

src/services/polkit/qml.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ class PolkitAgent
135135

136136
// clang-format off
137137
/// The D-Bus path that this agent listener will use.
138-
///
139-
/// > [!INFO] This value can be set to any valid path and has no impact on
140-
/// > the functionality of the listener.
141-
Q_PROPERTY(QString path READ path WRITE setPath REQUIRED);
138+
///
139+
/// If not set, a default of /org/quickshell/Polkit will be used.
140+
Q_PROPERTY(QString path READ path WRITE setPath);
142141

143142
/// Indicates an ongoing authentication request.
144143
///

0 commit comments

Comments
 (0)