diff --git a/quickshell/Modules/Settings/CreateUserTab.qml b/quickshell/Modules/Settings/CreateUserTab.qml index 80ce46e80..a7d5a7bca 100644 --- a/quickshell/Modules/Settings/CreateUserTab.qml +++ b/quickshell/Modules/Settings/CreateUserTab.qml @@ -18,6 +18,8 @@ Item { property bool pendingAdmin: false property bool pendingGreeter: false + Component.onCompleted: UsersService.refresh() + function _resetForm() { pendingUsername = ""; pendingPassword = ""; diff --git a/quickshell/Modules/Settings/UsersTab.qml b/quickshell/Modules/Settings/UsersTab.qml index d062616e2..0fd8867a8 100644 --- a/quickshell/Modules/Settings/UsersTab.qml +++ b/quickshell/Modules/Settings/UsersTab.qml @@ -15,6 +15,9 @@ Item { property string statusText: "" property bool statusIsError: false property bool operationPending: false + + Component.onCompleted: UsersService.refresh() + Connections { target: UsersService function onOperationCompleted(op, username, success, message) { diff --git a/quickshell/Services/SettingsSearchService.qml b/quickshell/Services/SettingsSearchService.qml index c8929aacd..80653f1fc 100644 --- a/quickshell/Services/SettingsSearchService.qml +++ b/quickshell/Services/SettingsSearchService.qml @@ -49,6 +49,18 @@ Singleton { } } + Connections { + target: UsersService + + function onAdminGroupChanged() { + root._refreshTranslatedCache(); + } + + function onGreeterGroupChanged() { + root._refreshTranslatedCache(); + } + } + Connections { target: SettingsTabs @@ -362,7 +374,21 @@ Singleton { function _withArgs(text, args) { if (!args) return text; - return args.reduce((acc, arg) => acc.arg(arg), text); + return args.reduce((acc, arg) => acc.arg(_descriptionArgument(arg)), text); + } + + function _descriptionArgument(arg) { + if (typeof arg === "string") + return arg; + if (arg?.service !== "UsersService") + return ""; + switch (arg.property) { + case "adminGroup": + case "greeterGroup": + return UsersService[arg.property]; + default: + return ""; + } } function _rebuildTranslationCache() { diff --git a/quickshell/Services/UsersService.qml b/quickshell/Services/UsersService.qml index 2572028c0..713d0bebd 100644 --- a/quickshell/Services/UsersService.qml +++ b/quickshell/Services/UsersService.qml @@ -477,5 +477,4 @@ Singleton { proc.running = true; } - Component.onCompleted: refresh() } diff --git a/quickshell/translations/extract_settings_index.py b/quickshell/translations/extract_settings_index.py index fd0245026..de27d01dc 100644 --- a/quickshell/translations/extract_settings_index.py +++ b/quickshell/translations/extract_settings_index.py @@ -279,14 +279,18 @@ def enrich_keywords(label, description, category, existing_tags, parent_label=No def literal_args(value): - """Positional .arg() values after the first I18n.tr call, None where the arg is not a string literal.""" + """Extract literal and supported runtime .arg() values from a setting description.""" call_tail = value.split("I18n.tr(", 1)[-1].split("I18n.tr(", 1)[0] args = [] - for match in re.finditer(r"\.arg\(\s*(?:" + STR_DQ + "|" + STR_SQ + r")?", call_tail): + pattern = r"\.arg\(\s*(?:" + STR_DQ + "|" + STR_SQ + r"|(?PUsersService\.(?:adminGroup|greeterGroup)))?" + for match in re.finditer(pattern, call_tail): if match.group(1) is not None: args.append(decode_string_literal(match.group(1), '"')) elif match.group(2) is not None: args.append(decode_string_literal(match.group(2), "'")) + elif match.group("dynamic") is not None: + service, prop = match.group("dynamic").split(".", 1) + args.append({"service": service, "property": prop}) else: args.append(None) return args @@ -294,7 +298,7 @@ def literal_args(value): def apply_args(text, args): for index, arg in enumerate(args, start=1): - if arg is not None: + if isinstance(arg, str): text = text.replace(f"%{index}", arg) return text diff --git a/quickshell/translations/settings_search_index.json b/quickshell/translations/settings_search_index.json index 429994b87..e44ff88b1 100644 --- a/quickshell/translations/settings_search_index.json +++ b/quickshell/translations/settings_search_index.json @@ -17282,7 +17282,14 @@ "users" ], "parentLabel": "Users & accounts", - "description": "Adds them to the %1 group so they can run %2" + "description": "Adds them to the %1 group so they can run %2", + "descriptionArgs": [ + { + "service": "UsersService", + "property": "greeterGroup" + }, + "dms-greeter sync --profile" + ] }, { "section": "createUserAdmin", @@ -17305,7 +17312,13 @@ "wheel" ], "parentLabel": "Users & accounts", - "description": "Adds them to the %1 group so they can use sudo" + "description": "Adds them to the %1 group so they can use sudo", + "descriptionArgs": [ + { + "service": "UsersService", + "property": "adminGroup" + } + ] }, { "section": "greeterAuth",