Forráskód Böngészése

added ability to provide own repo

UwU 2 hónapja
szülő
commit
e8927c4fce

+ 3 - 1
README.md

@@ -21,7 +21,9 @@ npm run dist     # package with electron-builder
 ## Notes
 
 - Settings can build and install linux-wallpaperengine from source (needs
-  sudo for the package manager and `make install`).
+  sudo for the package manager and `make install`). A custom repository (git
+  URL or local path) and branch can be set there to build from a fork instead
+  of the official repo.
 - 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,

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

@@ -6,10 +6,14 @@ import {
   isWorkshopPathConfigured,
   getDefaultFps,
   setDefaultFps,
+  getLweRepoUrl,
+  getLweRepoBranch,
+  setLweRepo,
   importWEConfigFile,
   createFreshConfig
 } from '../services/config.service'
 import { getDefaultWorkshopPath } from '../utils/paths'
+import { DEFAULT_LWE_REPO } from '@shared/constants'
 import { restartWatcher } from '../services/watcher.service'
 import { importWEConfig } from '../services/library.service'
 
@@ -18,7 +22,10 @@ export function registerConfigHandlers(): void {
     workshopPath: getConfiguredWorkshopPath(),
     defaultWorkshopPath: getDefaultWorkshopPath(),
     isConfigured: isWorkshopPathConfigured(),
-    defaultFps: getDefaultFps()
+    defaultFps: getDefaultFps(),
+    lweRepoUrl: getLweRepoUrl(),
+    lweRepoBranch: getLweRepoBranch(),
+    defaultLweRepoUrl: DEFAULT_LWE_REPO
   }))
 
   ipcMain.handle(IpcChannels.CONFIG_SET_DEFAULT_FPS, (_e, fps: number | null) => {
@@ -26,6 +33,11 @@ export function registerConfigHandlers(): void {
     return { ok: true }
   })
 
+  ipcMain.handle(IpcChannels.CONFIG_SET_LWE_REPO, (_e, url: string | null, branch: string | null) => {
+    setLweRepo(url, branch)
+    return { ok: true }
+  })
+
   ipcMain.handle(IpcChannels.CONFIG_SET_WORKSHOP_PATH, (_e, newPath: string) => {
     setConfiguredWorkshopPath(newPath)
     restartWatcher()

+ 20 - 1
src/main/services/config.service.ts

@@ -7,13 +7,17 @@ import { WE_APP_ID } from '@shared/constants'
 interface AppConfig {
   workshopPath: string | null
   defaultFps: number | null
+  lweRepoUrl: string | null
+  lweRepoBranch: string | null
 }
 
 const store = new Store<AppConfig>({
   name: 'config',
   defaults: {
     workshopPath: null,
-    defaultFps: null
+    defaultFps: null,
+    lweRepoUrl: null,
+    lweRepoBranch: null
   }
 })
 
@@ -37,6 +41,21 @@ export function setDefaultFps(fps: number | null): void {
   store.set('defaultFps', fps)
 }
 
+/** Custom linux-wallpaperengine repo (git URL or local path); null = official repo. */
+export function getLweRepoUrl(): string | null {
+  return store.get('lweRepoUrl')
+}
+
+/** Branch/tag to build from the custom repo; null = default branch. */
+export function getLweRepoBranch(): string | null {
+  return store.get('lweRepoBranch')
+}
+
+export function setLweRepo(url: string | null, branch: string | null): void {
+  store.set('lweRepoUrl', url?.trim() || null)
+  store.set('lweRepoBranch', branch?.trim() || null)
+}
+
 /** Path where we store our copy of config.json */
 export function getWeConfigPath(): string {
   return path.join(app.getPath('userData'), 'we-config.json')

+ 17 - 4
src/main/services/lwe.service.ts

@@ -15,11 +15,12 @@ import {
   getXdgRuntimeDir
 } from '../utils/platform'
 import { getWorkshopPath } from '../utils/paths'
+import { getLweRepoUrl, getLweRepoBranch } from './config.service'
+import { DEFAULT_LWE_REPO } from '@shared/constants'
 
 const execFileAsync = promisify(execFile)
 
 const LWE_BINARY = 'linux-wallpaperengine'
-const LWE_REPO = 'https://github.com/Almamu/linux-wallpaperengine.git'
 const BUILD_DIR = path.join(os.tmpdir(), 'lwe-build')
 
 /** Common install locations checked before falling back to $PATH. */
@@ -186,9 +187,21 @@ export async function installLwe(win: BrowserWindow): Promise<void> {
       fs.rmSync(BUILD_DIR, { recursive: true, force: true })
     }
 
-    // Clone
-    send({ stage: 'cloning', message: 'Cloning linux-wallpaperengine...', percentage: 5 })
-    await execFileAsync('git', ['clone', '--depth', '1', '--recursive', LWE_REPO, BUILD_DIR], {
+    // Clone from the configured repo (custom fork or local path), or the official repo.
+    // Local paths are expanded so git clone sees an absolute path.
+    let repo = getLweRepoUrl() ?? DEFAULT_LWE_REPO
+    if (repo.startsWith('~/')) repo = path.join(os.homedir(), repo.slice(2))
+    const branch = getLweRepoBranch()
+    const cloneArgs = ['clone', '--depth', '1', '--recursive']
+    if (branch) cloneArgs.push('--branch', branch)
+    cloneArgs.push(repo, BUILD_DIR)
+
+    send({
+      stage: 'cloning',
+      message: `Cloning ${repo}${branch ? ` (${branch})` : ''}...`,
+      percentage: 5
+    })
+    await execFileAsync('git', cloneArgs, {
       timeout: 120_000,
       maxBuffer: 10 * 1024 * 1024
     })

+ 3 - 1
src/preload/index.ts

@@ -68,12 +68,14 @@ const api = {
   },
 
   config: {
-    get: (): Promise<{ workshopPath: string | null; defaultWorkshopPath: string; isConfigured: boolean; defaultFps: number | null }> =>
+    get: (): Promise<{ workshopPath: string | null; defaultWorkshopPath: string; isConfigured: boolean; defaultFps: number | null; lweRepoUrl: string | null; lweRepoBranch: string | null; defaultLweRepoUrl: string }> =>
       ipcRenderer.invoke(IpcChannels.CONFIG_GET),
     setWorkshopPath: (p: string): Promise<{ ok: boolean }> =>
       ipcRenderer.invoke(IpcChannels.CONFIG_SET_WORKSHOP_PATH, p),
     setDefaultFps: (fps: number | null): Promise<{ ok: boolean }> =>
       ipcRenderer.invoke(IpcChannels.CONFIG_SET_DEFAULT_FPS, fps),
+    setLweRepo: (url: string | null, branch: string | null): Promise<{ ok: boolean }> =>
+      ipcRenderer.invoke(IpcChannels.CONFIG_SET_LWE_REPO, url, branch),
     pickFolder: (): Promise<string | null> =>
       ipcRenderer.invoke(IpcChannels.CONFIG_PICK_FOLDER),
     pickFile: (): Promise<string | null> =>

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

@@ -20,6 +20,10 @@ export default function SettingsView() {
 
   // linux-wallpaperengine state
   const [lweStatus, setLweStatus] = useState<LweStatus | null>(null)
+  const [lweRepoUrl, setLweRepoUrl] = useState('')
+  const [lweRepoBranch, setLweRepoBranch] = useState('')
+  const [defaultLweRepo, setDefaultLweRepo] = useState('')
+  const [repoSaved, setRepoSaved] = useState(false)
   const [lweInstalling, setLweInstalling] = useState(false)
   const [lweProgress, setLweProgress] = useState<LweInstallProgress | null>(null)
   const [distro, setDistro] = useState<LinuxDistro | null>(null)
@@ -34,6 +38,9 @@ export default function SettingsView() {
     window.electronAPI.config.get().then((cfg) => {
       setWorkshopPath(cfg.workshopPath ?? cfg.defaultWorkshopPath)
       setDefaultFps(cfg.defaultFps != null ? String(cfg.defaultFps) : '')
+      setLweRepoUrl(cfg.lweRepoUrl ?? '')
+      setLweRepoBranch(cfg.lweRepoBranch ?? '')
+      setDefaultLweRepo(cfg.defaultLweRepoUrl)
     })
     window.electronAPI.lwe.status().then(setLweStatus)
     window.electronAPI.lwe.detectDistro().then(setDistro)
@@ -96,10 +103,18 @@ export default function SettingsView() {
     }
   }
 
+  async function handleSaveRepo() {
+    await window.electronAPI.config.setLweRepo(lweRepoUrl.trim() || null, lweRepoBranch.trim() || null)
+    setRepoSaved(true)
+    setTimeout(() => setRepoSaved(false), 2000)
+  }
+
   async function handleInstallLwe() {
     setLweInstalling(true)
     setLweProgress({ stage: 'cloning', message: 'Starting installation...', percentage: 0 })
     try {
+      // Persist the repo fields first so the build uses what's on screen
+      await window.electronAPI.config.setLweRepo(lweRepoUrl.trim() || null, lweRepoBranch.trim() || null)
       await window.electronAPI.lwe.install()
     } catch (err) {
       setLweProgress({
@@ -294,6 +309,38 @@ export default function SettingsView() {
             scenes directly on your desktop.
           </p>
 
+          {/* Custom source repository */}
+          <div className="mt-3 space-y-2">
+            <label className="block text-xs text-gray-400">Source repository</label>
+            <p className="text-xs text-gray-600">
+              Build from a custom fork instead of the official repo. Accepts a git URL or a
+              local path. Leave empty to use the official repository.
+            </p>
+            <input
+              type="text"
+              value={lweRepoUrl}
+              onChange={(e) => { setLweRepoUrl(e.target.value); setRepoSaved(false) }}
+              placeholder={defaultLweRepo}
+              className="w-full rounded-lg bg-white/5 px-3 py-2 text-sm text-gray-200 outline-none focus:ring-1 focus:ring-indigo-500"
+            />
+            <div className="flex gap-2 items-center">
+              <input
+                type="text"
+                value={lweRepoBranch}
+                onChange={(e) => { setLweRepoBranch(e.target.value); setRepoSaved(false) }}
+                placeholder="branch (default)"
+                className="w-44 rounded-lg bg-white/5 px-3 py-2 text-sm text-gray-200 outline-none focus:ring-1 focus:ring-indigo-500"
+              />
+              <button
+                onClick={handleSaveRepo}
+                className="flex items-center gap-2 rounded-lg bg-white/5 px-4 py-2 text-sm text-gray-300 hover:bg-white/10"
+              >
+                <Save size={14} />
+                {repoSaved ? 'Saved!' : 'Save'}
+              </button>
+            </div>
+          </div>
+
           {lweStatus === null ? (
             <p className="mt-3 text-xs text-gray-500">Checking...</p>
           ) : lweStatus.installed ? (
@@ -305,18 +352,32 @@ export default function SettingsView() {
               {lweStatus.path && (
                 <p className="text-xs text-gray-500">Path: {lweStatus.path}</p>
               )}
-              <button
-                onClick={handleUninstallLwe}
-                disabled={isBusy}
-                className="flex items-center gap-2 rounded-lg bg-red-600/20 px-4 py-2 text-sm text-red-400 hover:bg-red-600/30 disabled:opacity-50"
-              >
-                {uninstalling ? (
-                  <Loader2 size={14} className="animate-spin" />
-                ) : (
-                  <Trash2 size={14} />
-                )}
-                {uninstalling ? 'Uninstalling...' : 'Uninstall'}
-              </button>
+              <div className="flex flex-wrap gap-2">
+                <button
+                  onClick={handleInstallLwe}
+                  disabled={isBusy}
+                  className="flex items-center gap-2 rounded-lg bg-white/5 px-4 py-2 text-sm text-gray-300 hover:bg-white/10 disabled:opacity-50"
+                >
+                  {lweInstalling ? (
+                    <Loader2 size={14} className="animate-spin" />
+                  ) : (
+                    <Download size={14} />
+                  )}
+                  {lweInstalling ? 'Building...' : 'Rebuild & install'}
+                </button>
+                <button
+                  onClick={handleUninstallLwe}
+                  disabled={isBusy}
+                  className="flex items-center gap-2 rounded-lg bg-red-600/20 px-4 py-2 text-sm text-red-400 hover:bg-red-600/30 disabled:opacity-50"
+                >
+                  {uninstalling ? (
+                    <Loader2 size={14} className="animate-spin" />
+                  ) : (
+                    <Trash2 size={14} />
+                  )}
+                  {uninstalling ? 'Uninstalling...' : 'Uninstall'}
+                </button>
+              </div>
               {uninstallMsg && (
                 <p className="text-xs text-gray-400">{uninstallMsg}</p>
               )}

+ 2 - 0
src/shared/constants.ts

@@ -1 +1,3 @@
 export const WE_APP_ID = 431960
+
+export const DEFAULT_LWE_REPO = 'https://github.com/Almamu/linux-wallpaperengine.git'

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

@@ -47,6 +47,7 @@ export const IpcChannels = {
   CONFIG_GET: 'config:get',
   CONFIG_SET_WORKSHOP_PATH: 'config:set-workshop-path',
   CONFIG_SET_DEFAULT_FPS: 'config:set-default-fps',
+  CONFIG_SET_LWE_REPO: 'config:set-lwe-repo',
   CONFIG_PICK_FOLDER: 'config:pick-folder',
   CONFIG_PICK_FILE: 'config:pick-file',
   CONFIG_IMPORT_WE: 'config:import-we',