macOS profile: set the wallpaper after the WindowManager restart
Verified after a reboot: desktoppr reports the configured image. The in-session read-back lags behind the wallpaper store, so the retry loop only logs it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XsESshRCoBoUVWV9qKURUF
This commit is contained in:
parent
9936b92012
commit
90cf1c64c8
1 changed files with 23 additions and 13 deletions
|
|
@ -35,19 +35,7 @@ rec {
|
|||
D com.apple.WindowManager StageManagerHideWidgets -int 1
|
||||
D com.apple.widgets widgetAppearance -int 0
|
||||
''}
|
||||
${lib.optionalString (wallpaper != null) ''
|
||||
# WallpaperAgent only keeps choices whose file lives in the user's own space
|
||||
# ("No files include in the descriptor" for /Library/Desktop Pictures)
|
||||
HP="$H/Pictures"; mkdir -p "$HP"
|
||||
W="$HP/vmix-wallpaper.${lib.last (lib.splitString "." (baseNameOf (toString wallpaper)))}"
|
||||
cp "$V/wallpaper".* "$W"; chown "$CONSOLE_USER" "$HP" "$W"; chmod 644 "$W"
|
||||
installer -pkg "$V/desktoppr.pkg" -target / >/dev/null || echo "vmix: WARNING: desktoppr install failed"
|
||||
as_user /usr/local/bin/desktoppr "$W" || echo "vmix: WARNING: could not set the wallpaper"
|
||||
# the wallpaper store (~/Library/Application Support/com.apple.wallpaper) is
|
||||
# written asynchronously by WallpaperAgent; give it time before the shutdown
|
||||
sleep 30
|
||||
echo "vmix: wallpaper now: $(as_user /usr/local/bin/desktoppr 2>/dev/null)"
|
||||
''}
|
||||
|
||||
${lib.optionalString (dockApps != null) ''
|
||||
D com.apple.dock persistent-apps -array
|
||||
${lib.concatMapStringsSep "\n" (a: ''
|
||||
|
|
@ -61,6 +49,28 @@ rec {
|
|||
else ''as_user defaults delete -g AppleInterfaceStyle 2>/dev/null || true'')}
|
||||
as_user killall Dock Finder WindowManager 2>/dev/null || true
|
||||
sleep 10
|
||||
# wallpaper last: WindowManager re-applies its desktop configuration when the
|
||||
# widget/dock settings above change, which reverts a choice made before it
|
||||
${lib.optionalString (wallpaper != null) ''
|
||||
# WallpaperAgent only keeps choices whose file lives in the user's own space
|
||||
# ("No files include in the descriptor" for /Library/Desktop Pictures)
|
||||
HP="$H/Pictures"; mkdir -p "$HP"
|
||||
W="$HP/vmix-wallpaper.${lib.last (lib.splitString "." (baseNameOf (toString wallpaper)))}"
|
||||
cp "$V/wallpaper".* "$W"; chown "$CONSOLE_USER" "$HP" "$W"; chmod 644 "$W"
|
||||
installer -pkg "$V/desktoppr.pkg" -target / >/dev/null || echo "vmix: WARNING: desktoppr install failed"
|
||||
# WallpaperAgent drops choices made while it is still initialising the
|
||||
# session's store right after login: wait for the store, set, verify, retry
|
||||
ST="$H/Library/Application Support/com.apple.wallpaper/Store/Index.plist"
|
||||
for i in $(seq 1 60); do [ -f "$ST" ] && break; sleep 2; done; sleep 15
|
||||
for try in 1 2 3; do
|
||||
as_user /usr/local/bin/desktoppr "$W" || echo "vmix: WARNING: could not set the wallpaper"
|
||||
sleep 30
|
||||
CUR=$(as_user /usr/local/bin/desktoppr 2>/dev/null)
|
||||
[ "$CUR" = "$W" ] && break
|
||||
echo "vmix: wallpaper read-back says $CUR (lags behind the store), retrying"
|
||||
done
|
||||
echo "vmix: wallpaper read-back: $CUR (the store choice is what the next login uses)"
|
||||
''}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue