@@ -52,16 +52,18 @@ static const char* permissionToString(eDynamicPermissionType type) {
52
52
case PERMISSION_TYPE_UNKNOWN: return " PERMISSION_TYPE_UNKNOWN" ;
53
53
case PERMISSION_TYPE_SCREENCOPY: return " PERMISSION_TYPE_SCREENCOPY" ;
54
54
case PERMISSION_TYPE_PLUGIN: return " PERMISSION_TYPE_PLUGIN" ;
55
+ case PERMISSION_TYPE_KEYBOARD: return " PERMISSION_TYPE_KEYBOARD" ;
55
56
}
56
57
57
58
return " error" ;
58
59
}
59
60
60
61
static const char * permissionToHumanString (eDynamicPermissionType type) {
61
62
switch (type) {
62
- case PERMISSION_TYPE_UNKNOWN: return " requesting an unknown permission" ;
63
- case PERMISSION_TYPE_SCREENCOPY: return " trying to capture your screen" ;
64
- case PERMISSION_TYPE_PLUGIN: return " trying to load a plugin" ;
63
+ case PERMISSION_TYPE_UNKNOWN: return " An application <b>{}</b> is requesting an unknown permission." ;
64
+ case PERMISSION_TYPE_SCREENCOPY: return " An application <b>{}</b> is trying to capture your screen.<br/><br/>Do you want to allow it to do so?" ;
65
+ case PERMISSION_TYPE_PLUGIN: return " An application <b>{}</b> is trying to load a plugin: <b>{}</b>.<br/><br/>Do you want to load it?" ;
66
+ case PERMISSION_TYPE_KEYBOARD: return " A new keyboard has been plugged in: {}.<br/><br/>Do you want to allow it to operate?" ;
65
67
}
66
68
67
69
return " error" ;
@@ -184,7 +186,7 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionMode(wl_c
184
186
return PERMISSION_RULE_ALLOW_MODE_PENDING;
185
187
}
186
188
187
- // if we are here, we need to ask.
189
+ // if we are here, we need to ask, that's the fallback for all these (keyboards wont come here)
188
190
askForPermission (client, LOOKUP.value_or (" " ), permission);
189
191
190
192
return PERMISSION_RULE_ALLOW_MODE_PENDING;
@@ -232,6 +234,10 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionModeWithS
232
234
} else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_PENDING) {
233
235
Debug::log (TRACE, " CDynamicPermissionManager::clientHasPermission: permission pending by config rule" );
234
236
return PERMISSION_RULE_ALLOW_MODE_PENDING;
237
+ } else if ((*it)->m_allowMode == PERMISSION_RULE_ALLOW_MODE_ASK) {
238
+ Debug::log (TRACE, " CDynamicPermissionManager::clientHasPermission: permission ask by config rule" );
239
+ askForPermission (nullptr , str, permission, pid);
240
+ return PERMISSION_RULE_ALLOW_MODE_PENDING;
235
241
} else
236
242
Debug::log (TRACE, " CDynamicPermissionManager::clientHasPermission: permission ask by config rule" );
237
243
}
@@ -247,6 +253,10 @@ eDynamicPermissionAllowMode CDynamicPermissionManager::clientPermissionModeWithS
247
253
return PERMISSION_RULE_ALLOW_MODE_PENDING;
248
254
}
249
255
256
+ // keyboards are allow default
257
+ if (permission == PERMISSION_TYPE_KEYBOARD)
258
+ return PERMISSION_RULE_ALLOW_MODE_ALLOW;
259
+
250
260
// if we are here, we need to ask.
251
261
askForPermission (nullptr , str, permission, pid);
252
262
@@ -263,22 +273,20 @@ void CDynamicPermissionManager::askForPermission(wl_client* client, const std::s
263
273
264
274
std::string description = " " ;
265
275
if (binaryPath.empty ())
266
- description = std::format (" An unknown application (wayland client ID 0x{:x}) is {}. " , (uintptr_t )client, permissionToHumanString (type ));
276
+ description = std::format (std::runtime_format ( permissionToHumanString (type)), std::format ( " unknown application (wayland client ID 0x{:x})" , (uintptr_t )client));
267
277
else if (client) {
268
278
std::string binaryName = binaryPath.contains (" /" ) ? binaryPath.substr (binaryPath.find_last_of (' /' ) + 1 ) : binaryPath;
269
- description = std::format (" An application <b> {}</b> ({}) is {}. " , binaryName, binaryPath, permissionToHumanString (type ));
279
+ description = std::format (std::runtime_format ( permissionToHumanString (type)), std::format ( " {}</b> ({})" , binaryName, binaryPath));
270
280
} else if (pid >= 0 ) {
271
281
if (type == PERMISSION_TYPE_PLUGIN) {
272
282
const auto LOOKUP = binaryNameForPid (pid);
273
- description = std::format (" An application <b>{}</b> is {}:<br/><b>{}</b> " , LOOKUP.value_or (" Unknown" ), permissionToHumanString (type ), binaryPath);
283
+ description = std::format (std::runtime_format ( permissionToHumanString (type)) , LOOKUP.value_or (" Unknown" ), binaryPath);
274
284
} else {
275
285
const auto LOOKUP = binaryNameForPid (pid);
276
- description = std::format (" An application <b>{}</b> ({}) is {}. " , LOOKUP.value_or (" Unknown" ), binaryPath, permissionToHumanString (type) );
286
+ description = std::format (std::runtime_format ( permissionToHumanString (type)) , LOOKUP.value_or (" Unknown" ), binaryPath);
277
287
}
278
288
} else
279
- description = std::format (" An application is {}:<br/><b>{}</b>" , permissionToHumanString (type), binaryPath);
280
-
281
- description += " <br/><br/>Do you want to allow this?" ;
289
+ description = std::format (std::runtime_format (permissionToHumanString (type)), binaryPath);
282
290
283
291
std::vector<std::string> options;
284
292
0 commit comments