Bladeren bron

0.9.3: install missing runtime libraries on Arch and Debian based systems, pacman and GNOME fixes

- missing system libraries are installed per package manager and only the absent ones (apt, pacman)
  - pacman: -Sy when a repository database is missing (Garuda ships a stale one), parsePacmanRepos with test
  - GNOME: screen list parsed from the Mutter monitor tuples, no duplicates
  - openSUSE: command lookup no longer needs which
  - autostart entry adds --no-sandbox when chrome-sandbox is not setuid root (AppImage)
  - library and workshop lists scroll to the top on page change
  - README rewritten
UwU 1 maand geleden
bovenliggende
commit
898ba17810

+ 88 - 18
README.md

@@ -1,17 +1,71 @@
-# we_manager
+# WE Manager
 
-A Wallpaper Engine manager for Linux. Browses the Steam Workshop through
-steamworks.js, keeps a local library of subscribed wallpapers with folders and
-tags, and plays animated wallpapers on the desktop via
-[linux-wallpaperengine](https://github.com/Almamu/linux-wallpaperengine).
+A Wallpaper Engine manager for Linux. It browses the Steam Workshop, keeps a local library of your wallpapers
+with folders, tags and playlists, and plays them on the desktop with
+[linux-wallpaperengine-kde](https://github.com/WallpaperEngineLover/linux-wallpaperengine-kde), the engine this
+app is built around (it also works with the upstream
+[linux-wallpaperengine](https://github.com/Almamu/linux-wallpaperengine), without the newer features).
 
-Steam must be running and Wallpaper Engine (app id 431960) must be in the
-library for workshop browsing and subscriptions to work. Without Steam the app
-still works as a local library manager.
+Steam has to be running with Wallpaper Engine (app id 431960) in the library for Workshop browsing, subscribing and
+voting. Without Steam the app still works as a local library manager.
+
+## Features
+
+**Workshop**
+- Search with filters (tags, type, age rating, resolution, size, not downloaded, not liked), `a+b` (all words) and
+  `-word` (exclude) terms, ignore creators, subscribe and unsubscribe, also several at once.
+- Like, dislike and favorite with the result confirmed against Steam. The lists are cached on disk, so they are there
+  when the app starts, with or without Steam running. Votes that failed are shown on the card and retried.
+- "Verify files" checks an item against what Steam knows (state, folder, `project.json`, main file, size) and repairs it.
+- Presets that depend on another Workshop item ask to install it before they are applied.
+
+**Library**
+- Everything you subscribed to, with folders, tags, favorites, sorting, filters and drag and drop. Card badges (HDR,
+  HRTF, backed up, compatibility, removed from the Workshop) and card borders for liked, disliked and failed votes can
+  be turned on or off. A wallpaper can have a custom thumbnail, picked from an image or captured from the wallpaper
+  running with your settings.
+- **Libraries on several disks**: add extra library folders (each with a name) on any disk, wallpapers there show up
+  as "Local". Copy or move wallpapers between libraries from the context menu. Every copy is staged, written to disk,
+  hash-checked and only then swapped in, a move deletes the original only after the final folder has been checked again,
+  and an interrupted copy is recovered at the next start. A disk that is not mounted keeps its entries.
+- **Backups**: pick a backup folder and back up the selected wallpapers, or everything that was removed from the
+  Workshop, before it is lost. Backed up wallpapers stay in the library when you unsubscribe (there is an option to
+  unsubscribe after a backup), outdated backups are marked when the Workshop has a newer version, a scan loads backups
+  that already sit in the folder, and corrupted folders are skipped and reported.
+- Import the folders and playlists of a Wallpaper Engine `config.json`.
+- Unreadable settings files are moved aside and the app starts with defaults instead of failing.
+
+**Playback**
+- One wallpaper on every screen, one per screen, one spanning several screens, or several side by side on one screen
+  (split screens). Screens are detected through the compositor (Plasma, GNOME, Hyprland, sway, niri, X11).
+- Per wallpaper: scaling, zoom, offset, corner color, FPS, the wallpaper's own user properties applied live, Wallpaper
+  Engine's image filters and color options, layer and effect toggles, extra engine arguments, shortcuts for the
+  wallpaper's buttons, and trimming a video to one part or several parts.
+- Changes are hot-swapped into the running engine where that is possible. A wallpaper that crashes is recorded
+  (on launch, on switch, while running) with a note and a "test fresh launch" button, and marked on its card.
+- **Playlists** per screen: a time per wallpaper or play videos to the end, shuffle or sort, favorites only, volume per
+  item.
+- **Schedules** switch wallpapers by time of day or by the system's dark and light theme.
+- Tray menu with next wallpaper, and performance presets (battery saver, full quality).
+
+**Settings**
+- Performance: FPS limits (also on battery), pause when another window is fullscreen, maximized or focused, pause on
+  battery or when idle, background layer, SSAA and MSAA, post processing, shadows, HDR output, hardware decoding.
+- Audio: automute, silent mode, volume, audio processing and HRTF.
+- Startup and tray, update notices for the app and the engine, library folders, backups, the desktop icons overlay.
+- Appearance: theme, accent color, window transparency and KDE blur, card sizes and borders, animated previews always
+  or on hover.
+- 13 languages: English, German, Spanish, French, Italian, Japanese, Korean, Polish, Portuguese, Russian, Turkish and
+  Chinese (simplified and traditional). The default follows the system language.
+
+**Engine management**
+- Downloads and updates the prebuilt engine, or builds it from source, and installs the system libraries it is missing
+  (see Notes). Without the engine it can still set a wallpaper through hyprpaper, swww/awww or swaybg.
 
 ## Installing
 
-- **AppImage / .deb** from the [releases](https://github.com/WallpaperEngineLover/we_manager/releases).
+- **AppImage / .deb** from the [releases](https://github.com/WallpaperEngineLover/we_manager/releases). The .deb
+  updates itself through apt after asking for your password, the AppImage replaces its own file.
 - **Flatpak**: the `.flatpak` bundle on the releases page comes with linux-wallpaperengine inside, for
   Bazzite, Silverblue/Kinoite, SteamOS and any other distribution:
   `flatpak install --user we-manager.flatpak` (needs Flathub for the runtime). To build it yourself:
@@ -19,13 +73,19 @@ still works as a local library manager.
   `flatpak-builder --user --install --force-clean build-dir packaging/flatpak/io.github.WallpaperEngineLover.we_manager.yml`.
 - **AUR** (coming soon, AUR registration is paused right now): `we-manager-bin`, with `linux-wallpaperengine-kde-bin` or `-git` for the engine. Until then use the AppImage.
 
-## Running
+Which distributions and desktops the engine is tested on is listed in the
+[engine's README](https://github.com/WallpaperEngineLover/linux-wallpaperengine-kde#readme).
+
+## Running from source
 
 ```
 npm install
-npm run dev      # dev mode with hot reload
-npm run build    # compile to out/
-npm run dist     # package with electron-builder
+npm run dev        # dev mode with hot reload
+npm run build      # compile to out/
+npm run dist       # package with electron-builder (AppImage and .deb)
+npm test           # unit tests
+npm run typecheck
+npm run lint
 ```
 
 ## Notes
@@ -34,15 +94,25 @@ npm run dist     # package with electron-builder
   [linux-wallpaperengine-kde releases](https://github.com/WallpaperEngineLover/linux-wallpaperengine-kde/releases)
   into `~/.local/share/linux-wallpaperengine-kde`: the Ubuntu 24.04 or Fedora 44
   build there, the portable build on every other distribution with glibc 2.35 or
-  newer (Arch, SteamOS, image-based systems, Debian, openSUSE, older and newer
-  Ubuntu and Fedora). sudo is only needed for missing system libraries. It can
-  also build and install from source (needs sudo for the package manager and
-  `make install`), from a configurable repository (git URL or local path) and
-  branch. Inside the Flatpak the engine comes with the app.
+  newer. The download is checked against the release's size and SHA-256 digest.
+- Missing system libraries are installed through the distribution's package manager, which asks for your password
+  (`pkexec`, else `sudo`): `apt` on Debian, Ubuntu and their derivatives (Mint, Zorin, MX), `dnf` on Fedora, `zypper`
+  on openSUSE, `pacman` on Arch and its derivatives. Only packages that are absent are installed, on Arch a full
+  system update is needed first if the package databases are out of date. Image-based systems (Silverblue, Bazzite,
+  SteamOS) are not touched, use the Flatpak or the portable build there.
+- It can also build and install the engine from source (needs the package manager and `make install`), from a
+  configurable repository (git URL or local path) and branch. Inside the Flatpak the engine comes with the app. An
+  engine installed by a package manager (AUR, a distribution package, Nix, the Flatpak) is left to that package manager,
+  Settings says who owns it.
 - The optional desktop icons overlay
   (`src/main/services/desktop-icons-overlay.py`) draws KDE Folder View icons
   on a transparent layer-shell surface above the wallpaper. It needs python3,
   GTK4, gtk4-layer-shell and pycairo, and only works on Wayland.
+- On GNOME Wayland the engine needs its Shell extension, WE Manager offers to install it.
+- KDE blur needs X11: with blur on in a Plasma Wayland session the app restarts itself through XWayland.
+- The Steam connection only exists while the window is shown. Steam counts a process that initializes its API as a
+  running game, which would show you as in-game and make Steam's game recording capture the wrong thing, so the
+  connection is dropped when the window goes to the tray.
 - `steam_appid.txt` is required by the Steamworks SDK and must stay next to
   the app.
 - Known issue: disabling "Enable system tray" in Settings can leave the tray

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "we-manager",
-  "version": "0.9.2",
+  "version": "0.9.3",
   "type": "module",
   "description": "Wallpaper Engine workshop manager",
   "desktopName": "we-manager.desktop",

+ 13 - 1
src/main/services/autostart.service.ts

@@ -24,7 +24,19 @@ export function isAutostartSupported(): boolean {
 /** The AppImage rather than its mount, `flatpak run` for a Flatpak */
 function launchCommand(): string[] {
   if (isFlatpak() && process.env.FLATPAK_ID) return ['flatpak', 'run', process.env.FLATPAK_ID]
-  return [process.env.APPIMAGE ?? app.getPath('exe')]
+  const exe = process.env.APPIMAGE ?? app.getPath('exe')
+  return needsNoSandbox(exe) ? [exe, '--no-sandbox'] : [exe]
+}
+
+/** Only the .deb's chrome-sandbox is setuid root, the others abort at login where unprivileged user namespaces are restricted */
+function needsNoSandbox(exe: string): boolean {
+  if (process.env.APPIMAGE) return true
+  try {
+    const st = fs.statSync(path.join(path.dirname(exe), 'chrome-sandbox'))
+    return !(st.uid === 0 && (st.mode & 0o4000) !== 0)
+  } catch {
+    return true
+  }
 }
 
 /** Quoted per the desktop entry spec when needed, a literal % is %% (field codes) */

+ 76 - 3
src/main/services/lwe-prebuilt.service.ts

@@ -10,7 +10,7 @@ import { isCommandAvailable } from '../utils/platform'
 import { getLwePrebuiltDir } from '../utils/paths'
 import { isFlatpak } from '../utils/flatpak'
 import { downloadVerified, fetchLatestRelease } from '../utils/github'
-import { buildCleanBuildEnv, isOstreeSystem, parseOsReleaseIds, readPrebuiltRelease, resetLweDetection } from './lwe.service'
+import { buildCleanBuildEnv, isOstreeSystem, pacmanHasSyncDatabases, parseOsReleaseIds, readPrebuiltRelease, resetLweDetection } from './lwe.service'
 import { t } from '../i18n'
 
 const execFileAsync = promisify(execFile)
@@ -38,10 +38,67 @@ const RUNTIME_DEPS_UBUNTU = [
   'libwayland-client0', 'libwayland-cursor0', 'libwayland-egl1', 'libegl1', 'libgl1',
   'libnss3', 'libatk1.0-0t64', 'libatk-bridge2.0-0t64', 'libcups2t64', 'libxcomposite1', 'libxdamage1',
   'libgbm1', 'libxkbcommon0', 'libasound2t64', 'libpango-1.0-0', 'libcairo2',
+  'libvulkan1', 'libxi6', 'libxxf86vm1', 'libxinerama1', 'libxcursor1', 'libxrender1', 'libxext6', 'libxfixes3',
   // V8 for scene scripts
   'libnode109'
 ]
 
+// the portable build leaves the desktop stack to the system (lib/SYSTEM_LIBS), pacman and apt can't install by soname
+const RUNTIME_DEPS_ARCH = [
+  'nss', 'nspr', 'atk', 'at-spi2-core', 'libcups', 'avahi', 'pango', 'cairo', 'gdk-pixbuf2', 'glib2', 'dbus',
+  'libdrm', 'mesa', 'libglvnd', 'vulkan-icd-loader', 'wayland', 'libxkbcommon', 'alsa-lib', 'libpulse',
+  'libx11', 'libxcomposite', 'libxdamage', 'libxext', 'libxfixes', 'libxi', 'libxinerama', 'libxrandr',
+  'libxrender', 'libxcursor', 'libxxf86vm', 'libxcb', 'libffi', 'libthai', 'pixman', 'systemd-libs', 'util-linux-libs'
+]
+
+// each entry lists the names across Debian and its derivatives, the first one the archive knows is installed (t64 renames)
+const RUNTIME_DEPS_DEBIAN: string[][] = [
+  ['libnss3'], ['libnspr4'], ['libatk1.0-0t64', 'libatk1.0-0'], ['libatk-bridge2.0-0t64', 'libatk-bridge2.0-0'],
+  ['libatspi2.0-0t64', 'libatspi2.0-0'], ['libcups2t64', 'libcups2'], ['libavahi-client3'], ['libavahi-common3'],
+  ['libpango-1.0-0'], ['libpangocairo-1.0-0'], ['libcairo2'], ['libgdk-pixbuf-2.0-0', 'libgdk-pixbuf2.0-0'],
+  ['libglib2.0-0t64', 'libglib2.0-0'], ['libdbus-1-3'], ['libdrm2'], ['libgbm1'], ['libegl1'], ['libgl1'],
+  ['libvulkan1'], ['libwayland-client0'], ['libwayland-cursor0'], ['libwayland-egl1'], ['libxkbcommon0'],
+  ['libasound2t64', 'libasound2'], ['libpulse0'], ['libx11-6'], ['libxcomposite1'], ['libxdamage1'],
+  ['libxext6'], ['libxfixes3'], ['libxi6'], ['libxinerama1'], ['libxrandr2'], ['libxrender1'], ['libxcursor1'],
+  ['libxxf86vm1'], ['libxcb1'], ['libthai0']
+]
+
+/** pacman -T prints the requirements nothing installed satisfies and exits with 127 */
+async function absentPacmanPackages(packages: string[]): Promise<string[]> {
+  try {
+    const { stdout } = await execFileAsync('pacman', ['-T', ...packages], { maxBuffer: 1024 * 1024 })
+    return stdout.split('\n').map(line => line.trim()).filter(Boolean)
+  } catch (error) {
+    const stdout = (error as { stdout?: string }).stdout
+    if (typeof stdout !== 'string') throw error
+    return stdout.split('\n').map(line => line.trim()).filter(Boolean)
+  }
+}
+
+async function debianPackageInstalled(name: string): Promise<boolean> {
+  try {
+    const { stdout } = await execFileAsync('dpkg-query', ['-W', '-f=${Status}', name])
+    return stdout.includes('install ok installed')
+  } catch {
+    return false
+  }
+}
+
+async function absentDebianPackages(entries: string[][]): Promise<string[]> {
+  const absent: string[] = []
+  for (const names of entries) {
+    if ((await Promise.all(names.map(debianPackageInstalled))).some(Boolean)) continue
+    for (const name of names) {
+      try {
+        await execFileAsync('apt-cache', ['show', '--no-all-versions', name], { maxBuffer: 5 * 1024 * 1024 })
+        absent.push(name)
+        break
+      } catch { }
+    }
+  }
+  return absent
+}
+
 function readOsRelease(): Record<string, string> {
   const fields: Record<string, string> = {}
   try {
@@ -146,13 +203,29 @@ async function installMissingLibraries(distro: PrebuiltDistro, missing: string[]
   const elevate = isCommandAvailable('pkexec') ? 'pkexec' : 'sudo'
   let command: string[]
   if (distro === 'ubuntu-24.04') {
-    command = ['apt-get', 'install', '-y', ...RUNTIME_DEPS_UBUNTU]
+    const absent = await absentDebianPackages(RUNTIME_DEPS_UBUNTU.map(name => [name]))
+    if (absent.length === 0) {
+      throw new Error(`These system libraries are missing: ${missing.join(', ')}. Install the packages providing them with your package manager.`)
+    }
+    command = ['apt-get', 'install', '-y', ...absent]
   } else if (ids.includes('fedora') && isCommandAvailable('dnf')) {
     command = ['dnf', 'install', '-y', ...bySoname]
   } else if ((ids.includes('suse') || ids.includes('opensuse')) && isCommandAvailable('zypper')) {
     command = ['zypper', '--non-interactive', 'install', ...bySoname]
+  } else if (ids.includes('arch') && isCommandAvailable('pacman')) {
+    // only what is absent: asking for installed ones would pull newer versions of core packages (a partial upgrade)
+    const absent = await absentPacmanPackages(RUNTIME_DEPS_ARCH)
+    if (absent.length === 0) {
+      throw new Error(`These system libraries are missing: ${missing.join(', ')}. Install the packages providing them with your package manager.`)
+    }
+    command = ['pacman', pacmanHasSyncDatabases() ? '-S' : '-Sy', '--noconfirm', '--needed', ...absent]
+  } else if (ids.includes('debian') && isCommandAvailable('apt-get')) {
+    const absent = await absentDebianPackages(RUNTIME_DEPS_DEBIAN)
+    if (absent.length === 0) {
+      throw new Error(`These system libraries are missing: ${missing.join(', ')}. Install the packages providing them with your package manager.`)
+    }
+    command = ['apt-get', 'install', '-y', ...absent]
   } else {
-    // apt and pacman can't install by soname without a file index
     throw new Error(`These system libraries are missing: ${missing.join(', ')}. Install the packages providing them with your package manager.`)
   }
   await execFileAsync(elevate, command, { timeout: 600_000, maxBuffer: 10 * 1024 * 1024 })

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

@@ -23,6 +23,7 @@ const {
   buildLweArgs,
   lwePackageOwner,
   nodeDevelPackage,
+  parsePacmanRepos,
   parseCustomArgs,
   parseOsReleaseIds
 } = await import('./lwe.service')
@@ -242,3 +243,10 @@ describe('lwePackageOwner', () => {
     expect(lwePackageOwner('/tmp/not-installed-by-anything/linux-wallpaperengine')).toBeUndefined()
   })
 })
+
+describe('parsePacmanRepos', () => {
+  it('lists the repositories and leaves [options] out', () => {
+    const conf = '[options]\nHoldPkg = pacman\n\n[core]\nInclude = /etc/pacman.d/mirrorlist\n  [extra]  \n#[testing]\n[garuda]\nServer = x\n'
+    expect(parsePacmanRepos(conf)).toEqual(['core', 'extra', 'garuda'])
+  })
+})

+ 26 - 1
src/main/services/lwe.service.ts

@@ -398,7 +398,8 @@ export async function installLweDeps(win: BrowserWindow): Promise<void> {
       break
     case 'arch':
       pkgManager = 'pacman'
-      installArgs = ['-S', '--noconfirm', '--needed']
+      // a fresh install has no sync databases and every package would be "target not found"
+      installArgs = pacmanHasSyncDatabases() ? ['-S', '--noconfirm', '--needed'] : ['-Sy', '--noconfirm', '--needed']
       packages = DEPS_ARCH
       break
   }
@@ -446,6 +447,30 @@ export async function installLweDeps(win: BrowserWindow): Promise<void> {
   }
 }
 
+/** the repositories of pacman.conf's [sections] (no [options]), Include lines are not followed */
+export function parsePacmanRepos(conf: string): string[] {
+  return conf.split('\n')
+    .map(line => /^\[([^\]]+)\]\s*$/.exec(line.trim())?.[1])
+    .filter((name): name is string => name !== undefined && name !== 'options')
+}
+
+/** true when every configured repository has its database, one missing (Garuda ships a stale chaotic-aur one) breaks `-S` */
+export function pacmanHasSyncDatabases(): boolean {
+  try {
+    const present = new Set(fs.readdirSync('/var/lib/pacman/sync'))
+    let repos: string[] = []
+    try {
+      repos = execFileSync('pacman-conf', ['--repo-list'], { encoding: 'utf8' }).split('\n').map(name => name.trim()).filter(Boolean)
+    } catch {
+      repos = parsePacmanRepos(fs.readFileSync('/etc/pacman.conf', 'utf8'))
+    }
+    if (repos.length === 0) return [...present].some((name) => name.endsWith('.db'))
+    return repos.every((repo) => present.has(`${repo}.db`))
+  } catch {
+    return false
+  }
+}
+
 export async function installLwe(win: BrowserWindow): Promise<void> {
   const send = (progress: LweInstallProgress) => {
     win.webContents.send(IpcChannels.EVENT_LWE_INSTALL_PROGRESS, progress)

+ 23 - 9
src/main/utils/platform.ts

@@ -1,3 +1,5 @@
+import fs from 'fs'
+import path from 'path'
 import { execSync } from 'child_process'
 import { parseDesktopEnv, type DesktopEnvironment } from '@shared/desktop'
 import { hostShell } from './flatpak'
@@ -135,7 +137,8 @@ export function getConnectedScreens(): string[] {
         hostShell("gdbus call --session --dest org.gnome.Mutter.DisplayConfig --object-path /org/gnome/Mutter/DisplayConfig --method org.gnome.Mutter.DisplayConfig.GetCurrentState 2>/dev/null"),
         { encoding: 'utf8', timeout: 5000 }
       )
-      const screens = [...output.matchAll(/connector:\s*'([^']+)'/gi)].map(m => m[1])
+      // gdbus prints the monitors as ('connector', 'vendor', 'product', 'serial') tuples
+      const screens = [...new Set([...output.matchAll(/\(\('([^']+)',\s*'[^']*',\s*'[^']*',\s*'[^']*'\)/g)].map(m => m[1]))]
       if (screens.length > 0) return screens
     } catch { }
   }
@@ -215,15 +218,26 @@ const commandCache = new Map<string, boolean>()
 
 export function isCommandAvailable(cmd: string): boolean {
   if (commandCache.has(cmd)) return commandCache.get(cmd)!
-  try {
-    const checker = process.platform === 'win32' ? `where ${cmd}` : `which ${cmd}`
-    execSync(checker, { stdio: 'ignore' })
-    commandCache.set(cmd, true)
-    return true
-  } catch {
-    commandCache.set(cmd, false)
-    return false
+  let found = false
+  if (process.platform === 'win32') {
+    try {
+      execSync(`where ${cmd}`, { stdio: 'ignore' })
+      found = true
+    } catch { }
+  } else {
+    // a PATH search of our own: minimal systems (openSUSE) ship without which(1)
+    const dirs = [...(process.env.PATH ?? '').split(':'), '/usr/local/sbin', '/usr/sbin', '/sbin'].filter(Boolean)
+    found = dirs.some((dir) => {
+      try {
+        fs.accessSync(path.join(dir, cmd), fs.constants.X_OK)
+        return true
+      } catch {
+        return false
+      }
+    })
   }
+  commandCache.set(cmd, found)
+  return found
 }
 
 export function invalidateCommandCache(cmd: string): void {

+ 7 - 0
src/renderer/src/components/library/LibraryView.tsx

@@ -392,6 +392,13 @@ export default function LibraryView({ onBrowseCreator }: LibraryViewProps) {
     onOpenDetail: setDetailId
   })
 
+  const firstPage = useRef(page)
+  useEffect(() => {
+    if (firstPage.current === page) return
+    firstPage.current = page
+    containerProps.ref.current?.scrollTo({ top: 0 })
+  }, [page, containerProps.ref])
+
   const resolutionCounts = useMemo(() => {
     const counts = new Map<string, number>()
     for (const w of allWallpapers) {

+ 7 - 0
src/renderer/src/components/workshop/WorkshopBrowser.tsx

@@ -339,6 +339,13 @@ export default function WorkshopBrowser({
     dataAttr: 'data-workshop-id',
     onOpenDetail: setDetailId
   })
+
+  const firstPage = useRef(page)
+  useEffect(() => {
+    if (firstPage.current === page) return
+    firstPage.current = page
+    containerProps.ref.current?.scrollTo({ top: 0 })
+  }, [page, containerProps.ref])
   const selectionSize = selection.size > 0 ? downloadSize([...selection]) : null
 
   function openCtxMenu(e: React.MouseEvent, itemId: string) {