mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
Open notes with custom software.
This commit is contained in:
parent
9fc474504b
commit
7c7bea5e3a
@ -55,18 +55,15 @@ async function openNoteCustom(noteId, mime) {
|
|||||||
const platform = process.platform;
|
const platform = process.platform;
|
||||||
if (platform === 'linux') {
|
if (platform === 'linux') {
|
||||||
const terminals = ['gnome-terminal', 'konsole', 'xterm', 'xfce4-terminal', 'mate-terminal', 'rxvt', 'terminator', 'terminology'];
|
const terminals = ['gnome-terminal', 'konsole', 'xterm', 'xfce4-terminal', 'mate-terminal', 'rxvt', 'terminator', 'terminology'];
|
||||||
let foundTerminal = false;
|
|
||||||
let availableTerminal = null;
|
|
||||||
const openFileWithTerminal = (terminal) => {
|
const openFileWithTerminal = (terminal) => {
|
||||||
const command = `${terminal} -e 'mimeopen -d "${filePath}"'`;
|
const command = `${terminal} -e 'mimeopen -d "${filePath}"'`;
|
||||||
console.log(`Open Note custom: ${command}. `);
|
console.log(`Open Note custom: ${command} `);
|
||||||
exec(command, (error, stdout, stderr) => {
|
exec(command, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(`Open Note custom: Failed to open file with ${terminal}: ${error}`);
|
console.error(`Open Note custom: Failed to open file with ${terminal}: ${error}`);
|
||||||
searchTerminal(terminals.indexOf(terminal) + 1);
|
searchTerminal(terminals.indexOf(terminal) + 1);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Open Note custom: File opened with ${terminal}. `);
|
console.log(`Open Note custom: File opened with ${terminal}. ${stdout}`);
|
||||||
console.log(`Open Note custom: ${stdout}. `);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -79,11 +76,7 @@ async function openNoteCustom(noteId, mime) {
|
|||||||
}
|
}
|
||||||
exec(`which ${terminal}`, (error, stdout, stderr) => {
|
exec(`which ${terminal}`, (error, stdout, stderr) => {
|
||||||
if (stdout.trim()) {
|
if (stdout.trim()) {
|
||||||
foundTerminal = true;
|
openFileWithTerminal(terminal);
|
||||||
availableTerminal = terminal;
|
|
||||||
}
|
|
||||||
if (foundTerminal) {
|
|
||||||
openFileWithTerminal(availableTerminal);
|
|
||||||
} else {
|
} else {
|
||||||
searchTerminal(index + 1);
|
searchTerminal(index + 1);
|
||||||
}
|
}
|
||||||
@ -108,15 +101,6 @@ async function openNoteCustom(noteId, mime) {
|
|||||||
open(getFileUrl(noteId), { url: true });
|
open(getFileUrl(noteId), { url: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// allow browser to handle opening common file
|
|
||||||
if (mime === "application/pdf" || mime.startsWith("image") || mime.startsWith("audio") || mime.startsWith("video")) {
|
|
||||||
window.open(getOpenFileUrl(noteId));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
window.location.href = getFileUrl(noteId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadNoteRevision(noteId, noteRevisionId) {
|
function downloadNoteRevision(noteId, noteRevisionId) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user