mirror of
https://github.com/jahruz67/wisp-open.git
synced 2026-08-08 18:14:08 +00:00
Merge pull request #4 from jahruz67/codex/refactor-linux-global-hotkey-system-8g9jyq
Add Linux 'press' helper and UI support for system hotkey command
This commit is contained in:
+7
-6
@@ -41,18 +41,19 @@
|
|||||||
|
|
||||||
<div class="section-group-label">Input</div>
|
<div class="section-group-label">Input</div>
|
||||||
|
|
||||||
<!-- Shortcut -->
|
<!-- Linux Wayland Hotkey Command -->
|
||||||
<div class="section">
|
<div class="section" id="linuxPressSection" style="display: none;">
|
||||||
<label>Hotkey</label>
|
<label>System Hotkey Command (Linux)</label>
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<div class="flex-row">
|
<div class="flex-row">
|
||||||
<div class="input-wrapper">
|
<div class="input-wrapper">
|
||||||
<input type="text" id="shortcutInput" placeholder="Click Record to set..." readonly>
|
<input type="text" id="linuxPressCommand" readonly>
|
||||||
</div>
|
</div>
|
||||||
<button onclick="recordShortcut()" id="recordBtn">Record</button>
|
<button onclick="copyLinuxPressCommand()">Copy</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="hint">Click Record, then press your desired key combination (e.g. Ctrl+X).</p>
|
<p class="hint">GNOME: Settings -> Keyboard -> Custom Shortcuts -> Add a shortcut with the copied command.</p>
|
||||||
|
<p class="hint">KDE: System Settings -> Shortcuts -> Command/URL -> Add a shortcut with the copied command.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Microphone -->
|
<!-- Microphone -->
|
||||||
|
|||||||
+25
-16
@@ -24,12 +24,18 @@ async function loadSettings() {
|
|||||||
|
|
||||||
// Populate fields
|
// Populate fields
|
||||||
document.getElementById('apiKey').value = settings.api_key || '';
|
document.getElementById('apiKey').value = settings.api_key || '';
|
||||||
document.getElementById('shortcutInput').value = settings.shortcut || 'alt+z';
|
|
||||||
document.getElementById('whisperModel').value = settings.whisper_model || 'whisper-large-v3-turbo';
|
document.getElementById('whisperModel').value = settings.whisper_model || 'whisper-large-v3-turbo';
|
||||||
document.getElementById('aiModel').value = settings.ai_model || 'llama-3.3-70b-versatile';
|
document.getElementById('aiModel').value = settings.ai_model || 'llama-3.3-70b-versatile';
|
||||||
document.getElementById('aiPrompt').value = settings.ai_prompt || '';
|
document.getElementById('aiPrompt').value = settings.ai_prompt || '';
|
||||||
document.getElementById('startupToggle').checked = settings.startup || false;
|
document.getElementById('startupToggle').checked = settings.startup || false;
|
||||||
|
|
||||||
|
if (settings.linux_press_mode) {
|
||||||
|
const section = document.getElementById('linuxPressSection');
|
||||||
|
const cmdInput = document.getElementById('linuxPressCommand');
|
||||||
|
if (section) section.style.display = 'block';
|
||||||
|
if (cmdInput) cmdInput.value = settings.linux_press_command || '';
|
||||||
|
}
|
||||||
|
|
||||||
// Load history
|
// Load history
|
||||||
renderHistory(settings.history || []);
|
renderHistory(settings.history || []);
|
||||||
|
|
||||||
@@ -123,25 +129,28 @@ async function saveApiKey() {
|
|||||||
showToast('API Key saved');
|
showToast('API Key saved');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save Shortcut
|
|
||||||
async function saveShortcut() {
|
|
||||||
const shortcut = document.getElementById('shortcutInput').value.trim().toLowerCase();
|
|
||||||
|
|
||||||
if (!shortcut) {
|
async function copyLinuxPressCommand() {
|
||||||
alert('Please enter a shortcut');
|
const cmdInput = document.getElementById('linuxPressCommand');
|
||||||
return;
|
if (!cmdInput) return;
|
||||||
|
|
||||||
|
const command = cmdInput.value || '';
|
||||||
|
try {
|
||||||
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
await navigator.clipboard.writeText(command);
|
||||||
|
} else {
|
||||||
|
cmdInput.focus();
|
||||||
|
cmdInput.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
}
|
||||||
|
showToast('Command copied');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to copy Linux command:', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parts = shortcut.split('+');
|
|
||||||
if (parts.length < 2) {
|
|
||||||
alert('Shortcut must have a modifier + key (e.g., ctrl+x)');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await saveSetting('shortcut', shortcut);
|
|
||||||
showToast('Shortcut saved: ' + shortcut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.copyLinuxPressCommand = copyLinuxPressCommand;
|
||||||
|
|
||||||
// Save Whisper Model
|
// Save Whisper Model
|
||||||
async function saveWhisperModel() {
|
async function saveWhisperModel() {
|
||||||
const model = document.getElementById('whisperModel').value;
|
const model = document.getElementById('whisperModel').value;
|
||||||
|
|||||||
Reference in New Issue
Block a user