Add custom open command override

This commit is contained in:
2026-03-28 12:47:37 +01:00
parent 8e369ebd5a
commit c5695af7fd
3 changed files with 91 additions and 4 deletions

View File

@@ -60,7 +60,7 @@ var settingsTemplate = template.Must(template.New("settings").Parse(`<!doctype h
</head>
<body>
<h1>Path Aliases</h1>
<p class="small">Define aliases like <code>PROJECTS</code> -> <code>/mnt/projects</code>. Use in <code>/open</code> as <code>PROJECTS&gt;my/repo</code>.</p>
<p class="small">Define aliases like <code>PROJECTS</code> -&gt; <code>/mnt/projects</code>. Use in <code>/open</code> as <code>PROJECTS&gt;my/repo</code>.</p>
<table>
<thead>
@@ -70,7 +70,19 @@ var settingsTemplate = template.Must(template.New("settings").Parse(`<!doctype h
</table>
<div style="margin-top: 0.75rem;">
<button id="addRow">Add Alias</button>
<button id="save">Save</button>
</div>
<h2 style="margin-top: 2rem;">Open Location Command</h2>
<p class="small">
Optionally override the default file manager. Use <code>%1</code> for the resolved path.<br>
Example: <code>doublecmd.exe -C -T -P L -L "%1"</code>
</p>
<div style="max-width: 900px;">
<input type="text" id="openCmd" placeholder='e.g. doublecmd.exe -C -T -P L -L "%1"' style="width: 100%; box-sizing: border-box; padding: 0.35rem;">
</div>
<div style="margin-top: 1rem;">
<button id="save">Save All Settings</button>
</div>
<div id="status" class="small"></div>
@@ -148,6 +160,7 @@ var settingsTemplate = template.Must(template.New("settings").Parse(`<!doctype h
const keys = Object.keys(data.path_map || {}).sort();
if (keys.length === 0) addRow();
for (const k of keys) addRow(k, data.path_map[k]);
document.getElementById('openCmd').value = data.open_location_command || '';
setStatus('Loaded', false);
}
@@ -155,10 +168,11 @@ var settingsTemplate = template.Must(template.New("settings").Parse(`<!doctype h
try {
const map = collect();
setStatus('Saving...', false);
const openCmd = document.getElementById('openCmd').value.trim();
const res = await fetch('/settings/config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ path_map: map })
body: JSON.stringify({ path_map: map, open_location_command: openCmd })
});
const data = await res.json();
if (!data.ok) {