Skip to content

The swiss army knife of lossless video/audio editing

Implement custom config path

Mikael Finstad04a6d5c6a8b2
diff --git a/public/configStore.js b/public/configStore.js
index d3fbe951..6037ca96 100644
--- a/public/configStore.js
+++ b/public/configStore.js
@@ -1,45 +1,68 @@
const Store = require('electron-store');
+const electron = require('electron');
+const os = require('os');
+const { join } = require('path');
+const { pathExists } = require('fs-extra');
+
+const { app } = electron;
+
const defaults = {
- defaults: {
- captureFormat: 'jpeg',
- customOutDir: undefined,
- keyframeCut: true,
- autoMerge: false,
- autoDeleteMergedSegments: true,
- timecodeShowFrames: false,
- invertCutSegments: false,
- autoExportExtraStreams: true,
- exportConfirmEnabled: true,
- askBeforeClose: false,
- enableAskForImportChapters: true,
- enableAskForFileOpenAction: true,
- muted: false,
- autoSaveProjectFile: true,
- wheelSensitivity: 0.2,
- language: undefined,
- ffmpegExperimental: false,
- preserveMovData: false,
- movFastStart: true,
- avoidNegativeTs: 'make_zero',
- hideNotifications: undefined,
- autoLoadTimecode: false,
- segmentsToChapters: false,
- preserveMetadataOnMerge: false,
- simpleMode: true,
- outSegTemplate: undefined,
- keyboardSeekAccFactor: 1.03,
- keyboardNormalSeekSpeed: 1,
- },
+ captureFormat: 'jpeg',
+ customOutDir: undefined,
+ keyframeCut: true,
+ autoMerge: false,
+ autoDeleteMergedSegments: true,
+ timecodeShowFrames: false,
+ invertCutSegments: false,
+ autoExportExtraStreams: true,
+ exportConfirmEnabled: true,
+ askBeforeClose: false,
+ enableAskForImportChapters: true,
+ enableAskForFileOpenAction: true,
+ muted: false,
+ autoSaveProjectFile: true,
+ wheelSensitivity: 0.2,
+ language: undefined,
+ ffmpegExperimental: false,
+ preserveMovData: false,
+ movFastStart: true,
+ avoidNegativeTs: 'make_zero',
+ hideNotifications: undefined,
+ autoLoadTimecode: false,
+ segmentsToChapters: false,
+ preserveMetadataOnMerge: false,
+ simpleMode: true,
+ outSegTemplate: undefined,
+ keyboardSeekAccFactor: 1.03,
+ keyboardNormalSeekSpeed: 1,
};
+// For portable app: https://github.com/mifi/lossless-cut/issues/645
+async function getCustomStoragePath() {
+ try {
+ const isWindows = os.platform() === 'win32';
+ if (!isWindows || process.windowsStore) return undefined;
+
+ const customStoragePath = app.getAppPath();
+ const customConfigPath = join(customStoragePath, 'config.json');
+ if (await pathExists(customConfigPath)) return customStoragePath;
+ return undefined;
+ } catch (err) {
+ console.error('Failed to get custom storage path', err);
+ return undefined;
+ }
+}
let store;
async function init() {
+ const customStoragePath = await getCustomStoragePath();
+ if (customStoragePath) console.log('customStoragePath', customStoragePath);
+
for (let i = 0; i < 5; i += 1) {
try {
- store = new Store(defaults);
+ store = new Store({ defaults, cwd: customStoragePath });
return;
} catch (err) {
// eslint-disable-next-line no-await-in-loop