Skip to content

Commit 9cb8255

Browse files
committed
Add CPU rendering toggle for video wallpapers
Add videoCpuMode setting that passes --cpu to aether-wp, skipping GPU rendering entirely. Fixes silent failures on systems where the automatic GPU-to-CPU fallback doesn't trigger.
1 parent c6197f8 commit 9cb8255

5 files changed

Lines changed: 57 additions & 4 deletions

File tree

frontend/src/lib/components/sidebar/TemplateToggles.svelte

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,42 @@
4242
{/each}
4343
</div>
4444
</div>
45+
46+
<div class="mt-4">
47+
<h3
48+
class="text-fg-dimmed mb-2 text-[10px] font-medium uppercase tracking-wider"
49+
>
50+
Video Wallpaper
51+
</h3>
52+
<div class="flex flex-col gap-2">
53+
<label class="flex cursor-pointer items-center justify-between gap-3">
54+
<div>
55+
<span class="text-fg-secondary text-[11px]">CPU rendering</span>
56+
<p class="text-fg-dimmed text-[9px] leading-snug">
57+
Use software rendering for video wallpapers. Enable if
58+
videos fail to display.
59+
</p>
60+
</div>
61+
<button
62+
class="relative h-4 w-8 shrink-0 transition-colors duration-150
63+
{getSettings().videoCpuMode
64+
? 'bg-accent'
65+
: 'bg-bg-surface border-border border'}"
66+
onclick={() =>
67+
updateSettings({
68+
videoCpuMode: !getSettings().videoCpuMode,
69+
})}
70+
role="switch"
71+
aria-checked={getSettings().videoCpuMode}
72+
aria-label="Toggle CPU rendering"
73+
>
74+
<span
75+
class="bg-fg-primary absolute left-0.5 top-0.5 h-3 w-3 transition-transform duration-150
76+
{getSettings().videoCpuMode
77+
? 'translate-x-4'
78+
: 'translate-x-0'}"
79+
></span>
80+
</button>
81+
</label>
82+
</div>
83+
</div>

frontend/src/lib/stores/settings.svelte.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const defaults: Settings = {
66
includeVscode: false,
77
includeNeovim: true,
88
selectedNeovimConfig: '',
9+
videoCpuMode: false,
910
};
1011

1112
let settings = $state<Settings>({...defaults});

frontend/src/lib/types/theme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface Settings {
4444
includeVscode: boolean;
4545
includeNeovim: boolean;
4646
selectedNeovimConfig: string;
47+
videoCpuMode: boolean;
4748
}
4849

4950
export const DEFAULT_ADJUSTMENTS: Adjustments = {

internal/theme/applier.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ func stopAetherWp() {
162162
}
163163

164164
// applyWallpaperAetherWp starts aether-wp for animated wallpapers.
165-
func applyWallpaperAetherWp(mediaPath string) error {
165+
// When cpuMode is true, passes --cpu to skip GPU and use software rendering.
166+
func applyWallpaperAetherWp(mediaPath string, cpuMode bool) error {
166167
wpBin := aetherWpPath()
167168
if wpBin == "" {
168169
return fmt.Errorf("aether-wp binary not found")
@@ -171,10 +172,20 @@ func applyWallpaperAetherWp(mediaPath string) error {
171172
_ = platform.RunAsync("pkill", "-x", "swaybg")
172173
stopAetherWp()
173174

174-
if err := platform.RunAsync("setsid", wpBin, mediaPath); err != nil {
175+
args := []string{wpBin}
176+
if cpuMode {
177+
args = append(args, "--cpu")
178+
}
179+
args = append(args, mediaPath)
180+
181+
if err := platform.RunAsync("setsid", args...); err != nil {
175182
return fmt.Errorf("failed to start aether-wp: %w", err)
176183
}
177-
log.Printf("aether-wp started for: %s", mediaPath)
184+
mode := "GPU"
185+
if cpuMode {
186+
mode = "CPU"
187+
}
188+
log.Printf("aether-wp started (%s) for: %s", mode, mediaPath)
178189
return nil
179190
}
180191

@@ -215,7 +226,7 @@ func ApplyWallpaper(wallpaperPath string, settings Settings) error {
215226
log.Printf("Created wallpaper symlink: %s -> %s", symlinkPath, wallpaperPath)
216227

217228
if IsAnimatedWallpaper(wallpaperPath) && IsAetherWpAvailable() {
218-
return applyWallpaperAetherWp(wallpaperPath)
229+
return applyWallpaperAetherWp(wallpaperPath, settings.VideoCpuMode)
219230
}
220231
return applyWallpaperSwaybg(symlinkPath)
221232
}

internal/theme/writer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type Settings struct {
5757
IncludeNeovim bool `json:"includeNeovim"`
5858
SelectedNeovimConfig string `json:"selectedNeovimConfig"`
5959
ExcludedApps map[string]bool `json:"excludedApps,omitempty"`
60+
VideoCpuMode bool `json:"videoCpuMode"`
6061
}
6162

6263
// ApplyResult is returned by ApplyTheme with the outcome of theme application.

0 commit comments

Comments
 (0)