Skip to content

Commit 520620f

Browse files
Fix file save dialog default path for Linux KDE
Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
1 parent 119e9e5 commit 520620f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

app/main.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,8 +2658,13 @@ ipc.on('show-debug-log', showDebugLogWindow);
26582658
ipc.on(
26592659
'show-debug-log-save-dialog',
26602660
async (_event: Electron.Event, logText: string) => {
2661+
// Workaround KDE portal file dialog default path issue
2662+
const defaultPath = OS.isLinuxUsingKDE()
2663+
? '~/debuglog.txt'
2664+
: 'debuglog.txt';
2665+
26612666
const { filePath } = await dialog.showSaveDialog({
2662-
defaultPath: 'debuglog.txt',
2667+
defaultPath,
26632668
showsTagField: false,
26642669
});
26652670
if (filePath) {
@@ -3043,10 +3048,13 @@ ipc.handle('show-save-dialog', async (_event, { defaultPath }) => {
30433048
return { canceled: true };
30443049
}
30453050

3051+
// Workaround KDE portal file dialog default path issue
3052+
const osDefaultPath = OS.isLinuxUsingKDE() ? `~/${defaultPath}` : defaultPath;
3053+
30463054
const { canceled, filePath: selectedFilePath } = await dialog.showSaveDialog(
30473055
mainWindow,
30483056
{
3049-
defaultPath,
3057+
defaultPath: osDefaultPath,
30503058
showsTagField: false,
30513059
}
30523060
);

ts/util/os/osMain.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ function isWaylandEnabled(): boolean {
2323
return Boolean(process.env.WAYLAND_DISPLAY);
2424
}
2525

26+
function isLinuxUsingKDE(): boolean {
27+
return os.platform() === 'linux' && process.env.XDG_CURRENT_DESKTOP === 'KDE';
28+
}
29+
2630
const OS = {
2731
...getOSFunctions(os.release()),
2832
getLinuxName,
33+
isLinuxUsingKDE,
2934
isWaylandEnabled,
3035
};
3136

0 commit comments

Comments
 (0)