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>
|
||||
|
||||
<!-- Shortcut -->
|
||||
<div class="section">
|
||||
<label>Hotkey</label>
|
||||
<!-- Linux Wayland Hotkey Command -->
|
||||
<div class="section" id="linuxPressSection" style="display: none;">
|
||||
<label>System Hotkey Command (Linux)</label>
|
||||
<div class="form-control">
|
||||
<div class="flex-row">
|
||||
<div class="input-wrapper">
|
||||
<input type="text" id="shortcutInput" placeholder="Click Record to set..." readonly>
|
||||
<input type="text" id="linuxPressCommand" readonly>
|
||||
</div>
|
||||
<button onclick="recordShortcut()" id="recordBtn">Record</button>
|
||||
<button onclick="copyLinuxPressCommand()">Copy</button>
|
||||
</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>
|
||||
|
||||
<!-- Microphone -->
|
||||
|
||||
+24
-15
@@ -24,12 +24,18 @@ async function loadSettings() {
|
||||
|
||||
// Populate fields
|
||||
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('aiModel').value = settings.ai_model || 'llama-3.3-70b-versatile';
|
||||
document.getElementById('aiPrompt').value = settings.ai_prompt || '';
|
||||
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
|
||||
renderHistory(settings.history || []);
|
||||
|
||||
@@ -123,25 +129,28 @@ async function saveApiKey() {
|
||||
showToast('API Key saved');
|
||||
}
|
||||
|
||||
// Save Shortcut
|
||||
async function saveShortcut() {
|
||||
const shortcut = document.getElementById('shortcutInput').value.trim().toLowerCase();
|
||||
|
||||
if (!shortcut) {
|
||||
alert('Please enter a shortcut');
|
||||
return;
|
||||
async function copyLinuxPressCommand() {
|
||||
const cmdInput = document.getElementById('linuxPressCommand');
|
||||
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');
|
||||
}
|
||||
|
||||
const parts = shortcut.split('+');
|
||||
if (parts.length < 2) {
|
||||
alert('Shortcut must have a modifier + key (e.g., ctrl+x)');
|
||||
return;
|
||||
showToast('Command copied');
|
||||
} catch (err) {
|
||||
console.error('Failed to copy Linux command:', err);
|
||||
}
|
||||
|
||||
await saveSetting('shortcut', shortcut);
|
||||
showToast('Shortcut saved: ' + shortcut);
|
||||
}
|
||||
|
||||
window.copyLinuxPressCommand = copyLinuxPressCommand;
|
||||
|
||||
// Save Whisper Model
|
||||
async function saveWhisperModel() {
|
||||
const model = document.getElementById('whisperModel').value;
|
||||
|
||||
Reference in New Issue
Block a user