瀏覽代碼

better X11 handling, AUR package fixes, Hyprland support features

UwU 1 月之前
父節點
當前提交
b4716aa833

+ 3 - 1
.github/workflows/build.yml

@@ -185,6 +185,8 @@ jobs:
 
   aur:
     needs: release
+    # pre-release tags are no valid pkgver
+    if: ${{ !contains(github.ref_name, '-') }}
     runs-on: ubuntu-latest
     env:
       HAS_AUR_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY != '' }}
@@ -197,7 +199,7 @@ jobs:
 
       - name: Publish we-manager-bin to the AUR
         if: env.HAS_AUR_KEY == 'true'
-        uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
+        uses: KSXGitHub/github-actions-deploy-aur@2ac5a4c1d7035885d46b10e3193393be8460b6f1 # v4.1.1
         with:
           pkgname: we-manager-bin
           pkgbuild: ./packaging/aur/we-manager-bin/PKGBUILD

+ 27 - 0
README.md

@@ -52,3 +52,30 @@ npm run dist     # package with electron-builder
   is called correctly on our end. Confirmed upstream: relaunching the process
   is the only thing that clears it, but doing that from the toggle itself
   caused GPU/window failures on Wayland, so it isn't worth the tradeoff.
+
+## Hyprland, Sway, niri and other wlroots compositors
+
+- Screens come from the compositor itself when its session variable is set: `hyprctl monitors -j`
+  (`HYPRLAND_INSTANCE_SIGNATURE`), `swaymsg -t get_outputs -r` (`SWAYSOCK`) or `niri msg --json outputs`
+  (`NIRI_SOCKET`). Disabled outputs are skipped. `wlr-randr`, `kscreen-doctor`, GNOME's D-Bus API and `xrandr`
+  stay as the fallbacks, in that order.
+- Settings > Performance has "Use the background layer" (`--layer background`) on these compositors and on KDE.
+  niri needs it, the engine's default is the bottom layer. The stored setting is still called
+  `kdeBackgroundLayer`, so existing configs keep working.
+- These compositors do not run `~/.config/autostart` entries, so Settings shows the line for the compositor
+  config next to the startup toggle (`exec-once = ... --minimized` for Hyprland, `exec ... --minimized` for sway,
+  `spawn-at-startup` for niri, the plain command otherwise). It only shows in a packaged build, the path is the
+  AppImage or the installed executable.
+- Closing the window to the tray (and `--minimized`) needs a StatusNotifier host on the session bus, e.g. the
+  tray module of waybar or a Quickshell tray. Without one, closing quits the app and `--minimized` shows the
+  window after waiting 10 seconds for the host to appear. If neither `busctl` nor `gdbus` can tell, a host is
+  assumed.
+- Click forwarding: a layer-shell background surface gets no mouse buttons while a bar or shell covers it. With an
+  engine that has `--input-file`, WE Manager starts each engine with `$XDG_RUNTIME_DIR/lwe-input-<screen>`
+  (`lwe-input-all` when one engine draws every screen), and Settings > Performance lists the paths. A shell or
+  compositor binding writes `{"leftDown":true}` into that file while the left button is held, e.g.
+  `echo '{"leftDown":true}' > "$XDG_RUNTIME_DIR/lwe-input-DP-1"`, and keeps refreshing it: the engine ignores
+  the file once it is older than 2 seconds. WE Manager never writes the file itself.
+- Not done, these are engine side and tracked in the linux-wallpaperengine-kde repository: the fullscreen pause is
+  global per engine and ignores maximized windows on wlroots compositors, fractional scaling is rounded to an
+  integer scale, and the Flatpak sandbox cannot reach the Hyprland socket.

+ 1 - 1
packaging/aur/we-manager-bin/PKGBUILD

@@ -1,5 +1,5 @@
 # Maintainer: UwU <260361707+WallpaperEngineLover@users.noreply.github.com>
-# pkgver and the checksum are set by .github/workflows/aur.yml on every release
+# pkgver and the checksum are set by the aur job of .github/workflows/build.yml on every release
 pkgname=we-manager-bin
 _pkgname=we-manager
 pkgver=0.8.1

+ 21 - 2
src/main/index.ts

@@ -14,12 +14,14 @@ import { initPlaylistPlayer, startPlaylist } from './services/playlist-player.se
 import { killAllLweProcesses, getLweStatus } from './services/lwe.service'
 import { initDisplay } from './services/display.service'
 import { initSchedule } from './services/schedule.service'
+import { hasStatusNotifierHost } from './utils/platform'
 
 const startMinimized = process.argv.includes('--minimized')
 let isQuitting = false
 let hasKilledLweOnQuit = false
 
 const BACKGROUND_SYNC_INTERVAL_MS = 3 * 60 * 1000
+const TRAY_HOST_WAIT_MS = 10_000
 
 // Keeps "liked" state and library availability fresh without the user having to restart the
 // app or click "Check unavailable" - votes cast on Steam directly (client, community website)
@@ -78,7 +80,21 @@ function startBackgroundSync(win: BrowserWindow): void {
   }, BACKGROUND_SYNC_INTERVAL_MS)
 }
 
+// gives a panel that starts after us until the deadline, then shows the window
+function showWindowUnlessTrayAppears(win: BrowserWindow): void {
+  const deadline = Date.now() + TRAY_HOST_WAIT_MS
+  const timer = setInterval(() => {
+    if (win.isDestroyed() || win.isVisible() || hasStatusNotifierHost(0)) {
+      clearInterval(timer)
+    } else if (Date.now() >= deadline) {
+      clearInterval(timer)
+      win.show()
+    }
+  }, 1000)
+}
+
 function createWindow(): BrowserWindow {
+  const startHidden = startMinimized && getTrayEnabled()
   const win = new BrowserWindow({
     width: 1280,
     height: 800,
@@ -86,7 +102,7 @@ function createWindow(): BrowserWindow {
     minHeight: 600,
     backgroundColor: '#0f0f0f',
     titleBarStyle: 'hiddenInset',
-    show: !(startMinimized && getTrayEnabled()),
+    show: !startHidden,
     webPreferences: {
       preload: path.join(__dirname, '../preload/index.cjs'),
       contextIsolation: true,
@@ -102,8 +118,9 @@ function createWindow(): BrowserWindow {
 
   // When the tray is enabled, closing the window hides it instead of quitting so the
   // tray icon remains the only way back in (and the app keeps running for playlists).
+  // Without a StatusNotifier host there is no icon to come back through, so it quits.
   win.on('close', (event) => {
-    if (getTrayEnabled() && !isQuitting) {
+    if (getTrayEnabled() && !isQuitting && hasStatusNotifierHost()) {
       event.preventDefault()
       win.hide()
     }
@@ -115,6 +132,8 @@ function createWindow(): BrowserWindow {
     win.loadFile(path.join(__dirname, '../renderer/index.html'))
   }
 
+  if (startHidden && !hasStatusNotifierHost()) showWindowUnlessTrayAppears(win)
+
   return win
 }
 

+ 2 - 1
src/main/ipc/config.handlers.ts

@@ -66,7 +66,7 @@ import { DEFAULT_LWE_REPO } from '@shared/constants'
 import { restartWatcher } from '../services/watcher.service'
 import { importWEConfig } from '../services/library.service'
 import { createTray, destroyTray } from '../services/tray.service'
-import { isAutostartSupported, setAutostartEnabled } from '../services/autostart.service'
+import { getCompositorAutostartLine, isAutostartSupported, setAutostartEnabled } from '../services/autostart.service'
 
 export function registerConfigHandlers(): void {
   ipcMain.handle(IpcChannels.CONFIG_GET, () => ({
@@ -86,6 +86,7 @@ export function registerConfigHandlers(): void {
     autoUnsubscribeAfterBackup: getAutoUnsubscribeAfterBackup(),
     trayEnabled: getTrayEnabled(),
     autostartSupported: isAutostartSupported(),
+    autostartCompositorLine: getCompositorAutostartLine(),
     autostartEnabled: getAutostartEnabled(),
     autostartMinimized: getAutostartMinimized(),
     autostartPlaylistId: getAutostartPlaylistId(),

+ 3 - 1
src/main/ipc/lwe.handlers.ts

@@ -1,6 +1,6 @@
 import { BrowserWindow, dialog, ipcMain } from 'electron'
 import { IpcChannels } from '@shared/ipc-channels'
-import { getLweStatus, detectDistro, installLweDeps, installLwe, uninstallLwe, launchLweAsync, isLweRunning, killAllLweProcesses, listLweObjects, hotswapLweSettings, listLweProperties, listLweAudioObjects, listLweEffects, type HotswapOptions } from '../services/lwe.service'
+import { getLweStatus, detectDistro, installLweDeps, installLwe, uninstallLwe, launchLweAsync, isLweRunning, killAllLweProcesses, listLweObjects, hotswapLweSettings, listLweProperties, listLweAudioObjects, listLweEffects, listInputFiles, type HotswapOptions } from '../services/lwe.service'
 import { getPrebuiltTarget, installLwePrebuilt } from '../services/lwe-prebuilt.service'
 import { stopDisplay } from '../services/display.service'
 import { stopPlaylist } from '../services/playlist-player.service'
@@ -78,6 +78,8 @@ export function registerLweHandlers(win: BrowserWindow): void {
     return getConnectedScreens()
   })
 
+  ipcMain.handle(IpcChannels.LWE_INPUT_FILES, () => listInputFiles(getConnectedScreens()))
+
   ipcMain.handle(IpcChannels.LWE_LIST_APPLICATIONS, () => listDesktopApplications())
 
   // null when there is no video file or no ffprobe to measure it

+ 8 - 0
src/main/services/autostart.service.ts

@@ -2,6 +2,8 @@ import * as fs from 'fs'
 import * as path from 'path'
 import * as os from 'os'
 import { app } from 'electron'
+import { compositorAutostartLine } from '@shared/desktop'
+import { detectDesktopEnv } from '../utils/platform'
 
 const DESKTOP_FILE_NAME = 'we-manager.desktop'
 
@@ -56,6 +58,12 @@ export function setAutostartEnabled(enabled: boolean, minimized: boolean): void
   fs.writeFileSync(filePath, contents, 'utf8')
 }
 
+/** Startup line for the compositor config, null when the session runs the .desktop entry itself */
+export function getCompositorAutostartLine(): string | null {
+  if (!isAutostartSupported()) return null
+  return compositorAutostartLine(detectDesktopEnv(), resolveExecutablePath())
+}
+
 export function isAutostartFileEnabled(): boolean {
   return fs.existsSync(getAutostartDesktopPath())
 }

+ 7 - 0
src/main/services/lwe.service.test.ts

@@ -133,6 +133,13 @@ describe('nodeDevelPackage', () => {
     expect(nodeDevelPackage([])).toBe('nodejs-devel')
     expect(nodeDevelPackage(['nodejs24-docs'])).toBe('nodejs-devel')
   })
+
+  it('keeps an installed -devel package instead of adding a conflicting one', () => {
+    // Nobara: nodejs-devel 22 from an older release next to Fedora 44's nodejs24-libs
+    expect(nodeDevelPackage(['nodejs-libs', 'nodejs24-libs', 'nodejs-devel'])).toBeNull()
+    expect(nodeDevelPackage(['nodejs22-libs', 'nodejs22-devel'])).toBeNull()
+    expect(nodeDevelPackage(['nodejs24-libs', 'nodejs24-docs'])).toBe('nodejs24-devel')
+  })
 })
 
 describe('parseOsReleaseIds', () => {

+ 81 - 149
src/main/services/lwe.service.ts

@@ -24,7 +24,8 @@ import {
   whichCommand,
   getConnectedScreens,
   getWaylandDisplay,
-  getXdgRuntimeDir
+  getXdgRuntimeDir,
+  isWaylandSession
 } from '../utils/platform'
 import { getWorkshopPath, getLweManifestPath, getLwePrebuiltDir, getSteamRoots } from '../utils/paths'
 import { isFlatpak } from '../utils/flatpak'
@@ -244,12 +245,6 @@ export function getLweStatus(): LweStatus {
 export function resetLweDetection(): void {
   ownerCache = undefined
   invalidateCommandCache(LWE_BINARY)
-  invalidateObjectFlagsSupport()
-  invalidateAudioSensitivitySupport()
-  invalidateSoundVolumeSupport()
-  invalidateEffectFlagsSupport()
-  invalidateDisableAnimationsSupport()
-  invalidateExpandCanvasSupport()
   invalidateHelpText()
 }
 
@@ -310,13 +305,16 @@ const DEPS_FEDORA = [
 ]
 
 /**
- * Fedora's Node.js packages are versioned (nodejs22, nodejs24, ...) and their -devel packages conflict, so the headers
- * have to belong to the libnode already installed; with none installed dnf picks the default for nodejs-devel
+ * Fedora's versioned nodejsNN-devel packages conflict, so an installed one is kept. Otherwise the headers must match
+ * the newest installed libnode; with none installed dnf picks the default for nodejs-devel
  */
-export function nodeDevelPackage(installedLibs: string[]): string {
+export function nodeDevelPackage(installedNodePackages: string[]): string | null {
+  const names = installedNodePackages.map((name) => name.trim())
+  if (names.some((name) => /^nodejs\d*-devel$/.test(name))) return null
+
   let best: { name: string; version: number } | undefined
-  for (const name of installedLibs) {
-    const match = /^nodejs(\d*)-libs$/.exec(name.trim())
+  for (const name of names) {
+    const match = /^nodejs(\d*)-libs$/.exec(name)
     if (!match) continue
     const version = match[1] ? Number(match[1]) : 0
     if (!best || version > best.version) best = { name: `nodejs${match[1]}-devel`, version }
@@ -324,9 +322,12 @@ export function nodeDevelPackage(installedLibs: string[]): string {
   return best?.name ?? 'nodejs-devel'
 }
 
-function installedNodeLibs(): string[] {
+function installedNodePackages(): string[] {
   try {
-    return execFileSync('rpm', ['-qa', '--qf', '%{NAME}\n', 'nodejs*-libs'], { encoding: 'utf8', timeout: 10_000 }).split('\n')
+    return execFileSync('rpm', ['-qa', '--qf', '%{NAME}\n', 'nodejs*-libs', 'nodejs*-devel'], {
+      encoding: 'utf8',
+      timeout: 10_000
+    }).split('\n')
   } catch {
     return []
   }
@@ -385,7 +386,8 @@ export async function installLweDeps(win: BrowserWindow): Promise<void> {
       pkgManager = 'dnf'
       // --skip-unavailable: avoid failing on missing/broken repos (e.g. Cursor 403) or package renames
       installArgs = ['install', '-y', '--skip-unavailable']
-      packages = [...DEPS_FEDORA, nodeDevelPackage(installedNodeLibs())]
+      const nodeDevel = nodeDevelPackage(installedNodePackages())
+      packages = nodeDevel ? [...DEPS_FEDORA, nodeDevel] : DEPS_FEDORA
       break
     case 'arch':
       pkgManager = 'pacman'
@@ -806,10 +808,15 @@ function buildLweEnvVars(): string[] {
   const waylandDisplay = getWaylandDisplay()
   if (waylandDisplay) vars.push(`WAYLAND_DISPLAY=${waylandDisplay}`)
 
-  // XDG_SESSION_TYPE is how LWE decides between X11 and Wayland drivers
-  const sessionType = process.env.XDG_SESSION_TYPE
+  // LWE picks its X11/Wayland driver by XDG_SESSION_TYPE, often unset without a login manager
+  const sessionType = process.env.XDG_SESSION_TYPE || (waylandDisplay ? 'wayland' : undefined)
   if (sessionType) vars.push(`XDG_SESSION_TYPE=${sessionType}`)
 
+  for (const name of ['XDG_CURRENT_DESKTOP', 'HYPRLAND_INSTANCE_SIGNATURE', 'SWAYSOCK', 'NIRI_SOCKET']) {
+    const value = process.env[name]
+    if (value) vars.push(`${name}=${value}`)
+  }
+
   if (process.env.DISPLAY) vars.push(`DISPLAY=${process.env.DISPLAY}`)
 
   // XDG_RUNTIME_DIR is needed for the Wayland socket
@@ -818,148 +825,28 @@ function buildLweEnvVars(): string[] {
   return vars
 }
 
-// Not every linux-wallpaperengine build has --list-objects/--disable-object/--enable-object
-// (they're recent additions), so probe --help once and cache the result rather than assuming.
-let objectFlagsSupported: boolean | null = null
-
-function invalidateObjectFlagsSupport(): void {
-  objectFlagsSupported = null
-}
-
 function supportsObjectFlags(): boolean {
-  if (objectFlagsSupported !== null) return objectFlagsSupported
-  try {
-    const binaryPath = getLweBinaryPath()
-    const envVars = buildLweEnvVars()
-    const stdout = execFileSync('env', [...envVars, binaryPath, '--help'], {
-      timeout: 5_000,
-      encoding: 'utf8',
-      maxBuffer: 2 * 1024 * 1024
-    })
-    objectFlagsSupported = stdout.includes('--list-objects')
-  } catch {
-    objectFlagsSupported = false
-  }
-  return objectFlagsSupported
-}
-
-// --list-audio-objects/--audio-sensitivity are even more recent than --list-objects, so they get
-// their own cached probe rather than assuming a build new enough for one is new enough for both.
-let audioSensitivitySupported: boolean | null = null
-
-function invalidateAudioSensitivitySupport(): void {
-  audioSensitivitySupported = null
+  return supportsFlag('--list-objects')
 }
 
 function supportsAudioSensitivity(): boolean {
-  if (audioSensitivitySupported !== null) return audioSensitivitySupported
-  try {
-    const binaryPath = getLweBinaryPath()
-    const envVars = buildLweEnvVars()
-    const stdout = execFileSync('env', [...envVars, binaryPath, '--help'], {
-      timeout: 5_000,
-      encoding: 'utf8',
-      maxBuffer: 2 * 1024 * 1024
-    })
-    audioSensitivitySupported = stdout.includes('--list-audio-objects')
-  } catch {
-    audioSensitivitySupported = false
-  }
-  return audioSensitivitySupported
-}
-
-// --sound-volume is newer still - its own probe rather than assuming a build with
-// --list-audio-objects also has it.
-let soundVolumeSupported: boolean | null = null
-
-function invalidateSoundVolumeSupport(): void {
-  soundVolumeSupported = null
+  return supportsFlag('--list-audio-objects')
 }
 
 function supportsSoundVolume(): boolean {
-  if (soundVolumeSupported !== null) return soundVolumeSupported
-  try {
-    const binaryPath = getLweBinaryPath()
-    const envVars = buildLweEnvVars()
-    const stdout = execFileSync('env', [...envVars, binaryPath, '--help'], {
-      timeout: 5_000,
-      encoding: 'utf8',
-      maxBuffer: 2 * 1024 * 1024
-    })
-    soundVolumeSupported = stdout.includes('--sound-volume')
-  } catch {
-    soundVolumeSupported = false
-  }
-  return soundVolumeSupported
-}
-
-let effectFlagsSupported: boolean | null = null
-
-function invalidateEffectFlagsSupport(): void {
-  effectFlagsSupported = null
+  return supportsFlag('--sound-volume')
 }
 
 function supportsEffectFlags(): boolean {
-  if (effectFlagsSupported !== null) return effectFlagsSupported
-  try {
-    const binaryPath = getLweBinaryPath()
-    const envVars = buildLweEnvVars()
-    const stdout = execFileSync('env', [...envVars, binaryPath, '--help'], {
-      timeout: 5_000,
-      encoding: 'utf8',
-      maxBuffer: 2 * 1024 * 1024
-    })
-    effectFlagsSupported = stdout.includes('--list-effects')
-  } catch {
-    effectFlagsSupported = false
-  }
-  return effectFlagsSupported
-}
-
-let disableAnimationsSupported: boolean | null = null
-
-function invalidateDisableAnimationsSupport(): void {
-  disableAnimationsSupported = null
+  return supportsFlag('--list-effects')
 }
 
 function supportsDisableAnimations(): boolean {
-  if (disableAnimationsSupported !== null) return disableAnimationsSupported
-  try {
-    const binaryPath = getLweBinaryPath()
-    const envVars = buildLweEnvVars()
-    const stdout = execFileSync('env', [...envVars, binaryPath, '--help'], {
-      timeout: 5_000,
-      encoding: 'utf8',
-      maxBuffer: 2 * 1024 * 1024
-    })
-    disableAnimationsSupported = stdout.includes('--disable-animations')
-  } catch {
-    disableAnimationsSupported = false
-  }
-  return disableAnimationsSupported
-}
-
-let expandCanvasSupported: boolean | null = null
-
-function invalidateExpandCanvasSupport(): void {
-  expandCanvasSupported = null
+  return supportsFlag('--disable-animations')
 }
 
 function supportsExpandCanvas(): boolean {
-  if (expandCanvasSupported !== null) return expandCanvasSupported
-  try {
-    const binaryPath = getLweBinaryPath()
-    const envVars = buildLweEnvVars()
-    const stdout = execFileSync('env', [...envVars, binaryPath, '--help'], {
-      timeout: 5_000,
-      encoding: 'utf8',
-      maxBuffer: 2 * 1024 * 1024
-    })
-    expandCanvasSupported = stdout.includes('--expand-canvas')
-  } catch {
-    expandCanvasSupported = false
-  }
-  return expandCanvasSupported
+  return supportsFlag('--expand-canvas')
 }
 
 // shell-like: quotes group whitespace anywhere in a token (foo="bar baz") and are dropped
@@ -990,16 +877,30 @@ export function parseCustomArgs(raw: string): string[] {
 }
 
 let helpText: string | null = null
+let helpTextStamp = ''
 
 function invalidateHelpText(): void {
   helpText = null
 }
 
+// the binary can be replaced while we run, the cached --help is tied to the file
+function binaryStamp(binaryPath: string): string {
+  try {
+    const stat = fs.statSync(binaryPath)
+    return `${binaryPath}:${stat.ino}:${stat.size}:${stat.mtimeMs}`
+  } catch {
+    return binaryPath
+  }
+}
+
 // older builds ignore unknown flags, so a flag the binary doesn't list is left out instead of passed
 function supportsFlag(flag: string): boolean {
-  if (helpText === null) {
+  const binaryPath = getLweBinaryPath()
+  const stamp = binaryStamp(binaryPath)
+  if (helpText === null || stamp !== helpTextStamp) {
+    helpTextStamp = stamp
     try {
-      helpText = execFileSync('env', [...buildLweEnvVars(), getLweBinaryPath(), '--help'], {
+      helpText = execFileSync('env', [...buildLweEnvVars(), binaryPath, '--help'], {
         timeout: 5_000,
         encoding: 'utf8',
         maxBuffer: 2 * 1024 * 1024
@@ -1028,6 +929,7 @@ export interface LweLaunchOptions {
   offsetY?: number
   disableParallax?: boolean
   expandCanvas?: boolean
+  repairAssets?: boolean
   cornerColor?: string
   imageAdjustments?: ImageAdjustments
   speed?: number
@@ -1081,6 +983,7 @@ function buildLweArgs(
   }
   if (options.disableParallax) args.push('--disable-parallax')
   if (options.expandCanvas && supportsExpandCanvas()) args.push('--expand-canvas')
+  if (options.repairAssets && supportsFlag('--repair-assets')) args.push('--repair-assets')
   if (options.cornerColor) args.push('--corner-color', options.cornerColor)
   if (options.speed !== undefined) args.push('--speed', String(options.speed))
   const segments = options.videoSegments ?? []
@@ -1132,10 +1035,28 @@ function getControlFilePath(): string {
   return path.join(getXdgRuntimeDir(), 'lwe-control')
 }
 
+function screenFileSuffix(screen: ScreenTarget): string {
+  return screen === ALL_SCREENS ? 'all' : screen.replace(/[^A-Za-z0-9._-]/g, '_')
+}
+
 /** One hotswap file per engine (--control-file), so engines on different screens can't read each other's */
 function controlFileFor(screen: ScreenTarget): string {
-  const name = screen === ALL_SCREENS ? 'all' : screen.replace(/[^A-Za-z0-9._-]/g, '_')
-  return path.join(getXdgRuntimeDir(), `lwe-control-${name}`)
+  return path.join(getXdgRuntimeDir(), `lwe-control-${screenFileSuffix(screen)}`)
+}
+
+/** Where a desktop shell writes the mouse button state for the engine on a screen (--input-file) */
+function inputFileFor(screen: ScreenTarget): string {
+  return path.join(getXdgRuntimeDir(), `lwe-input-${screenFileSuffix(screen)}`)
+}
+
+function supportsInputFile(): boolean {
+  return isWaylandSession() && supportsFlag('--input-file')
+}
+
+/** Input files for the all-screens engine and each given screen, none without --input-file support */
+export function listInputFiles(screens: string[]): { screen: ScreenTarget; path: string }[] {
+  if (!supportsInputFile()) return []
+  return [ALL_SCREENS, ...screens].map((screen) => ({ screen, path: inputFileFor(screen) }))
 }
 
 /**
@@ -1382,6 +1303,7 @@ export interface HotswapOptions {
   offsetY?: number
   disableParallax?: boolean
   expandCanvas?: boolean
+  repairAssets?: boolean
   cornerColor?: string
   imageAdjustments?: ImageAdjustments
   speed?: number
@@ -1435,6 +1357,9 @@ export function buildHotswapLines(options: HotswapOptions): string[] {
   }
   if (options.disableParallax !== undefined) lines.push(`disable-parallax=${options.disableParallax ? 'on' : 'off'}`)
   if (options.expandCanvas !== undefined) lines.push(`expand-canvas=${options.expandCanvas ? 'on' : 'off'}`)
+  if (options.repairAssets !== undefined && supportsFlag('--repair-assets')) {
+    lines.push(`repair-assets=${options.repairAssets ? 'on' : 'off'}`)
+  }
   if (options.cornerColor !== undefined) lines.push(`corner-color=${options.cornerColor}`)
   lines.push(...imageAdjustmentLines(options.imageAdjustments))
   if (options.speed !== undefined) lines.push(`speed=${options.speed}`)
@@ -1536,6 +1461,7 @@ function hotswapOptionsFor(wallpaperPath: string, options: LweLaunchOptions): Ho
     offsetY: options.offsetY ?? 0,
     disableParallax: options.disableParallax ?? false,
     expandCanvas: options.expandCanvas ?? false,
+    repairAssets: options.repairAssets ?? false,
     cornerColor: options.cornerColor ?? '000000',
     imageAdjustments: options.imageAdjustments,
     speed: options.speed ?? 1,
@@ -1585,7 +1511,12 @@ export async function launchLweAsync(wallpaperPath: string, options: LweLaunchOp
 
   const binaryPath = getLweBinaryPath()
   const controlFile = supportsFlag('--control-file') ? controlFileFor(screen) : null
-  const lweArgs = [...(controlFile ? ['--control-file', controlFile] : []), ...buildLweArgs(wallpaperPath, options)]
+  const inputFile = supportsInputFile() ? inputFileFor(screen) : null
+  const lweArgs = [
+    ...(controlFile ? ['--control-file', controlFile] : []),
+    ...(inputFile ? ['--input-file', inputFile] : []),
+    ...buildLweArgs(wallpaperPath, options)
+  ]
   const envVars = buildLweEnvVars()
 
   // Spawn via `env` to set env vars explicitly, matching how LWE works from the terminal.
@@ -1786,7 +1717,7 @@ function parseLweAudioObjectList(output: string): LweAudioObject[] {
 export async function listLweAudioObjects(wallpaperPath: string): Promise<LweAudioObject[]> {
   const status = getLweStatus()
   if (!status.installed) throw new Error('linux-wallpaperengine is not installed.')
-  // Same reasoning as supportsObjectFlags(): older builds silently ignore unknown flags and fall
+  // older builds silently ignore unknown flags and fall
   // through to actually rendering the wallpaper instead of exiting.
   if (!supportsAudioSensitivity()) return []
 
@@ -1934,6 +1865,7 @@ export async function stopLwe(screen?: ScreenTarget): Promise<void> {
       } catch { /* already dead */ }
       await waitForPidExit(inst.pid)
       if (inst.controlFile) fs.rmSync(inst.controlFile, { force: true })
+      fs.rmSync(inputFileFor(inst.screen), { force: true })
       if (instances.get(inst.screen) === inst) instances.delete(inst.screen)
     })
   )

+ 2 - 0
src/main/services/wallpaper.service.ts

@@ -55,6 +55,7 @@ export function detectEnvironment(): WallpaperEnvironment {
   else if (desktopEnv === 'gnome') recommended = 'gsettings'
   else if (desktopEnv === 'kde') recommended = 'qdbus'
   else if (displayServer === 'wayland' && available.includes('swww')) recommended = 'swww'
+  else if (displayServer === 'wayland' && available.includes('swaybg')) recommended = 'swaybg'
   else if (available.includes('feh')) recommended = 'feh'
 
   envCache = {
@@ -236,6 +237,7 @@ export async function lweOptionsFor(
     offsetY: wallpaper.offsetY,
     disableParallax: wallpaper.disableParallax ?? false,
     expandCanvas: wallpaper.expandCanvas ?? false,
+    repairAssets: wallpaper.repairAssets ?? false,
     cornerColor: wallpaper.cornerColor,
     imageAdjustments: wallpaper.imageAdjustments,
     speed: wallpaper.playbackSpeed,

+ 89 - 0
src/main/utils/fixtures/compositors/hypr-monitors-all-one-disabled.json

@@ -0,0 +1,89 @@
+[{
+    "id": 0,
+    "name": "HEADLESS-1",
+    "description": "",
+    "make": "",
+    "model": "",
+    "serial": "",
+    "width": 1920,
+    "height": 1080,
+    "physicalWidth": 0,
+    "physicalHeight": 0,
+    "refreshRate": 60.00000,
+    "x": 0,
+    "y": 0,
+    "activeWorkspace": {
+        "id": 1,
+        "name": "1"
+    },
+    "specialWorkspace": {
+        "id": 0,
+        "name": ""
+    },
+    "reserved": [0, 0, 0, 0],
+    "scale": 1,
+    "transform": 0,
+    "focused": true,
+    "dpmsStatus": true,
+    "vrr": false,
+    "solitary": "0",
+    "solitaryBlockedBy": ["NOTIFICATION","WINDOWED","CANDIDATE"],
+    "activelyTearing": false,
+    "tearingBlockedBy": ["NOT_TORN","USER","SUPPORT","CANDIDATE"],
+    "directScanoutTo": "0",
+    "directScanoutBlockedBy": ["USER","SW","CANDIDATE"],
+    "disabled": false,
+    "currentFormat": "XRGB8888",
+    "mirrorOf": "none",
+    "availableModes": ["1920x1080@60.00Hz"],
+    "colorManagementPreset": "srgb",
+    "sdrBrightness": 1,
+    "sdrSaturation": 1,
+    "sdrMinLuminance": 0.2,
+    "sdrMaxLuminance": 80,
+    "hardwareCursorsInUse": true
+},{
+    "id": 1,
+    "name": "HEADLESS-2",
+    "description": "",
+    "make": "",
+    "model": "",
+    "serial": "",
+    "width": 1920,
+    "height": 1080,
+    "physicalWidth": 0,
+    "physicalHeight": 0,
+    "refreshRate": 60.00000,
+    "x": 1920,
+    "y": 0,
+    "activeWorkspace": {
+        "id": 0,
+        "name": ""
+    },
+    "specialWorkspace": {
+        "id": 0,
+        "name": ""
+    },
+    "reserved": [0, 0, 0, 0],
+    "scale": 1,
+    "transform": 0,
+    "focused": false,
+    "dpmsStatus": true,
+    "vrr": false,
+    "solitary": "0",
+    "solitaryBlockedBy": ["WORKSPACE"],
+    "activelyTearing": false,
+    "tearingBlockedBy": ["NOT_TORN","USER","SUPPORT","CANDIDATE"],
+    "directScanoutTo": "0",
+    "directScanoutBlockedBy": ["USER","SW","CANDIDATE"],
+    "disabled": true,
+    "currentFormat": "XRGB8888",
+    "mirrorOf": "none",
+    "availableModes": ["1920x1080@60.00Hz"],
+    "colorManagementPreset": "srgb",
+    "sdrBrightness": 1,
+    "sdrSaturation": 1,
+    "sdrMinLuminance": 0.2,
+    "sdrMaxLuminance": 80,
+    "hardwareCursorsInUse": true
+}]

+ 45 - 0
src/main/utils/fixtures/compositors/hypr-monitors-one-disabled.json

@@ -0,0 +1,45 @@
+[{
+    "id": 0,
+    "name": "HEADLESS-1",
+    "description": "",
+    "make": "",
+    "model": "",
+    "serial": "",
+    "width": 1920,
+    "height": 1080,
+    "physicalWidth": 0,
+    "physicalHeight": 0,
+    "refreshRate": 60.00000,
+    "x": 0,
+    "y": 0,
+    "activeWorkspace": {
+        "id": 1,
+        "name": "1"
+    },
+    "specialWorkspace": {
+        "id": 0,
+        "name": ""
+    },
+    "reserved": [0, 0, 0, 0],
+    "scale": 1,
+    "transform": 0,
+    "focused": true,
+    "dpmsStatus": true,
+    "vrr": false,
+    "solitary": "0",
+    "solitaryBlockedBy": ["NOTIFICATION","WINDOWED","CANDIDATE"],
+    "activelyTearing": false,
+    "tearingBlockedBy": ["NOT_TORN","USER","SUPPORT","CANDIDATE"],
+    "directScanoutTo": "0",
+    "directScanoutBlockedBy": ["USER","SW","CANDIDATE"],
+    "disabled": false,
+    "currentFormat": "XRGB8888",
+    "mirrorOf": "none",
+    "availableModes": ["1920x1080@60.00Hz"],
+    "colorManagementPreset": "srgb",
+    "sdrBrightness": 1,
+    "sdrSaturation": 1,
+    "sdrMinLuminance": 0.2,
+    "sdrMaxLuminance": 80,
+    "hardwareCursorsInUse": true
+}]

+ 89 - 0
src/main/utils/fixtures/compositors/hypr-monitors.json

@@ -0,0 +1,89 @@
+[{
+    "id": 0,
+    "name": "HEADLESS-1",
+    "description": "",
+    "make": "",
+    "model": "",
+    "serial": "",
+    "width": 1920,
+    "height": 1080,
+    "physicalWidth": 0,
+    "physicalHeight": 0,
+    "refreshRate": 60.00000,
+    "x": 0,
+    "y": 0,
+    "activeWorkspace": {
+        "id": 1,
+        "name": "1"
+    },
+    "specialWorkspace": {
+        "id": 0,
+        "name": ""
+    },
+    "reserved": [0, 0, 0, 0],
+    "scale": 1,
+    "transform": 0,
+    "focused": true,
+    "dpmsStatus": true,
+    "vrr": false,
+    "solitary": "0",
+    "solitaryBlockedBy": ["NOTIFICATION","WINDOWED","CANDIDATE"],
+    "activelyTearing": false,
+    "tearingBlockedBy": ["NOT_TORN","USER","SUPPORT","CANDIDATE"],
+    "directScanoutTo": "0",
+    "directScanoutBlockedBy": ["USER","SW","CANDIDATE"],
+    "disabled": false,
+    "currentFormat": "XRGB8888",
+    "mirrorOf": "none",
+    "availableModes": ["1920x1080@60.00Hz"],
+    "colorManagementPreset": "srgb",
+    "sdrBrightness": 1,
+    "sdrSaturation": 1,
+    "sdrMinLuminance": 0.2,
+    "sdrMaxLuminance": 80,
+    "hardwareCursorsInUse": true
+},{
+    "id": 1,
+    "name": "HEADLESS-2",
+    "description": "",
+    "make": "",
+    "model": "",
+    "serial": "",
+    "width": 1920,
+    "height": 1080,
+    "physicalWidth": 0,
+    "physicalHeight": 0,
+    "refreshRate": 60.00000,
+    "x": 1920,
+    "y": 0,
+    "activeWorkspace": {
+        "id": 2,
+        "name": "2"
+    },
+    "specialWorkspace": {
+        "id": 0,
+        "name": ""
+    },
+    "reserved": [0, 0, 0, 0],
+    "scale": 1,
+    "transform": 0,
+    "focused": false,
+    "dpmsStatus": true,
+    "vrr": false,
+    "solitary": "0",
+    "solitaryBlockedBy": ["NOTIFICATION","WINDOWED","CANDIDATE"],
+    "activelyTearing": false,
+    "tearingBlockedBy": ["NOT_TORN","USER","SUPPORT","CANDIDATE"],
+    "directScanoutTo": "0",
+    "directScanoutBlockedBy": ["USER","SW","CANDIDATE"],
+    "disabled": false,
+    "currentFormat": "XRGB8888",
+    "mirrorOf": "none",
+    "availableModes": ["1920x1080@60.00Hz"],
+    "colorManagementPreset": "srgb",
+    "sdrBrightness": 1,
+    "sdrSaturation": 1,
+    "sdrMinLuminance": 0.2,
+    "sdrMaxLuminance": 80,
+    "hardwareCursorsInUse": true
+}]

+ 1 - 0
src/main/utils/fixtures/compositors/niri-outputs.json

@@ -0,0 +1 @@
+{"winit":{"name":"winit","make":"Smithay","model":"Winit","serial":null,"physical_size":null,"modes":[{"width":1920,"height":1080,"refresh_rate":60000,"is_preferred":true}],"current_mode":0,"is_custom_mode":true,"vrr_supported":false,"vrr_enabled":false,"logical":{"x":0,"y":0,"width":1920,"height":1080,"scale":1.0,"transform":"Flipped180"}}}

+ 101 - 0
src/main/utils/fixtures/compositors/sway-outputs-one-disabled.json

@@ -0,0 +1,101 @@
+[
+  {
+    "id": 3,
+    "type": "output",
+    "orientation": "none",
+    "percent": 1.0,
+    "urgent": false,
+    "marks": [],
+    "layout": "output",
+    "border": "none",
+    "current_border_width": 0,
+    "rect": {
+      "x": 0,
+      "y": 0,
+      "width": 1920,
+      "height": 1080
+    },
+    "deco_rect": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "window_rect": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "geometry": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "name": "HEADLESS-1",
+    "window": null,
+    "nodes": [],
+    "floating_nodes": [],
+    "focus": [
+      6
+    ],
+    "fullscreen_mode": 0,
+    "sticky": false,
+    "floating": null,
+    "scratchpad_state": null,
+    "primary": false,
+    "make": "Unknown",
+    "model": "Unknown",
+    "serial": "Unknown",
+    "modes": [],
+    "features": {
+      "adaptive_sync": false,
+      "hdr": false
+    },
+    "non_desktop": false,
+    "active": true,
+    "dpms": true,
+    "power": true,
+    "scale": 1.0,
+    "scale_filter": "nearest",
+    "transform": "normal",
+    "adaptive_sync_status": "disabled",
+    "current_workspace": "2",
+    "current_mode": {
+      "width": 1920,
+      "height": 1080,
+      "refresh": 0
+    },
+    "max_render_time": 0,
+    "allow_tearing": false,
+    "hdr": false,
+    "focused": true,
+    "subpixel_hinting": "unknown"
+  },
+  {
+    "primary": false,
+    "make": "Unknown",
+    "model": "Unknown",
+    "serial": "Unknown",
+    "modes": [],
+    "features": {
+      "adaptive_sync": false,
+      "hdr": false
+    },
+    "non_desktop": false,
+    "type": "output",
+    "name": "HEADLESS-2",
+    "active": false,
+    "dpms": false,
+    "power": false,
+    "current_workspace": null,
+    "rect": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "percent": null
+  }
+]

+ 150 - 0
src/main/utils/fixtures/compositors/sway-outputs.json

@@ -0,0 +1,150 @@
+[
+  {
+    "id": 4,
+    "type": "output",
+    "orientation": "none",
+    "percent": 0.5,
+    "urgent": false,
+    "marks": [],
+    "layout": "output",
+    "border": "none",
+    "current_border_width": 0,
+    "rect": {
+      "x": 0,
+      "y": 0,
+      "width": 1920,
+      "height": 1080
+    },
+    "deco_rect": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "window_rect": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "geometry": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "name": "HEADLESS-2",
+    "window": null,
+    "nodes": [],
+    "floating_nodes": [],
+    "focus": [
+      5
+    ],
+    "fullscreen_mode": 0,
+    "sticky": false,
+    "floating": null,
+    "scratchpad_state": null,
+    "primary": false,
+    "make": "Unknown",
+    "model": "Unknown",
+    "serial": "Unknown",
+    "modes": [],
+    "features": {
+      "adaptive_sync": false,
+      "hdr": false
+    },
+    "non_desktop": false,
+    "active": true,
+    "dpms": true,
+    "power": true,
+    "scale": 1.0,
+    "scale_filter": "nearest",
+    "transform": "normal",
+    "adaptive_sync_status": "disabled",
+    "current_workspace": "1",
+    "current_mode": {
+      "width": 1920,
+      "height": 1080,
+      "refresh": 0
+    },
+    "max_render_time": 0,
+    "allow_tearing": false,
+    "hdr": false,
+    "focused": true,
+    "subpixel_hinting": "unknown"
+  },
+  {
+    "id": 3,
+    "type": "output",
+    "orientation": "none",
+    "percent": 0.5,
+    "urgent": false,
+    "marks": [],
+    "layout": "output",
+    "border": "none",
+    "current_border_width": 0,
+    "rect": {
+      "x": 1920,
+      "y": 0,
+      "width": 1920,
+      "height": 1080
+    },
+    "deco_rect": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "window_rect": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "geometry": {
+      "x": 0,
+      "y": 0,
+      "width": 0,
+      "height": 0
+    },
+    "name": "HEADLESS-1",
+    "window": null,
+    "nodes": [],
+    "floating_nodes": [],
+    "focus": [
+      6
+    ],
+    "fullscreen_mode": 0,
+    "sticky": false,
+    "floating": null,
+    "scratchpad_state": null,
+    "primary": false,
+    "make": "Unknown",
+    "model": "Unknown",
+    "serial": "Unknown",
+    "modes": [],
+    "features": {
+      "adaptive_sync": false,
+      "hdr": false
+    },
+    "non_desktop": false,
+    "active": true,
+    "dpms": true,
+    "power": true,
+    "scale": 1.0,
+    "scale_filter": "nearest",
+    "transform": "normal",
+    "adaptive_sync_status": "disabled",
+    "current_workspace": "2",
+    "current_mode": {
+      "width": 1920,
+      "height": 1080,
+      "refresh": 0
+    },
+    "max_render_time": 0,
+    "allow_tearing": false,
+    "hdr": false,
+    "focused": false,
+    "subpixel_hinting": "unknown"
+  }
+]

+ 189 - 0
src/main/utils/platform.test.ts

@@ -0,0 +1,189 @@
+import { readFileSync } from 'fs'
+import { join } from 'path'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+const execSync = vi.fn<(command: string) => string>()
+vi.mock('child_process', () => ({ execSync: (command: string) => execSync(command) }))
+
+const {
+  getConnectedScreens,
+  hasStatusNotifierHost,
+  parseHyprctlMonitors,
+  parseNameHasOwner,
+  parseNiriOutputs,
+  parseSwayOutputs
+} = await import('./platform')
+
+function answerCommands(answers: Record<string, string>): void {
+  execSync.mockImplementation((command: string) => {
+    const known = Object.keys(answers).find((name) => command.includes(name))
+    if (!known) throw new Error(`${command}: not found`)
+    return answers[known]
+  })
+}
+
+function waylandSession(markers: Record<string, string>): void {
+  vi.stubEnv('WAYLAND_DISPLAY', 'wayland-1')
+  for (const marker of ['HYPRLAND_INSTANCE_SIGNATURE', 'SWAYSOCK', 'NIRI_SOCKET']) {
+    vi.stubEnv(marker, markers[marker] ?? '')
+  }
+}
+
+afterEach(() => {
+  vi.unstubAllEnvs()
+  execSync.mockReset()
+})
+
+describe('parseHyprctlMonitors', () => {
+  it('lists the monitor names and skips disabled ones', () => {
+    const output = JSON.stringify([
+      { id: 0, name: 'DP-1', description: 'Dell U2720Q', width: 3840, height: 2160, disabled: false },
+      { id: 1, name: 'HDMI-A-1', width: 1920, height: 1080 },
+      { id: 2, name: 'eDP-1', disabled: true }
+    ])
+    expect(parseHyprctlMonitors(output)).toEqual(['DP-1', 'HDMI-A-1'])
+  })
+
+  it('returns nothing for output that is not a monitor list', () => {
+    expect(parseHyprctlMonitors('')).toEqual([])
+    expect(parseHyprctlMonitors('Couldn\'t connect to the socket')).toEqual([])
+    expect(parseHyprctlMonitors('{"name":"DP-1"}')).toEqual([])
+    expect(parseHyprctlMonitors('[null, {"id": 3}]')).toEqual([])
+  })
+})
+
+describe('parseSwayOutputs', () => {
+  it('lists the output names and skips inactive ones', () => {
+    const output = JSON.stringify([
+      { name: 'DP-2', active: true, make: 'Dell', rect: { x: 0, y: 0, width: 2560, height: 1440 } },
+      { name: 'HDMI-A-1', active: false },
+      { name: 'eDP-1', active: true }
+    ])
+    expect(parseSwayOutputs(output)).toEqual(['DP-2', 'eDP-1'])
+  })
+
+  it('returns nothing for output that is not an output list', () => {
+    expect(parseSwayOutputs('')).toEqual([])
+    expect(parseSwayOutputs('{"success":false}')).toEqual([])
+  })
+})
+
+describe('parseNiriOutputs', () => {
+  it('takes the names from the keys and skips outputs without a current mode', () => {
+    const output = JSON.stringify({
+      'eDP-1': { name: 'eDP-1', make: 'BOE', current_mode: 0, logical: { x: 0, y: 0, width: 1920, height: 1080 } },
+      'DP-3': { name: 'DP-3', current_mode: 2, logical: { x: 1920, y: 0, width: 2560, height: 1440 } },
+      'HDMI-A-1': { name: 'HDMI-A-1', current_mode: null, logical: null }
+    })
+    expect(parseNiriOutputs(output)).toEqual(['eDP-1', 'DP-3'])
+  })
+
+  it('returns nothing for output that is not an output map', () => {
+    expect(parseNiriOutputs('')).toEqual([])
+    expect(parseNiriOutputs('[]')).toEqual([])
+    expect(parseNiriOutputs('null')).toEqual([])
+    expect(parseNiriOutputs('{}')).toEqual([])
+  })
+})
+
+// captured from headless sessions: sway 1.12, Hyprland 0.56.2 and niri 26.04
+function captured(name: string): string {
+  return readFileSync(join(__dirname, 'fixtures', 'compositors', name), 'utf8')
+}
+
+describe('output lists the compositors really print', () => {
+  it('sway lists every output, an inactive one is switched off', () => {
+    expect(parseSwayOutputs(captured('sway-outputs.json')).sort()).toEqual(['HEADLESS-1', 'HEADLESS-2'])
+    expect(parseSwayOutputs(captured('sway-outputs-one-disabled.json'))).toEqual(['HEADLESS-1'])
+  })
+
+  it('hyprctl leaves a disabled monitor out of `monitors` and marks it in `monitors all`', () => {
+    expect(parseHyprctlMonitors(captured('hypr-monitors.json'))).toEqual(['HEADLESS-1', 'HEADLESS-2'])
+    expect(parseHyprctlMonitors(captured('hypr-monitors-one-disabled.json'))).toEqual(['HEADLESS-1'])
+    expect(parseHyprctlMonitors(captured('hypr-monitors-all-one-disabled.json'))).toEqual(['HEADLESS-1'])
+  })
+
+  it('niri keys its outputs by name', () => {
+    expect(parseNiriOutputs(captured('niri-outputs.json'))).toEqual(['winit'])
+  })
+})
+
+describe('parseNameHasOwner', () => {
+  it('reads busctl and gdbus answers', () => {
+    expect(parseNameHasOwner('b true\n')).toBe(true)
+    expect(parseNameHasOwner('b false\n')).toBe(false)
+    expect(parseNameHasOwner('(true,)\n')).toBe(true)
+    expect(parseNameHasOwner('(false,)\n')).toBe(false)
+  })
+
+  it('gives null for anything else', () => {
+    expect(parseNameHasOwner('')).toBeNull()
+    expect(parseNameHasOwner('Failed to connect to bus')).toBeNull()
+  })
+})
+
+describe.skipIf(process.platform !== 'linux')('getConnectedScreens', () => {
+  it('asks hyprctl on Hyprland, before wlr-randr', () => {
+    waylandSession({ HYPRLAND_INSTANCE_SIGNATURE: 'abc_123' })
+    answerCommands({
+      'hyprctl monitors -j': '[{"name":"DP-1"},{"name":"HDMI-A-1","disabled":true}]',
+      'wlr-randr': 'eDP-1 "Some panel"\n  Enabled: yes\n'
+    })
+    expect(getConnectedScreens()).toEqual(['DP-1'])
+  })
+
+  it('asks swaymsg on sway and niri msg on niri', () => {
+    waylandSession({ SWAYSOCK: '/run/user/1000/sway-ipc.sock' })
+    answerCommands({ 'swaymsg -t get_outputs -r': '[{"name":"DP-2","active":true}]' })
+    expect(getConnectedScreens()).toEqual(['DP-2'])
+
+    waylandSession({ NIRI_SOCKET: '/run/user/1000/niri.sock' })
+    answerCommands({ 'niri msg --json outputs': '{"eDP-1":{"name":"eDP-1","current_mode":0}}' })
+    expect(getConnectedScreens()).toEqual(['eDP-1'])
+  })
+
+  it('falls back to wlr-randr when the compositor query fails or lists nothing', () => {
+    waylandSession({ HYPRLAND_INSTANCE_SIGNATURE: 'abc_123' })
+    answerCommands({ 'wlr-randr': 'DP-1 "Dell"\n  Enabled: yes\nHDMI-A-1 "LG"\n  Enabled: yes\n' })
+    expect(getConnectedScreens()).toEqual(['DP-1', 'HDMI-A-1'])
+
+    answerCommands({ 'hyprctl monitors -j': '[]', 'wlr-randr': 'DP-1 "Dell"\n' })
+    expect(getConnectedScreens()).toEqual(['DP-1'])
+  })
+
+  it('leaves the compositor tools alone without their marker', () => {
+    waylandSession({})
+    answerCommands({ 'wlr-randr': 'DP-1 "Dell"\n' })
+    expect(getConnectedScreens()).toEqual(['DP-1'])
+    expect(execSync).toHaveBeenCalledTimes(1)
+  })
+})
+
+describe.skipIf(process.platform !== 'linux')('hasStatusNotifierHost', () => {
+  it('follows the owner of the watcher name', () => {
+    answerCommands({ busctl: 'b true\n' })
+    expect(hasStatusNotifierHost(0)).toBe(true)
+    answerCommands({ busctl: 'b false\n' })
+    expect(hasStatusNotifierHost(0)).toBe(false)
+  })
+
+  it('tries gdbus when busctl is missing', () => {
+    answerCommands({ gdbus: '(false,)\n' })
+    expect(hasStatusNotifierHost(0)).toBe(false)
+  })
+
+  it('assumes a host when neither tool can answer', () => {
+    answerCommands({})
+    expect(hasStatusNotifierHost(0)).toBe(true)
+    answerCommands({ busctl: 'garbled' })
+    expect(hasStatusNotifierHost(0)).toBe(true)
+  })
+
+  it('reuses an answer for a short while', () => {
+    answerCommands({ busctl: 'b false\n' })
+    expect(hasStatusNotifierHost(0)).toBe(false)
+    answerCommands({ busctl: 'b true\n' })
+    expect(hasStatusNotifierHost()).toBe(false)
+    expect(hasStatusNotifierHost(0)).toBe(true)
+  })
+})

+ 97 - 12
src/main/utils/platform.ts

@@ -1,8 +1,9 @@
 import { execSync } from 'child_process'
+import { parseDesktopEnv, type DesktopEnvironment } from '@shared/desktop'
 import { hostShell } from './flatpak'
 
 export type DisplayServer = 'wayland' | 'x11' | 'unknown'
-export type DesktopEnvironment = 'gnome' | 'kde' | 'hyprland' | 'sway' | 'other'
+export type { DesktopEnvironment }
 
 export function detectDisplayServer(): DisplayServer {
   if (process.platform === 'win32' || process.platform === 'darwin') return 'unknown'
@@ -13,12 +14,12 @@ export function detectDisplayServer(): DisplayServer {
 
 export function detectDesktopEnv(): DesktopEnvironment {
   if (process.platform === 'win32' || process.platform === 'darwin') return 'other'
-  const xdg = (process.env.XDG_CURRENT_DESKTOP ?? '').toLowerCase()
-  if (xdg.includes('gnome')) return 'gnome'
-  if (xdg.includes('kde')) return 'kde'
-  if (xdg.includes('hyprland')) return 'hyprland'
-  if (xdg.includes('sway')) return 'sway'
-  return 'other'
+  return parseDesktopEnv(process.env.XDG_CURRENT_DESKTOP, process.env)
+}
+
+/** Electron often runs under XWayland without WAYLAND_DISPLAY, so the session type counts too. */
+export function isWaylandSession(): boolean {
+  return !!process.env.WAYLAND_DISPLAY || process.env.XDG_SESSION_TYPE === 'wayland'
 }
 
 /**
@@ -44,16 +45,63 @@ export function getXdgRuntimeDir(): string {
   return process.env.XDG_RUNTIME_DIR || `/run/user/${process.getuid?.() ?? 1000}`
 }
 
+function parseJson(output: string): unknown {
+  try {
+    return JSON.parse(output)
+  } catch {
+    return null
+  }
+}
+
+/** `hyprctl monitors -j`: an array of monitors, a disabled one has no output to draw on */
+export function parseHyprctlMonitors(output: string): string[] {
+  const monitors = parseJson(output)
+  if (!Array.isArray(monitors)) return []
+  return monitors
+    .filter(m => m && typeof m.name === 'string' && m.name && m.disabled !== true)
+    .map(m => m.name)
+}
+
+/** `swaymsg -t get_outputs -r`: an array of outputs, inactive ones are switched off */
+export function parseSwayOutputs(output: string): string[] {
+  const outputs = parseJson(output)
+  if (!Array.isArray(outputs)) return []
+  return outputs
+    .filter(o => o && typeof o.name === 'string' && o.name && o.active !== false)
+    .map(o => o.name)
+}
+
+/** `niri msg --json outputs`: an object keyed by output name, a disabled one has no current mode */
+export function parseNiriOutputs(output: string): string[] {
+  const outputs = parseJson(output)
+  if (!outputs || typeof outputs !== 'object' || Array.isArray(outputs)) return []
+  return Object.entries(outputs)
+    .filter(([, o]) => (o as { current_mode?: unknown } | null)?.current_mode !== null)
+    .map(([name]) => name)
+}
+
+const COMPOSITOR_QUERIES: { marker: string; command: string; parse: (output: string) => string[] }[] = [
+  { marker: 'HYPRLAND_INSTANCE_SIGNATURE', command: 'hyprctl monitors -j', parse: parseHyprctlMonitors },
+  { marker: 'SWAYSOCK', command: 'swaymsg -t get_outputs -r', parse: parseSwayOutputs },
+  { marker: 'NIRI_SOCKET', command: 'niri msg --json outputs', parse: parseNiriOutputs }
+]
+
 /** Detect connected screen/output names for use with linux-wallpaperengine --screen-root. */
 export function getConnectedScreens(): string[] {
   if (process.platform !== 'linux') return []
 
-  // Electron often runs under XWayland, so WAYLAND_DISPLAY may be unset even on Wayland sessions.
-  // Check XDG_SESSION_TYPE as well to detect the real session type.
-  const isWayland = !!process.env.WAYLAND_DISPLAY || process.env.XDG_SESSION_TYPE === 'wayland'
-
   // On Wayland, we MUST use native Wayland output names (not xrandr/XWayland names)
-  if (isWayland) {
+  if (isWaylandSession()) {
+    // the compositor's own IPC knows which outputs are enabled
+    for (const { marker, command, parse } of COMPOSITOR_QUERIES) {
+      if (!process.env[marker]) continue
+      try {
+        const output = execSync(hostShell(`${command} 2>/dev/null`), { encoding: 'utf8', timeout: 5000 })
+        const screens = parse(output)
+        if (screens.length > 0) return screens
+      } catch { /* not available */ }
+    }
+
     // wlr-randr (wlroots compositors: hyprland, sway, etc.)
     try {
       const output = execSync(hostShell('wlr-randr 2>/dev/null'), { encoding: 'utf8', timeout: 5000 })
@@ -105,6 +153,43 @@ export function getConnectedScreens(): string[] {
   return []
 }
 
+/** Answer of a NameHasOwner call, from busctl (`b true`) or gdbus (`(true,)`), null when it is neither */
+export function parseNameHasOwner(output: string): boolean | null {
+  const m = output.trim().match(/^(?:b\s+|\(\s*)(true|false)\b/)
+  return m ? m[1] === 'true' : null
+}
+
+const NAME_HAS_OWNER_COMMANDS = [
+  'busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus NameHasOwner s org.kde.StatusNotifierWatcher',
+  'gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.NameHasOwner org.kde.StatusNotifierWatcher'
+]
+
+const TRAY_HOST_CACHE_MS = 15_000
+let trayHostCache: { value: boolean; at: number } | null = null
+
+/**
+ * Whether something on the session bus can show a StatusNotifier icon. Without one a window hidden
+ * to the tray has no way back. Assumes yes when neither busctl nor gdbus can tell.
+ */
+export function hasStatusNotifierHost(maxAgeMs = TRAY_HOST_CACHE_MS): boolean {
+  if (process.platform !== 'linux') return true
+  if (trayHostCache && Date.now() - trayHostCache.at < maxAgeMs) return trayHostCache.value
+
+  let value = true
+  for (const command of NAME_HAS_OWNER_COMMANDS) {
+    try {
+      const output = execSync(hostShell(`${command} 2>/dev/null`), { encoding: 'utf8', timeout: 2000 })
+      const owned = parseNameHasOwner(output)
+      if (owned !== null) {
+        value = owned
+        break
+      }
+    } catch { /* tool missing or no session bus */ }
+  }
+  trayHostCache = { value, at: Date.now() }
+  return value
+}
+
 // Cache results so we only call which/where once per session
 const commandCache = new Map<string, boolean>()
 

+ 4 - 0
src/preload/index.ts

@@ -130,6 +130,7 @@ const api = {
       autoUnsubscribeAfterBackup: boolean
       trayEnabled: boolean
       autostartSupported: boolean
+      autostartCompositorLine: string | null
       autostartEnabled: boolean
       autostartMinimized: boolean
       autostartPlaylistId: string | null
@@ -326,6 +327,7 @@ const api = {
       offsetY?: number
       disableParallax?: boolean
       expandCanvas?: boolean
+      repairAssets?: boolean
       cornerColor?: string
       imageAdjustments?: ImageAdjustments
       speed?: number
@@ -342,6 +344,8 @@ const api = {
       ipcRenderer.invoke(IpcChannels.LWE_LIST_PROPERTIES, wallpaperPath),
     listScreens: (): Promise<string[]> =>
       ipcRenderer.invoke(IpcChannels.LWE_LIST_SCREENS),
+    inputFiles: (): Promise<{ screen: string; path: string }[]> =>
+      ipcRenderer.invoke(IpcChannels.LWE_INPUT_FILES),
     videoDuration: (wallpaperPath: string, projectFile?: string): Promise<number | null> =>
       ipcRenderer.invoke(IpcChannels.LWE_VIDEO_DURATION, wallpaperPath, projectFile),
     listAudioObjects: (wallpaperPath: string): Promise<LweAudioObject[]> =>

+ 37 - 0
src/renderer/src/components/common/CopyField.tsx

@@ -0,0 +1,37 @@
+import { useState } from 'react'
+import { Check, Copy } from 'lucide-react'
+
+interface Props {
+  text: string
+  label?: string
+}
+
+export default function CopyField({ text, label }: Props) {
+  const [copied, setCopied] = useState(false)
+
+  async function copy() {
+    try {
+      await navigator.clipboard.writeText(text)
+    } catch {
+      return
+    }
+    setCopied(true)
+    setTimeout(() => setCopied(false), 1500)
+  }
+
+  return (
+    <div className="flex items-center gap-2">
+      {label && <span className="w-24 shrink-0 truncate text-xs text-gray-500">{label}</span>}
+      <code className="min-w-0 flex-1 truncate rounded bg-white/5 px-2 py-1 text-xs text-gray-300" title={text}>
+        {text}
+      </code>
+      <button
+        onClick={copy}
+        title="Copy"
+        className="shrink-0 rounded p-1.5 text-gray-500 hover:bg-white/5 hover:text-gray-200"
+      >
+        {copied ? <Check size={13} /> : <Copy size={13} />}
+      </button>
+    </div>
+  )
+}

+ 40 - 0
src/renderer/src/components/common/DetailSidebar.tsx

@@ -30,6 +30,7 @@ import {
   Move,
   Move3d,
   Expand,
+  Wrench,
   Palette,
   Gauge,
   Zap,
@@ -581,6 +582,7 @@ export default function DetailSidebar({
             offsetY: patch.offsetY,
             disableParallax: patch.disableParallax,
             expandCanvas: patch.expandCanvas,
+            repairAssets: patch.repairAssets,
             cornerColor: patch.cornerColor,
             imageAdjustments: patch.imageAdjustments,
             speed: patch.playbackSpeed,
@@ -857,6 +859,19 @@ export default function DetailSidebar({
     }
   }
 
+  const [isCommittingRepairAssets, setIsCommittingRepairAssets] = useState(false)
+  const repairAssets = libraryMeta?.repairAssets ?? false
+
+  async function toggleRepairAssets() {
+    if (isCommittingRepairAssets) return
+    setIsCommittingRepairAssets(true)
+    try {
+      await persistAndMaybeRelaunch({ repairAssets: !repairAssets })
+    } finally {
+      setIsCommittingRepairAssets(false)
+    }
+  }
+
   const [customArgsDraft, setCustomArgsDraft] = useState<string | null>(null)
   const [isCommittingCustomArgs, setIsCommittingCustomArgs] = useState(false)
   const customArgs = customArgsDraft ?? libraryMeta?.customArgs ?? ''
@@ -1435,6 +1450,31 @@ export default function DetailSidebar({
                 <ToggleLeft size={14} className="text-gray-600" />
               )}
             </button>
+            <button
+              onClick={toggleRepairAssets}
+              disabled={isCommittingRepairAssets}
+              title="Loads files the way the wallpaper's author meant where current Wallpaper Engine drops them, e.g. an image whose texture has no name"
+              className="mt-1.5 flex w-full items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-gray-500 hover:text-gray-300 disabled:opacity-40"
+            >
+              <Wrench size={12} />
+              <span className="flex-1 text-left">Repair broken assets</span>
+              {isActive && (
+                <span className="rounded-full bg-green-600/30 px-1.5 normal-case text-green-300">
+                  live
+                </span>
+              )}
+              {isCommittingRepairAssets ? (
+                <Loader2 size={14} className="animate-spin text-gray-500" />
+              ) : repairAssets ? (
+                <ToggleRight size={14} className="text-indigo-400" />
+              ) : (
+                <ToggleLeft size={14} className="text-gray-600" />
+              )}
+            </button>
+            <p className="mt-0.5 text-[11px] text-gray-600">
+              Might fix old wallpapers that show a blank or grey screen in current Wallpaper Engine but
+              worked in older versions. Off by default to match Wallpaper Engine.
+            </p>
           </div>
         )}
 

+ 37 - 6
src/renderer/src/components/settings/PerformanceSettings.tsx

@@ -2,8 +2,10 @@ import { useState } from 'react'
 import { useQuery, useQueryClient } from '@tanstack/react-query'
 import { Check, Plus, Save, Trash2 } from 'lucide-react'
 import type { EngineFlagPreset, EngineFlags, FullscreenPauseMode } from '@shared/types'
+import { isWlrootsStyle } from '@shared/desktop'
 import { BOOLEAN_FLAGS, CHOICE_FLAGS, FULLSCREEN_PAUSE_OPTIONS } from '../../constants/engineFlags'
 import { useConfig } from '../../hooks/queries'
+import CopyField from '../common/CopyField'
 
 interface Props {
   defaultFps: number | null
@@ -50,6 +52,13 @@ export default function PerformanceSettings({ defaultFps, onDefaultFpsChanged }:
     queryKey: ['environment'],
     queryFn: () => window.electronAPI.wallpaper.detectEnvironment()
   })
+  const desktopEnv = environment?.desktopEnv
+  const wlroots = !!desktopEnv && isWlrootsStyle(desktopEnv)
+  const { data: inputFiles = [] } = useQuery({
+    queryKey: ['input-files'],
+    queryFn: () => window.electronAPI.lwe.inputFiles(),
+    enabled: wlroots
+  })
   const [newName, setNewName] = useState('')
   const [appliedId, setAppliedId] = useState<string | null>(null)
 
@@ -104,23 +113,45 @@ export default function PerformanceSettings({ defaultFps, onDefaultFpsChanged }:
             <span className="text-sm text-gray-300">{label}</span>
           </label>
         ))}
-        {environment?.desktopEnv === 'kde' && (
+        {(desktopEnv === 'kde' || wlroots) && (
           <div>
             <label className="flex cursor-pointer items-center gap-3">
               <Toggle
                 on={!!flags.kdeBackgroundLayer}
                 onClick={() => saveFlags({ ...flags, kdeBackgroundLayer: !flags.kdeBackgroundLayer })}
               />
-              <span className="text-sm text-gray-300">Use the KDE background layer</span>
+              <span className="text-sm text-gray-300">Use the background layer</span>
             </label>
             <p className="ml-12 mt-1 text-xs text-gray-600">
-              Older versions always did this on KDE. It puts the wallpaper in the same layer as Plasma's own
-              desktop, and whichever of the two shows up last is drawn on top. At login Plasma's desktop often
-              starts after the wallpaper and hides it, so leave this off unless the default layer causes problems
-              for you, e.g. with "keep below others" windows.
+              Draws the wallpaper in the compositor's background layer instead of the bottom one. Some compositors
+              (niri) need it.
+              {desktopEnv === 'kde' && (
+                <>
+                  {' '}
+                  Older versions always did this on KDE. It is the layer of Plasma's own desktop, and whichever of
+                  the two shows up last is drawn on top. At login Plasma's desktop often starts after the wallpaper
+                  and hides it, so leave this off unless the default layer causes problems for you, e.g. with "keep
+                  below others" windows.
+                </>
+              )}
             </p>
           </div>
         )}
+        {wlroots && inputFiles.length > 0 && (
+          <div>
+            <p className="text-sm text-gray-300">Click forwarding</p>
+            <p className="mt-1 text-xs text-gray-600">
+              Lets a desktop shell or compositor binding pass the left mouse button on when something covers the
+              wallpaper: it writes {'{"leftDown":true}'} to the file of the screen while the button is held, and the
+              engine ignores the file once it is older than 2 seconds.
+            </p>
+            <div className="mt-2 space-y-1">
+              {inputFiles.map((file) => (
+                <CopyField key={file.screen} label={file.screen === '*' ? 'All screens' : file.screen} text={file.path} />
+              ))}
+            </div>
+          </div>
+        )}
         <label className="flex items-center gap-3 text-sm text-gray-300">
           <span>Fullscreen apps</span>
           <select

+ 12 - 0
src/renderer/src/components/settings/SettingsView.tsx

@@ -7,6 +7,7 @@ import DisplaySettings from './DisplaySettings'
 import VoteBorderSettings from './VoteBorderSettings'
 import LibraryFoldersSettings from './LibraryFoldersSettings'
 import ScheduleSettings from './ScheduleSettings'
+import CopyField from '../common/CopyField'
 
 const DISTRO_LABELS: Record<LinuxDistro, string> = {
   fedora: 'Fedora / Nobara / RHEL',
@@ -65,6 +66,7 @@ export default function SettingsView() {
   const [steamIdentity, setSteamIdentityState] = useState<SteamIdentity>('wallpaper-engine')
   const [steamIdentitySaved, setSteamIdentitySaved] = useState(false)
   const [autostartSupported, setAutostartSupported] = useState(false)
+  const [autostartCompositorLine, setAutostartCompositorLine] = useState<string | null>(null)
   const [autostartEnabled, setAutostartEnabledState] = useState(false)
   const [autostartMinimized, setAutostartMinimized] = useState(false)
   const [autostartPlaylistId, setAutostartPlaylistId] = useState<string | null>(null)
@@ -95,6 +97,7 @@ export default function SettingsView() {
       setKillLweOnQuit(cfg.killLweOnQuit)
       setSteamIdentityState(cfg.steamIdentity)
       setAutostartSupported(cfg.autostartSupported)
+      setAutostartCompositorLine(cfg.autostartCompositorLine)
       setAutostartEnabledState(cfg.autostartEnabled)
       setAutostartMinimized(cfg.autostartMinimized)
       setAutostartPlaylistId(cfg.autostartPlaylistId)
@@ -1078,6 +1081,15 @@ export default function SettingsView() {
                 Only available in a packaged build (AppImage/deb), not in development mode.
               </p>
             )}
+            {autostartCompositorLine && (
+              <div className="space-y-1.5">
+                <p className="text-xs text-gray-500">
+                  This compositor does not run ~/.config/autostart entries by itself (a session manager like uwsm
+                  does). To start WE Manager at login, add this line to its config:
+                </p>
+                <CopyField text={autostartCompositorLine} />
+              </div>
+            )}
 
             <label className="flex items-center gap-3 cursor-pointer pl-12">
               <button

+ 1 - 1
src/renderer/src/constants/engineFlags.ts

@@ -14,7 +14,7 @@ export const BOOLEAN_FLAGS: { key: BooleanFlag; label: string; hint: string }[]
   {
     key: 'hdr',
     label: 'HDR output',
-    hint: 'Sends HDR to monitors running in HDR mode (KDE Plasma with HDR enabled); HDR videos keep their highlights'
+    hint: 'Sends HDR to monitors running in HDR mode (Wayland compositors with color management, e.g. KDE Plasma with HDR enabled); HDR videos keep their highlights'
   }
 ]
 

+ 66 - 0
src/shared/desktop.test.ts

@@ -0,0 +1,66 @@
+import { describe, expect, it } from 'vitest'
+import { compositorAutostartLine, isWlrootsStyle, parseDesktopEnv } from './desktop'
+
+describe('parseDesktopEnv', () => {
+  it('knows the desktops by XDG_CURRENT_DESKTOP', () => {
+    expect(parseDesktopEnv('GNOME')).toBe('gnome')
+    expect(parseDesktopEnv('ubuntu:GNOME')).toBe('gnome')
+    expect(parseDesktopEnv('KDE')).toBe('kde')
+    expect(parseDesktopEnv('COSMIC')).toBe('cosmic')
+    expect(parseDesktopEnv('Hyprland')).toBe('hyprland')
+    expect(parseDesktopEnv('sway')).toBe('sway')
+    expect(parseDesktopEnv('niri')).toBe('niri')
+    expect(parseDesktopEnv('river')).toBe('river')
+    expect(parseDesktopEnv('labwc:wlroots')).toBe('labwc')
+    expect(parseDesktopEnv('Wayfire')).toBe('wayfire')
+    expect(parseDesktopEnv('X-Cinnamon')).toBe('other')
+    expect(parseDesktopEnv(undefined)).toBe('other')
+  })
+
+  it('falls back to the compositor sockets when the name is missing', () => {
+    expect(parseDesktopEnv(undefined, { HYPRLAND_INSTANCE_SIGNATURE: 'abc' })).toBe('hyprland')
+    expect(parseDesktopEnv('', { SWAYSOCK: '/run/user/1000/sway-ipc.sock' })).toBe('sway')
+    expect(parseDesktopEnv(undefined, { NIRI_SOCKET: '/run/user/1000/niri.sock' })).toBe('niri')
+    expect(parseDesktopEnv('KDE', { NIRI_SOCKET: '/run/user/1000/niri.sock' })).toBe('kde')
+    expect(parseDesktopEnv(undefined, { SWAYSOCK: '' })).toBe('other')
+  })
+})
+
+describe('isWlrootsStyle', () => {
+  it('covers the layer-shell compositors without a shell of their own', () => {
+    for (const env of ['hyprland', 'sway', 'niri', 'river', 'labwc', 'wayfire'] as const) {
+      expect(isWlrootsStyle(env)).toBe(true)
+    }
+    for (const env of ['gnome', 'kde', 'cosmic', 'other'] as const) {
+      expect(isWlrootsStyle(env)).toBe(false)
+    }
+  })
+})
+
+describe('compositorAutostartLine', () => {
+  const exe = '/opt/WE Manager/we-manager'
+
+  it('writes the line of each compositor config', () => {
+    expect(compositorAutostartLine('hyprland', '/usr/bin/we-manager')).toBe('exec-once = /usr/bin/we-manager --minimized')
+    expect(compositorAutostartLine('sway', '/usr/bin/we-manager')).toBe('exec /usr/bin/we-manager --minimized')
+    expect(compositorAutostartLine('niri', '/usr/bin/we-manager')).toBe(
+      'spawn-at-startup "/usr/bin/we-manager" "--minimized"'
+    )
+    expect(compositorAutostartLine('river', '/usr/bin/we-manager')).toBe('/usr/bin/we-manager --minimized')
+  })
+
+  it('quotes a path with spaces for the shell and for KDL', () => {
+    expect(compositorAutostartLine('hyprland', exe)).toBe(`exec-once = '/opt/WE Manager/we-manager' --minimized`)
+    expect(compositorAutostartLine('niri', exe)).toBe('spawn-at-startup "/opt/WE Manager/we-manager" "--minimized"')
+    expect(compositorAutostartLine('sway', `/home/it's/app.AppImage`)).toBe(
+      `exec '/home/it'\\''s/app.AppImage' --minimized`
+    )
+  })
+
+  it('has nothing for sessions that run the autostart entry themselves', () => {
+    expect(compositorAutostartLine('kde', '/usr/bin/we-manager')).toBeNull()
+    expect(compositorAutostartLine('gnome', '/usr/bin/we-manager')).toBeNull()
+    expect(compositorAutostartLine('cosmic', '/usr/bin/we-manager')).toBeNull()
+    expect(compositorAutostartLine('other', '/usr/bin/we-manager')).toBeNull()
+  })
+})

+ 63 - 0
src/shared/desktop.ts

@@ -0,0 +1,63 @@
+export type DesktopEnvironment =
+  | 'gnome'
+  | 'kde'
+  | 'cosmic'
+  | 'hyprland'
+  | 'sway'
+  | 'niri'
+  | 'river'
+  | 'labwc'
+  | 'wayfire'
+  | 'other'
+
+const WLROOTS_STYLE: DesktopEnvironment[] = ['hyprland', 'sway', 'niri', 'river', 'labwc', 'wayfire']
+
+/** Compositors that draw wallpapers through wlr-layer-shell and ship no desktop shell of their own */
+export function isWlrootsStyle(env: DesktopEnvironment): boolean {
+  return WLROOTS_STYLE.includes(env)
+}
+
+const BY_XDG_NAME: [string, DesktopEnvironment][] = [
+  ['gnome', 'gnome'],
+  ['kde', 'kde'],
+  ['cosmic', 'cosmic'],
+  ['hyprland', 'hyprland'],
+  ['sway', 'sway'],
+  ['niri', 'niri'],
+  ['river', 'river'],
+  ['labwc', 'labwc'],
+  ['wayfire', 'wayfire']
+]
+
+/** Falls back to the compositor sockets when XDG_CURRENT_DESKTOP is unset */
+export function parseDesktopEnv(
+  xdgCurrentDesktop: string | undefined,
+  env: Record<string, string | undefined> = {}
+): DesktopEnvironment {
+  const xdg = (xdgCurrentDesktop ?? '').toLowerCase()
+  for (const [name, desktop] of BY_XDG_NAME) {
+    if (xdg.includes(name)) return desktop
+  }
+  if (env.HYPRLAND_INSTANCE_SIGNATURE) return 'hyprland'
+  if (env.SWAYSOCK) return 'sway'
+  if (env.NIRI_SOCKET) return 'niri'
+  return 'other'
+}
+
+function shellWord(word: string): string {
+  return /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replace(/'/g, `'\\''`)}'`
+}
+
+function kdlString(text: string): string {
+  return `"${text.replace(/[\\"]/g, '\\$&')}"`
+}
+
+/** Line for the compositor config's startup section, null when the session runs ~/.config/autostart itself */
+export function compositorAutostartLine(env: DesktopEnvironment, exePath: string): string | null {
+  if (!isWlrootsStyle(env)) return null
+  const command = `${shellWord(exePath)} --minimized`
+  if (env === 'hyprland') return `exec-once = ${command}`
+  if (env === 'sway') return `exec ${command}`
+  if (env === 'niri') return `spawn-at-startup ${kdlString(exePath)} ${kdlString('--minimized')}`
+  return command
+}

+ 1 - 0
src/shared/ipc-channels.ts

@@ -133,6 +133,7 @@ export const IpcChannels = {
   LWE_HOTSWAP_SETTINGS: 'lwe:hotswap-settings',
   LWE_LIST_PROPERTIES: 'lwe:list-properties',
   LWE_LIST_SCREENS: 'lwe:list-screens',
+  LWE_INPUT_FILES: 'lwe:input-files',
   LWE_LIST_AUDIO_OBJECTS: 'lwe:list-audio-objects',
   LWE_LIST_EFFECTS: 'lwe:list-effects',
   LWE_LIST_APPLICATIONS: 'lwe:list-applications',

+ 5 - 2
src/shared/types.ts

@@ -1,5 +1,6 @@
 import type { ImageAdjustments } from './imageAdjustments'
 import type { VideoSegment } from './videoTrim'
+import type { DesktopEnvironment } from './desktop'
 
 export type { ImageAdjustments } from './imageAdjustments'
 
@@ -83,6 +84,8 @@ export interface WallpaperMeta {
    * meant to be revealed by parallax) show in full, via linux-wallpaperengine --expand-canvas
    */
   expandCanvas?: boolean
+  /** --repair-assets: loads what broken wallpapers meant where WE shows nothing useful (e.g. a texture named "") */
+  repairAssets?: boolean
   /**
    * Color shown outside the wallpaper's bounds (Center/Fit letterboxing, zoomed-out scaling) as a
    * "RRGGBB"/"RRGGBBAA" hex string, applied via linux-wallpaperengine --corner-color. Default: black.
@@ -174,7 +177,7 @@ export interface EngineFlags {
   shadows?: LightingQuality
   msaa?: MsaaQuality
   ssaa?: SsaaQuality
-  /** KDE only: --layer background, plasmashell's desktop window can cover the wallpaper there */
+  /** --layer background (plasmashell's desktop can cover the wallpaper on KDE, niri needs it); key kept for stored configs */
   kdeBackgroundLayer?: boolean
 }
 
@@ -380,7 +383,7 @@ export interface WallpaperFolder {
 
 export interface WallpaperEnvironment {
   displayServer: 'wayland' | 'x11' | 'unknown'
-  desktopEnv: 'gnome' | 'kde' | 'hyprland' | 'sway' | 'other'
+  desktopEnv: DesktopEnvironment
   availableBackends: WallpaperBackend[]
   recommendedBackend: WallpaperBackend
   linuxWallpaperEngine: LweStatus