Skip to content

The swiss army knife of lossless video/audio editing

allow revealing config file path

Mikael Finstada5000a897775
diff --git a/src/main/configStore.ts b/src/main/configStore.ts
index b17818fe..5412b186 100644
--- a/src/main/configStore.ts
+++ b/src/main/configStore.ts
@@ -148,17 +148,19 @@ const defaults: Config = {
invertTimelineScroll: undefined,
};
+const configFileName = 'config.json'; // note: this is also hard-coded inside electron-store
+
// look for a config.json file next to the executable
// For portable app: https://github.com/mifi/lossless-cut/issues/645
-async function lookForCustomStoragePath() {
+async function lookForNeighbourConfigFile() {
try {
// https://github.com/mifi/lossless-cut/issues/645#issuecomment-1001363314
// https://stackoverflow.com/questions/46307797/how-to-get-the-original-path-of-a-portable-electron-app
// https://github.com/electron-userland/electron-builder/blob/master/docs/configuration/nsis.md
if (!isWindows || process.windowsStore) return undefined;
- const customStorageDir = process.env['PORTABLE_EXECUTABLE_DIR'] || dirname(app.getPath('exe'));
- const customConfigPath = join(customStorageDir, 'config.json');
- if (await pathExists(customConfigPath)) return customStorageDir;
+ const appExeDir = process.env['PORTABLE_EXECUTABLE_DIR'] || dirname(app.getPath('exe'));
+ const customConfigPath = join(appExeDir, configFileName);
+ if (await pathExists(customConfigPath)) return appExeDir;
return undefined;
} catch (err) {
@@ -200,8 +202,12 @@ async function tryCreateStore({ customStoragePath }: { customStoragePath: string
throw new Error('Timed out while creating config store');
}
+let customStoragePath: string | undefined;
+
+export const getConfigPath = () => customStoragePath ?? join(app.getPath('userData'), configFileName); // custom path, or default used by electron-store
+
export async function init({ customConfigDir }: { customConfigDir: string | undefined }) {
- const customStoragePath = customConfigDir ?? await lookForCustomStoragePath();
+ customStoragePath = customConfigDir ?? await lookForNeighbourConfigFile();
if (customStoragePath) logger.info('customStoragePath', customStoragePath);
await tryCreateStore({ customStoragePath });
diff --git a/src/main/menu.ts b/src/main/menu.ts
index c160c166..ca76641c 100644
--- a/src/main/menu.ts
+++ b/src/main/menu.ts
@@ -4,6 +4,7 @@ import { t } from 'i18next';
import { homepage, getReleaseUrl, licensesPage } from './constants.js';
import { logFilePath } from './logger.js';
+import { getConfigPath } from './configStore.js';
// menu-safe i18n.t:
@@ -448,6 +449,10 @@ export default ({ app, mainWindow, newVersion, isStoreBuild }: {
click() { electron.shell.openExternal('https://github.com/mifi/lossless-cut/issues'); },
},
{ type: 'separator' },
+ {
+ label: esc(t('Configuration file')),
+ click() { electron.shell.showItemInFolder(getConfigPath()); },
+ },
{
label: esc(t('Log file')),
click() { electron.shell.openPath(logFilePath); },