Complete Panama settings controls
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Public Settings.qml values are the compatibility surface consumed throughout
|
||||
# the shell. Once a value becomes user-configurable, this file must read it from
|
||||
# DesktopPreferences rather than keeping a second hardcoded source of truth.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
settings="$repo_dir/config/dot/quickshell/config/Settings.qml"
|
||||
|
||||
fail() {
|
||||
printf 'settings hardcoded values contract: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
properties=(
|
||||
temperatureUnit
|
||||
weatherRefreshMinutes
|
||||
vitalsIntervalMs
|
||||
notificationTimeoutMs
|
||||
notificationTimeoutCriticalMs
|
||||
notificationHistoryLimit
|
||||
maxVisibleToasts
|
||||
screenshotDir
|
||||
recordingDir
|
||||
recorderArgs
|
||||
)
|
||||
|
||||
for property in "${properties[@]}"; do
|
||||
count="$(rg -c \
|
||||
"^[[:space:]]*readonly property [A-Za-z]+ ${property}: DesktopPreferences\\.get\\(\"${property}\"\\)[[:space:]]*(//.*)?$" \
|
||||
"$settings" || true)"
|
||||
[[ "$count" == "1" ]] \
|
||||
|| fail "$property must use DesktopPreferences.get(\"$property\") exactly once"
|
||||
done
|
||||
|
||||
# dockPinned was already migrated on the shared branch. Pinning it here keeps a
|
||||
# later bulk edit from accidentally restoring the old hardcoded app list.
|
||||
rg -q '^[[:space:]]*readonly property var dockPinned: DesktopPreferences\.get\("dockPinned"\)[[:space:]]*$' "$settings" \
|
||||
|| fail 'dockPinned no longer reads DesktopPreferences exactly'
|
||||
|
||||
printf 'settings hardcoded values contract: PASS\n'
|
||||
@@ -3,6 +3,85 @@
|
||||
set -euo pipefail
|
||||
|
||||
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
fail() {
|
||||
printf 'settings pages contract: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
pages=(Home Displays Connectivity Sound Notifications ScreenIntelligence Services About)
|
||||
for page in "${pages[@]}"; do
|
||||
page_file="$repo_dir/config/dot/quickshell/modules/settings/${page}Page.qml"
|
||||
[[ -f "$page_file" ]] || fail "${page}Page.qml is missing"
|
||||
|
||||
root_type="$(awk '
|
||||
/^import / { next }
|
||||
/^[[:space:]]*\/\// { next }
|
||||
/^[[:space:]]*$/ { next }
|
||||
match($0, /^[[:space:]]*([A-Za-z][A-Za-z0-9]*)[[:space:]]*\{/, found) {
|
||||
print found[1]
|
||||
exit
|
||||
}
|
||||
' "$page_file")"
|
||||
[[ "$root_type" == "SettingsPage" ]] \
|
||||
|| fail "${page}Page.qml root is ${root_type:-unknown}, expected SettingsPage"
|
||||
! rg -q '^[[:space:]]*Flickable[[:space:]]*\{' "$page_file" \
|
||||
|| fail "${page}Page.qml still copies the page Flickable scaffold"
|
||||
done
|
||||
|
||||
require_row() {
|
||||
local file="$1"
|
||||
local row_type="$2"
|
||||
local setting="$3"
|
||||
|
||||
python3 - "$file" "$row_type" "$setting" <<'PY' || \
|
||||
fail "$(basename "$file") is missing $row_type for $setting"
|
||||
import re
|
||||
import sys
|
||||
|
||||
text = open(sys.argv[1], encoding="utf-8").read()
|
||||
row_type = re.escape(sys.argv[2])
|
||||
setting = re.escape(sys.argv[3])
|
||||
pattern = rf"{row_type}\s*\{{(?:(?!\n\s*[A-Z][A-Za-z0-9]*\s*\{{).)*?setting\s*:\s*\"{setting}\""
|
||||
raise SystemExit(0 if re.search(pattern, text, re.S) else 1)
|
||||
PY
|
||||
}
|
||||
|
||||
home_page="$repo_dir/config/dot/quickshell/modules/settings/HomePage.qml"
|
||||
require_row "$home_page" ChoiceRow temperatureUnit
|
||||
require_row "$home_page" SliderRow weatherRefreshMinutes
|
||||
require_row "$home_page" SliderRow vitalsIntervalMs
|
||||
|
||||
notifications_page="$repo_dir/config/dot/quickshell/modules/settings/NotificationsPage.qml"
|
||||
for setting in notificationTimeoutMs notificationTimeoutCriticalMs notificationHistoryLimit maxVisibleToasts; do
|
||||
require_row "$notifications_page" SliderRow "$setting"
|
||||
done
|
||||
python3 - "$notifications_page" <<'PY' || fail 'critical notification timeout does not render zero as Never'
|
||||
import re
|
||||
import sys
|
||||
|
||||
text = open(sys.argv[1], encoding="utf-8").read()
|
||||
block = re.search(
|
||||
r'SliderRow\s*\{(?:(?!\n\s*[A-Z][A-Za-z0-9]*\s*\{).)*?'
|
||||
r'setting\s*:\s*"notificationTimeoutCriticalMs"(?P<tail>.*?)\n\s*\}',
|
||||
text,
|
||||
re.S,
|
||||
)
|
||||
raise SystemExit(0 if block and re.search(r'zeroLabel\s*:\s*"Never"', block.group(0)) else 1)
|
||||
PY
|
||||
|
||||
intelligence_page="$repo_dir/config/dot/quickshell/modules/settings/ScreenIntelligencePage.qml"
|
||||
require_row "$intelligence_page" ChoiceRow screenshotDir
|
||||
require_row "$intelligence_page" ChoiceRow recordingDir
|
||||
require_row "$intelligence_page" ChoiceRow recorderArgs
|
||||
|
||||
# The source-only contract is safe during a shared Quickshell quiet window.
|
||||
# The existing compositor integration checks remain available explicitly.
|
||||
if [[ "${PANAMA_SETTINGS_STATIC_ONLY:-0}" == "1" ]]; then
|
||||
printf 'settings pages contract: PASS (static)\n'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
state_home="$(mktemp -d /tmp/panama-settings-pages-state.XXXXXX)"
|
||||
source_config_path="$repo_dir/config/dot/quickshell"
|
||||
config_path="$state_home/quickshell"
|
||||
@@ -58,11 +137,6 @@ exit 97
|
||||
EOF
|
||||
chmod +x "$test_bin/flatpak"
|
||||
|
||||
fail() {
|
||||
printf 'settings pages contract: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qs_for_test() {
|
||||
PATH="$test_bin:$PATH" QS_CONFIG_PATH="$config_path" XDG_STATE_HOME="$state_home" \
|
||||
qs -p "$config_path" "$@"
|
||||
|
||||
Reference in New Issue
Block a user