How ducbao414/live-wallpaper works
Purpose and Runtime
LiveWallpaper is a sandboxed macOS Ventura+ Swift/SwiftUI utility that renders a user-selected video as the desktop wallpaper and mixes bundled ambient audio. It uses Apple media/window APIs locally; no backend, network service, or external runtime is indicated. The Xcode application target and signing/sandbox boundary are in LiveWallpaper.xcodeproj/project.pbxproj and LiveWallpaper/LiveWallpaper.entitlements.
Application Entry and UI Shell
LiveWallpaper/LiveWallpaperApp.swift is the SwiftUI application entry point. LiveWallpaper/ContentView.swift is the primary interactive shell, coordinating wallpaper/video selection, recent media, settings, and ambient-sound UI. LiveWallpaper/WindowManager.swift manages application-window behavior, including continued control after the primary window closes.
Wallpaper Lifecycle
LiveWallpaper/Singletons/WallpaperManager.swift is the central controller for installing, playing, pausing, and removing the video wallpaper. It owns the desktop-rendering boundary and likely coordinates playback state with the system window hierarchy. LiveWallpaper/Components/PlayerLayerView.swift and LiveWallpaper/Components/InlineVideoPlayer.swift bridge video playback/rendering into SwiftUI for wallpaper and preview contexts.
Video Ingestion and Library Flow
LiveWallpaper/Views/VideoDropView.swift is the import boundary for user-selected or dropped video files; sandbox access is limited to selected videos. LiveWallpaper/Helpers/VidAnalyzer.swift analyzes candidate media, while LiveWallpaper/Views/Recent.swift and LiveWallpaper/Components/RecentVideoView.swift present persisted/recent video choices. The flow is: choose/drop video → validate/analyze → retain recent selection/state → hand selected URL to WallpaperManager.
Power and Appearance Adaptation
LiveWallpaper/Helpers/OvercastDetector.swift supports the power-saving behavior: wallpaper rendering can pause when application windows substantially cover it. LiveWallpaper/Singletons/WallpaperManager.swift consumes this visibility/occlusion signal to control playback rather than continuously rendering. Adaptive light/dark presentation is handled at the SwiftUI/application layer, centered on LiveWallpaper/ContentView.swift and LiveWallpaper/Views/SettingView.swift.
Ambient Audio Mixer
LiveWallpaper/Singletons/AudioMixer.swift is the audio-state and playback authority for concurrent ambient tracks and per-track volumes. LiveWallpaper/Views/AmbientSounds.swift exposes mixer controls. Audio assets are bundled under LiveWallpaper/Sounds, such as LiveWallpaper/Sounds/rain.mp3, LiveWallpaper/Sounds/beach.mp3, and LiveWallpaper/Sounds/fire.mp3; they are app resources rather than downloaded content.
Persistent Settings and Supporting Presentation
LiveWallpaper/Singletons/UserSetting.swift centralizes persisted user preferences and is shared by wallpaper, audio, and settings flows. LiveWallpaper/Views/SettingView.swift is the settings surface. Reusable presentation components—blur, progress, and notifications—are isolated in LiveWallpaper/Components/BlurView.swift, LiveWallpaper/Components/ProgressRing.swift, and LiveWallpaper/Components/Toast.swift, keeping UI feedback separate from media/window control.
Main entry points: ContentView.swift Control shell · WallpaperManager.swift Wallpaper manager · UserSetting.swift User settings · VideoDropView.swift Video import
Components 16
SwiftUI surfaces
- App entry
LiveWallpaper/LiveWallpaperApp.swift - Control shell · Coordinates media selection, recents, settings, and audio controls.
LiveWallpaper/ContentView.swift - Window manager · Keeps controls available after the primary window closes.
LiveWallpaper/WindowManager.swift - Settings
LiveWallpaper/Views/SettingView.swift - User settings · Shared preferences for wallpaper and audio behavior.
LiveWallpaper/Singletons/UserSetting.swift - UI feedback components · Blur, progress, and toast presentation.
LiveWallpaper/Components/Toast.swift
Video wallpaper
- Video import · Accepts user-selected or dropped videos.
LiveWallpaper/Views/VideoDropView.swift - Media analyzer
LiveWallpaper/Helpers/VidAnalyzer.swift - Recent videos · Presents persisted recent video choices.
LiveWallpaper/Views/Recent.swift - Wallpaper manager · Installs, renders, and controls video wallpaper playback.
LiveWallpaper/Singletons/WallpaperManager.swift - Video player bridge · Bridges video rendering for wallpaper and preview contexts.
LiveWallpaper/Components/PlayerLayerView.swift - Occlusion detector · Detects when application windows substantially cover the wallpaper.
LiveWallpaper/Helpers/OvercastDetector.swift
Ambient audio
- Ambient sound controls
LiveWallpaper/Views/AmbientSounds.swift - Audio mixer · Mixes concurrent ambient tracks with per-track volumes.
LiveWallpaper/Singletons/AudioMixer.swift - Bundled sound assets · Local rain, beach, fire, and other ambient tracks.
LiveWallpaper/Sounds
Other components
- App sandbox and signing · Xcode target defines the sandboxed local application boundary.
LiveWallpaper/LiveWallpaper.entitlements
Connections 17
- App entry → Control shell: launches
- App entry → Window manager: manages
- Control shell → Video import: selects video
- Control shell → Recent videos: shows
- Control shell → Settings: opens
- Control shell → Ambient sound controls: hosts
- Video import → Media analyzer: analyzes
- Media analyzer → Recent videos: retains selection
- Recent videos → Wallpaper manager: selected URL
- Wallpaper manager → Video player bridge: renders through
- Occlusion detector → Wallpaper manager: pause/resume signal
- Settings → User settings: updates
- User settings → Wallpaper manager: playback preferences
- User settings → Audio mixer: audio preferences
- Ambient sound controls → Audio mixer: controls
- Bundled sound assets → Audio mixer: local tracks
- App sandbox and signing → Video import: limits file access