### Shell Script Integration Example Source: https://context7.com/ognistik/macrowhisper/llms.txt This bash script provides a basic example of automating tasks using Macrowhisper. It demonstrates how to start a recording session with a specific action, wait for its completion, and then process the result using another action. ```bash #!/bin/bash # Custom automation script # Start recording session with specific action macrowhisper --action emailDraft # Wait for completion sleep 2 # Process result macrowhisper --exec-action sendEmail ``` -------------------------------- ### Install Macrowhisper via Script Source: https://github.com/ognistik/macrowhisper/blob/main/README.md Installs Macrowhisper's binary to /usr/local/bin using a provided installation script. This method is an alternative to package managers like Homebrew. ```bash curl -L https://raw.githubusercontent.com/ognistik/macrowhisper/main/scripts/install.sh | sudo sh ``` -------------------------------- ### Install Macrowhisper via Script Source: https://context7.com/ognistik/macrowhisper/llms.txt Installs the latest release of Macrowhisper by downloading and executing an installation script. The script verifies the download's integrity and installs the executable to a specified location. You can customize the installation directory. ```bash # Downloads latest release, verifies hash, installs to /usr/local/bin curl -L https://raw.githubusercontent.com/ognistik/macrowhisper/main/scripts/install.sh | sudo sh # Custom installation directory curl -L https://raw.githubusercontent.com/ognistik/macrowhisper/main/scripts/install.sh | sudo sh -s /opt/bin ``` -------------------------------- ### Install Macrowhisper via Homebrew Source: https://context7.com/ognistik/macrowhisper/llms.txt Installs the Macrowhisper command-line tool using Homebrew, a package manager for macOS. It first adds the necessary tap and then installs the formula. After installation, you can verify it by running the help command. ```bash # Install from tap brew install ognistik/formulae/macrowhisper # Verify installation macrowhisper --help ``` -------------------------------- ### Macrowhisper JSON Configuration Example Source: https://github.com/ognistik/macrowhisper/blob/main/README.md An example of the JSON configuration file used by Macrowhisper. It demonstrates how to define default settings, insert actions, and URL actions with voice triggers. This file allows for dynamic placeholders to be used. ```json { "defaults": { "activeAction": "autoPaste", "pressReturn": false, "actionDelay": 0.0 }, "inserts": { "autoPaste": { "action": "{{swResult}}" } }, "urls": { "googleSearch": { "action": "https://www.google.com/search?q={{swResult}}", "triggerVoice": "ask google|search online" } } } ``` -------------------------------- ### Build and Run Macrowhisper (Swift) Source: https://github.com/ognistik/macrowhisper/blob/main/src/DEVELOPMENT.md Instructions for building the Macrowhisper project using Swift's build system and running the application with different command-line arguments for development and testing. ```bash cd src swift build ``` ```bash # Start with verbose logging ./macrowhisper --verbose # Use custom config for testing ./macrowhisper --config ~/test-config.json --verbose ``` ```bash # Test service management ./macrowhisper --service-status # Test configuration ./macrowhisper --get-config # Test inserts (requires running daemon) ./macrowhisper --list-inserts ``` -------------------------------- ### Macrowhisper Complete Configuration Example Source: https://context7.com/ognistik/macrowhisper/llms.txt A comprehensive example of the Macrowhisper configuration file in JSON format. It demonstrates the structure for defaults, text insertions, URL actions, macOS Shortcuts, shell scripts, and AppleScript actions, including various trigger conditions and action parameters. ```json { "$schema": "file:///usr/local/bin/macrowhisper-schema.json", "defaults": { "watch": "~/Documents/superwhisper", "activeAction": "autoPaste", "actionDelay": 0.0, "noEsc": false, "restoreClipboard": true, "pressReturn": false, "returnDelay": 0.1, "moveTo": "", "icon": "β€’", "history": 30, "scheduledActionTimeout": 5, "clipboardBuffer": 5.0, "clipboardStacking": false, "noUpdates": false, "noNoti": false }, "inserts": { "autoPaste": { "action": ".autoPaste", "icon": "⏎" }, "emailDraft": { "action": "Subject: {{xml:subject}}\n\nDear {{xml:recipient}},\n\n{{swResult}}\n\nBest regards", "triggerVoice": "draft email|compose email", "triggerLogic": "or", "actionDelay": 0.2, "moveTo": ".delete" } }, "urls": { "googleSearch": { "action": "https://www.google.com/search?q={{result}}", "triggerVoice": "ask google|search online", "icon": "πŸ”" }, "perplexity": { "action": "https://www.perplexity.ai/?q={{result||\.$||}}", "triggerVoice": "ask perplexity", "openWith": "Arc" } }, "shortcuts": { "aiMemos": { "action": "∞∞{{date:long}}∞∞{{swResult}}∞∞{{result}}∞∞", "triggerModes": "memo|note", "triggerLogic": "or" }, "jsonData": { "action": "{\"result\": \"{{json:swResult}}\", \"date\": \"{{json:date:yyyy-MM-dd}}\", \"app\": \"{{json:frontApp}}\"}", "triggerVoice": "send to shortcut" } }, "scriptsShell": { "saveToFile": { "action": "echo \"{{swResult}}\" >> ~/Documents/dictation-log.txt", "triggerVoice": "save to file|log this" }, "notifyComplete": { "action": "osascript -e 'display notification \"{{swResult}}\" with title \"Dictation Complete\"'", "triggerApps": "com.apple.mail|com.microsoft.Word" } }, "scriptsAS": { "keyboardMaestro": { "action": "tell application \"Keyboard Maestro Engine\" to do script \"Process Dictation\" with parameter \"{{swResult}}\"", "triggerVoice": "trigger macro" } } } ``` -------------------------------- ### BetterTouchTool Integration Examples Source: https://context7.com/ognistik/macrowhisper/llms.txt This snippet shows how to trigger Macrowhisper actions from BetterTouchTool, using keyboard shortcuts or other triggers. It includes examples for executing a specific action and toggling the auto-return mode. ```bash # Trigger from keyboard shortcut /usr/local/bin/macrowhisper --action codeComment # Auto-return mode toggle /usr/local/bin/macrowhisper --auto-return true ``` -------------------------------- ### Install Macrowhisper via Homebrew Source: https://github.com/ognistik/macrowhisper/blob/main/README.md Installs the Macrowhisper application using the Homebrew package manager. This is a standard method for managing software installations on macOS. ```bash brew install ognistik/formulae/macrowhisper ``` -------------------------------- ### Add Session-Based Placeholder (Swift) Source: https://github.com/ognistik/macrowhisper/blob/main/src/DEVELOPMENT.md Example code demonstrating how to add a new session-based placeholder in Macrowhisper, involving enhancements to ClipboardMonitor, ActionExecutor, and Placeholders.swift. ```swift // 1. Enhance ClipboardMonitor session structure private struct EarlyMonitoringSession { let myNewData: String? // Add your data field // ... existing fields } // 2. Capture data in startEarlyMonitoring() let myNewData = captureMyData() let session = EarlyMonitoringSession( // ... existing params myNewData: myNewData ) // 3. Add getter method in ClipboardMonitor func getMyNewData(for recordingPath: String) -> String { // Return session data } // 4. Enhance metaJson in ActionExecutor enhanced["myNewData"] = clipboardMonitor.getMyNewData(for: recordingPath) // 5. Add placeholder processing in Placeholders.swift else if key == "myNewData" { var value = metaJson["myNewData"] as? String ?? "" // ... standard placeholder processing } ``` -------------------------------- ### Raw Regex Examples for Voice Triggers - Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Illustrates advanced voice trigger configurations using raw regex in Swift. These examples show exact matching, suffix matching, negative lookaheads, and case-sensitive patterns, allowing for precise control over text matching. ```text ==^exact match$== ==.*ends with this$== ==^(?!.*exclude).*$== ==(?-i)Case Sensitive== ``` -------------------------------- ### Alfred Workflow Integration Examples Source: https://context7.com/ognistik/macrowhisper/llms.txt These examples demonstrate how to use the Macrowhisper CLI within an Alfred workflow. They show how to set an active action, enable auto-return mode, and execute a specific action directly from Alfred. ```bash # Use macrowhisper CLI from Alfred macrowhisper --action emailDraft macrowhisper --auto-return true # Execute specific action macrowhisper --exec-action searchWeb ``` -------------------------------- ### Initial Macrowhisper Configuration and Service Management Source: https://context7.com/ognistik/macrowhisper/llms.txt Commands for managing Macrowhisper's configuration and background service. This includes revealing the default configuration file, setting a custom location, starting, stopping, restarting, and checking the status of the background service, as well as uninstalling it. ```bash # Create and open configuration file (~/.config/macrowhisper/macrowhisper.json) macrowhisper --reveal-config # Set custom config location macrowhisper --set-config /path/to/custom/config.json # Start background service macrowhisper --start-service # Check service status macrowhisper --service-status ``` -------------------------------- ### Macrowhisper CLI Service Commands Source: https://context7.com/ognistik/macrowhisper/llms.txt This set of commands provides control over the Macrowhisper background service. It includes options to start, stop, restart, check status, and uninstall the service. ```bash macrowhisper --start-service # Start background service macrowhisper --stop-service # Stop background service macrowhisper --restart-service # Restart service (required after updates) macrowhisper --uninstall-service # Remove service completely macrowhisper --service-status # Check if service is running macrowhisper --status # Show running status ``` -------------------------------- ### Macrowhisper Service Management Commands Source: https://github.com/ognistik/macrowhisper/blob/main/README.md Commands to manage the Macrowhisper background service, including starting, stopping, uninstalling, and checking its status. These commands are essential for running Macrowhisper as a background process. ```bash macrowhisper --start-service macrowhisper --stop-service macrowhisper --uninstall-service macrowhisper --service-status ``` -------------------------------- ### Start Smart Session Monitoring in Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Initiates early monitoring for a recording session, capturing initial clipboard content and selected text. This function is started conditionally based on the state of meta.json. ```swift // Started conditionally based on meta.json state func startEarlyMonitoring(for recordingPath: String) { let pasteboard = NSPasteboard.general let userOriginal = pasteboard.string(forType: .string) // Capture selected text immediately when monitoring starts let selectedText = getSelectedText() let session = EarlyMonitoringSession( userOriginalClipboard: userOriginal, startTime: Date(), selectedText: selectedText ) // ... session management } ``` -------------------------------- ### Manage Macrowhisper Service Source: https://context7.com/ognistik/macrowhisper/llms.txt Commands to stop and start the Macrowhisper background service. Includes a brief pause between stop and start operations. This is useful for restarting the service after configuration changes or troubleshooting. ```bash macrowhisper --stop-service sleep 1 macrowhisper --start-service ``` -------------------------------- ### Clipboard Buffer Configuration Source: https://context7.com/ognistik/macrowhisper/llms.txt This configuration section details settings for the clipboard buffer, including its size and stacking behavior. The 'useClipboard' insert example shows how to display previous clipboard content alongside new results. ```json { "defaults": { "clipboardBuffer": 5.0, "clipboardStacking": false }, "inserts": { "useClipboard": { "action": "Previous clipboard: {{clipboardContext}}\nNew: {{swResult}}" } } } ``` -------------------------------- ### JSON Configuration Schema Example Source: https://github.com/ognistik/macrowhisper/blob/main/src/CODEBASE_MAP.md This JSON schema defines the structure for Macrowhisper configuration files. It includes sections for default settings, various action types like inserts, URLs, shortcuts, and shell/AppleScript execution. The `$schema` field indicates the location of the schema definition for validation. ```json { "$schema": "file://path/to/macrowhisper-schema.json", "defaults": { "watch": "~/Documents/superwhisper", "activeAction": "actionName", "actionDelay": 0.0, "clipboardBuffer": 5.0 }, "inserts": { "name": { "action": "text", "triggerVoice": "pattern" }}, "urls": { "name": { "action": "https://...", "openWith": "app" }}, "shortcuts": { "name": { "action": "shortcutName" }}, "scriptsShell": { "name": { "action": "command" }}, "scriptsAS": { "name": { "action": "tell app..." }} } ``` -------------------------------- ### Manage Macrowhisper Background Service Source: https://context7.com/ognistik/macrowhisper/llms.txt Commands for controlling the Macrowhisper background service, which runs as a launchd agent. This includes starting, stopping, restarting, checking the status, and completely uninstalling the service. ```bash # Start background service (creates launchd agent) macrowhisper --start-service # Stop service macrowhisper --stop-service # Restart service (required after updates) macrowhisper --restart-service # Check if service is running macrowhisper --service-status # Uninstall service completely macrowhisper --uninstall-service ``` -------------------------------- ### Action-Specific Settings Override Source: https://context7.com/ognistik/macrowhisper/llms.txt This configuration demonstrates how to override default action settings. It includes examples for introducing delays, preventing escape key actions, and managing clipboard content during specific actions. ```json { "defaults": { "actionDelay": 0.0, "noEsc": false, "moveTo": "", "restoreClipboard": true }, "inserts": { "slowAction": { "action": "{{swResult}}", "actionDelay": 0.5, "noEsc": true }, "autoDelete": { "action": "{{swResult}}", "moveTo": ".delete" }, "keepOriginal": { "action": "{{swResult}}", "moveTo": ".none" } } } ``` -------------------------------- ### Keyboard Maestro Integration Example Source: https://context7.com/ognistik/macrowhisper/llms.txt This JSON snippet shows how to integrate Macrowhisper with Keyboard Maestro. It defines a 'triggerMacro' action that uses AppleScript to instruct the Keyboard Maestro Engine to execute a specific macro, passing the transcription result as a parameter. ```json { "scriptsAS": { "triggerMacro": { "action": "tell application \"Keyboard Maestro Engine\" to do script \"Process Dictation\" with parameter \"{{swResult}}\"", "triggerVoice": "keyboard maestro|trigger macro" } } } ``` -------------------------------- ### Macrowhisper CLI Utility Commands Source: https://context7.com/ognistik/macrowhisper/llms.txt This section lists utility commands for Macrowhisper, including obtaining help information, checking the version, and verifying for updates. ```bash macrowhisper --help # Show all available commands macrowhisper --version # Show version number macrowhisper --check-updates # Check for available updates ``` -------------------------------- ### Basic Placeholder System (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration demonstrating basic placeholder usage within actions. Includes placeholders for transcription results, application context, selected text, clipboard content, and formatted dates. ```json { "inserts": { "basicPlaceholders": { "action": "User said: {{result}}\nLLM result: {{swResult}}\nApp: {{frontApp}}\nSelected: {{selectedText}}\nClipboard: {{clipboardContext}}\nTimestamp: {{date:yyyy-MM-dd HH:mm:ss}}" } } } ``` -------------------------------- ### Macrowhisper Configuration Commands Source: https://github.com/ognistik/macrowhisper/blob/main/README.md Commands for managing Macrowhisper's configuration file. This includes revealing the default configuration file, creating it if it doesn't exist, and setting a custom configuration file location. ```bash macrowhisper --reveal-config macrowhisper --set-config ``` -------------------------------- ### Execute Action with Clipboard Synchronization - Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Provides a Swift code snippet demonstrating the core logic for executing an action. It includes placeholder comments for determining action-specific settings like delay and ESC simulation, and highlights the use of clipboard synchronization for safe execution. ```swift func executeAction( action: Any, name: String, type: ActionType, metaJson: [String: Any], recordingPath: String ) { // 1. Determine action-specific settings let actionDelay = action.actionDelay ?? configManager.config.defaults.actionDelay let shouldEsc = !(action.noEsc ?? configManager.config.defaults.noEsc) // 2. Execute with appropriate clipboard handling clipboardMonitor.executeWithClipboardSync(...) // 3. Handle moveTo setting handleMoveToSetting(...) } ``` -------------------------------- ### Troubleshooting: Configuration Validation Source: https://context7.com/ognistik/macrowhisper/llms.txt These commands help validate Macrowhisper's configuration. They allow users to reveal the configuration file, check its JSON syntax using Python, and verify the current configuration path. ```bash # Reveal and check config file macrowhisper --reveal-config # Verify JSON syntax cat ~/.config/macrowhisper/macrowhisper.json | python3 -m json.tool # Check config path macrowhisper --config-path ``` -------------------------------- ### URL Action Configuration (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for defining URL actions in Macrowhisper. This includes the URL pattern, voice triggers, and application to open the URL with. ```json { "urls": { "searchEngine": { "action": "https://www.google.com/search?q={{result}}", "triggerVoice": "search for|google this", "openWith": "Safari", "openBackground": false } } } ``` -------------------------------- ### Verify Macrowhisper Permissions and Status Source: https://context7.com/ognistik/macrowhisper/llms.txt Instructions on how to grant accessibility permissions to Macrowhisper through macOS System Settings. It also includes commands to verify the service status and to uninstall and reinstall the service if necessary. ```bash # Grant accessibility permissions # System Settings > Privacy & Security > Accessibility > Add macrowhisper # Verify permissions macrowhisper --status # Reinstall if needed macrowhisper --uninstall-service macrowhisper --start-service ``` -------------------------------- ### Macrowhisper CLI Configuration Commands Source: https://context7.com/ognistik/macrowhisper/llms.txt These commands manage the Macrowhisper configuration file. Users can reveal the config file in their default editor, set a custom configuration path, or display the current configuration file path. ```bash macrowhisper --reveal-config # Open config file in default editor macrowhisper --set-config # Set custom config location macrowhisper --config-path # Show current config file path ``` -------------------------------- ### Shortcut Action Configuration (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for defining macOS Shortcut actions. Specifies the shortcut name and how to pass data, including JSON-formatted data and timestamps. ```json { "shortcuts": { "processData": { "action": "My Shortcut Name", "triggerVoice": "process with shortcut" }, "jsonToShortcut": { "action": "{\"text\": \"{{json:swResult}}\", \"timestamp\": \"{{json:date:ISO8601}}\"}" } } } ``` -------------------------------- ### Troubleshooting: Check Service Status Source: https://context7.com/ognistik/macrowhisper/llms.txt This section provides bash commands to troubleshoot the Macrowhisper service. It includes checking the service status, listing running processes, and examining launchd agents. ```bash # Is service running? macrowhisper --service-status # View running processes ps aux | grep macrowhisper # Check launchd agent launchctl list | grep macrowhisper ``` -------------------------------- ### Macrowhisper Status and Help Commands Source: https://github.com/ognistik/macrowhisper/blob/main/README.md Commands to check the current status of Macrowhisper and access its comprehensive help information. These are useful for monitoring and understanding the application's capabilities. ```bash macrowhisper --status macrowhisper --help ``` -------------------------------- ### Action Management Commands (Bash) Source: https://context7.com/ognistik/macrowhisper/llms.txt Command-line interface commands for managing actions in Macrowhisper. These commands allow adding, setting, and executing various types of actions, including insert, URL, shortcut, shell, and AppleScript. ```bash # Add new insert action macrowhisper --add-insert myAction # Set as active action macrowhisper --action myAction # Execute action with last transcription result macrowhisper --exec-action myAction # Auto-return mode (paste next transcription immediately) macrowhisper --auto-return true # Disable auto-return macrowhisper --auto-return false ``` ```bash # Add URL action macrowhisper --add-url searchEngine ``` ```bash # Add macOS Shortcut action macrowhisper --add-shortcut processData ``` ```bash # Add shell script action macrowhisper --add-shell runScript ``` ```bash # Add AppleScript action macrowhisper --add-as automateApp ``` -------------------------------- ### Apply Action Delay After Clipboard Sync (Swift) Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Demonstrates the sequence of operations including clipboard synchronization, applying action delay, simulating the ESC key, and executing an action. This code highlights the timing coordination within the Macrowhisper system. ```swift // Step 1: Handle clipboard synchronization with Superwhisper (up to maxWaitTime) // ... clipboard sync logic ... // Step 2: Apply actionDelay after clipboard sync is complete if actionDelay > 0 { Thread.sleep(forTimeInterval: actionDelay) logDebug("Applied actionDelay: \(actionDelay)s after clipboard sync") } // Step 3: Simulate ESC (if enabled) if shouldEsc { simulateKeyDown(key: 53) // ESC key } // Step 4: Execute action insertAction() ``` -------------------------------- ### Macrowhisper CLI Action Management Commands Source: https://context7.com/ognistik/macrowhisper/llms.txt This group of commands facilitates the management and execution of actions within Macrowhisper. It covers setting active actions, executing specific actions, toggling auto-return mode, and adding new action types like inserts, URLs, shortcuts, shell scripts, and AppleScripts. ```bash macrowhisper --action # Set active action (fallback when no triggers match) macrowhisper --exec-action # Execute action with last transcription result macrowhisper --auto-return # Enable/disable auto-return mode macrowhisper --add-insert # Create new insert action macrowhisper --add-url # Create new URL action macrowhisper --add-shortcut # Create new Shortcut action macrowhisper --add-shell # Create new shell script action macrowhisper --add-as # Create new AppleScript action ``` -------------------------------- ### Troubleshooting: Service Restart After Changes Source: https://context7.com/ognistik/macrowhisper/llms.txt This command is crucial for applying configuration changes or updates to the Macrowhisper service. It ensures that the service restarts with the latest settings. ```bash # Always restart after config changes or updates macrowhisper --restart-service ``` -------------------------------- ### Date Formatting Options Source: https://context7.com/ognistik/macrowhisper/llms.txt This JSON configuration shows various ways to format dates using the {{date}} template. It includes options for ISO format, long format, short format, custom formatting, and time display. ```json { "inserts": { "dateFormats": { "action": "ISO: {{date:yyyy-MM-dd}}\nLong: {{date:long}}\nShort: {{date:short}}\nCustom: {{date:EEEE, MMMM d, yyyy}}\nTime: {{date:HH:mm:ss}}" } } } ``` -------------------------------- ### Shell Script Action Configuration (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for shell script actions. Defines the script path or command, trigger voice, and optionally the application context for execution. ```json { "scriptsShell": { "runScript": { "action": "/usr/local/bin/my-script.sh \"{{swResult}}\"", "triggerVoice": "run script" }, "multiCommand": { "action": "cd ~/Projects && git commit -m \"{{swResult}}\" && git push", "triggerApps": "com.apple.Terminal" } } } ``` -------------------------------- ### Global Defaults Settings (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt Configuration object for setting global default behaviors in Macrowhisper. This includes settings for watching directories, active actions, delays, and notification preferences. ```json { "defaults": { "watch": "~/Documents/superwhisper", "activeAction": "autoPaste", "actionDelay": 0.0, "noEsc": false, "restoreClipboard": true, "pressReturn": false, "returnDelay": 0.1, "moveTo": "", "icon": "β€’", "history": 30, "scheduledActionTimeout": 5, "clipboardBuffer": 5.0, "clipboardStacking": false, "noUpdates": false, "noNoti": false } } ``` -------------------------------- ### Macrowhisper Action Management Commands Source: https://github.com/ognistik/macrowhisper/blob/main/README.md Commands to manage and execute actions within Macrowhisper. This allows setting active actions, executing them with the last result, and adding new actions of various types (insert, URL, shell, shortcut, AppleScript). ```bash macrowhisper --action macrowhisper --exec-action macrowhisper --add-insert macrowhisper --add-url macrowhisper --add-shell macrowhisper --add-shortcut macrowhisper --add-as ``` -------------------------------- ### Configure Voice Triggers with Regex Patterns - Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Defines how voice triggers are configured using regular expressions in Swift. Supports standard prefix matching, exceptions with '!', and raw regex for full control. Voice triggers are case-insensitive by default and strip matched prefixes. ```json { "triggerVoice": "^send email|compose message|!delete email|==^google this\\.?$==" } ``` -------------------------------- ### Voice Trigger Configuration (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for defining voice triggers. Supports multiple phrases, exact matches, and exclusion patterns for activating actions. ```json { "urls": { "search": { "action": "https://www.google.com/search?q={{result}}", "triggerVoice": "ask google|search for|google this", "triggerLogic": "or" }, "exactMatch": { "action": "https://example.com", "triggerVoice": "==^open example\\.?$==" }, "excludePattern": { "action": "https://default.com", "triggerVoice": "!delete|!remove" } } } ``` -------------------------------- ### History Management Settings Source: https://context7.com/ognistik/macrowhisper/llms.txt This configuration snippet manages the history feature, specifying the number of history entries to retain and a default directory for processed recordings. The 'important' and 'temporary' inserts demonstrate how to route recordings to specific directories. ```json { "defaults": { "history": 30, "moveTo": "~/Documents/processed-recordings" }, "inserts": { "important": { "action": "{{swResult}}", "moveTo": "~/Documents/important-recordings" }, "temporary": { "action": "{{swResult}}", "moveTo": ".delete" } } } ``` -------------------------------- ### Run Macrowhisper in Foreground Source: https://context7.com/ognistik/macrowhisper/llms.txt Commands to run Macrowhisper directly in the foreground, useful for testing or debugging purposes. It also includes a command to check the current running status of the service. ```bash # Run directly (for testing/debugging) macrowhisper # Check running status macrowhisper --status ``` -------------------------------- ### Application Trigger Configuration (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for application-specific triggers. Allows actions to be activated only when a specific application is active, supporting multiple applications with OR logic. ```json { "inserts": { "emailSignature": { "action": "\n\nBest regards,\nJohn Doe", "triggerApps": "com.apple.mail|com.microsoft.Outlook", "triggerLogic": "or" }, "codeComment": { "action": "// {{swResult}}", "triggerApps": "com.microsoft.VSCode" } } } ``` -------------------------------- ### Macrowhisper: Schedule & Dictate Action (Bash) Source: https://github.com/ognistik/macrowhisper/blob/main/alfred/README.md Automates scheduling an action and initiating dictation using Macrowhisper and Superwhisper. Requires specifying an action name and optionally a Superwhisper mode key. The absolute path to macrowhisper might be needed in automation apps. ```bash open -g "superwhisper://record" # optional: switch Superwhisper mode (leave out if you don’t want to change modes) open -g "superwhisper://mode?key=" macrowhisper --schedule-action "" ``` -------------------------------- ### Control Action Execution Logging in Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Provides methods to manage the logging of clipboard changes during action execution. `startActionExecution` enables logging, `finishActionExecution` disables it, and `stopEarlyMonitoring` handles session cleanup. ```swift func startActionExecution(for recordingPath: String) // Enables clipboard change logging func finishActionExecution(for recordingPath: String) // Disables clipboard change logging func stopEarlyMonitoring(for recordingPath: String) // Natural session cleanup ``` -------------------------------- ### Combined Trigger Configuration (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for combining multiple triggers (voice, application, mode) using AND logic. This allows for highly specific activation conditions. ```json { "inserts": { "specificContext": { "action": "## Meeting Notes\n{{swResult}}", "triggerVoice": "meeting notes", "triggerApps": "com.apple.Notes", "triggerModes": "dictation", "triggerLogic": "and" } } } ``` -------------------------------- ### Mode Trigger Configuration (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for mode-based triggers. Actions can be activated based on the current operating mode, with support for OR logic across multiple modes. ```json { "inserts": { "formalEmail": { "action": "Dear Sir/Madam,\n\n{{swResult}}\n\nYours sincerely", "triggerModes": "email|formal", "triggerLogic": "or" } } } ``` -------------------------------- ### AppleScript Action Configuration (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for AppleScript actions. Specifies the AppleScript code to execute and associated voice triggers. ```json { "scriptsAS": { "automateApp": { "action": "tell application \"Finder\" to set comment of (choose file) to \"{{swResult}}\"", "triggerVoice": "set comment" }, "keyboardMaestro": { "action": "tell application \"Keyboard Maestro Engine\" to do script \"MyMacro\" with parameter \"{{swResult}}\"" } } } ``` -------------------------------- ### Accessing Meta.json Fields Source: https://context7.com/ognistik/macrowhisper/llms.txt This snippet illustrates how to access various metadata fields within the Macrowhisper configuration. It shows how to retrieve information such as the mode name, front-end application details, and results from the transcription and LLM. ```json { "inserts": { "metaAccess": { "action": "Mode: {{modeName}}\nApp: {{frontAppName}}\nBundle: {{frontAppBundleId}}\nResult: {{result}}\nLLM: {{llmResult}}" } } } ``` -------------------------------- ### Regex Replacement in Placeholders (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration showcasing regex replacement within placeholders. This allows for cleaning or transforming placeholder values before insertion, supporting single and multiple replacements. ```json { "urls": { "cleanedSearch": { "action": "https://www.google.com/search?q={{result||\\.$||}}", "triggerVoice": "search" }, "multiReplace": { "action": "https://api.example.com?text={{swResult|| ||%20||\\?||%3F}}" } } } ``` -------------------------------- ### Implement Smart Logging Logic in Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Demonstrates the logic for tracking clipboard changes and conditionally logging them based on the `isExecutingAction` flag. This ensures privacy by only logging changes during active action execution. ```swift // Always track clipboard changes for restoration logic self.earlyMonitoringSessions[recordingPath]?.clipboardChanges.append(change) // Only log if we're currently executing an action if session.isExecutingAction { logDebug("[ClipboardMonitor] Detected clipboard change during action execution") } ``` -------------------------------- ### Non-Insert Action Sync Function Signature (Swift) Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Defines the function signature for clipboard synchronization with non-insert actions like URL, Shortcut, Shell, and AppleScript. It includes parameters for the action, ESC simulation, delay, recording path, metadata, and clipboard restoration. ```swift func executeNonInsertActionWithClipboardRestore( action: @escaping () -> Void, shouldEsc: Bool, actionDelay: TimeInterval, recordingPath: String, metaJson: [String: Any], restoreClipboard: Bool = true ) ``` -------------------------------- ### Enhance Meta.json with Front App Context in Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Retrieves the currently active application's name and bundle identifier and adds this context to the meta.json object. Handles main thread and background thread execution for accessing `NSWorkspace`. ```swift // Always update front app context var frontApp: NSRunningApplication? if Thread.isMainThread { frontApp = NSWorkspace.shared.frontmostApplication } else { DispatchQueue.main.sync { frontApp = NSWorkspace.shared.frontmostApplication } } // Create enhanced metaJson with context var enhancedMetaJson = metaJson enhancedMetaJson["frontAppName"] = frontApp?.localizedName enhancedMetaJson["frontApp"] = frontApp?.localizedName enhancedMetaJson["frontAppBundleId"] = frontApp?.bundleIdentifier ``` -------------------------------- ### Basic Clipboard Sync Function Signature (Swift) Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Defines the function signature for basic clipboard synchronization, used as a fallback when early monitoring data is unavailable. It takes similar parameters to the enhanced version but without the 'isAutoPaste' flag as a default. ```swift func executeInsertWithClipboardSync( insertAction: @escaping () -> Void, actionDelay: TimeInterval, shouldEsc: Bool, isAutoPaste: Bool = false, restoreClipboard: Bool = true, recordingPath: String ) ``` -------------------------------- ### Enhanced Clipboard Sync Function Signature (Swift) Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Defines the function signature for enhanced clipboard synchronization used with actions triggered by a watcher. It includes parameters for the action to be performed, delay, ESC simulation, auto-paste flag, recording path, metadata, and clipboard restoration. ```swift func executeInsertWithEnhancedClipboardSync( insertAction: @escaping () -> Void, actionDelay: TimeInterval, shouldEsc: Bool, isAutoPaste: Bool = false, recordingPath: String, metaJson: [String: Any], restoreClipboard: Bool = true ) ``` -------------------------------- ### JSON Escaping for Shortcuts Source: https://context7.com/ognistik/macrowhisper/llms.txt This snippet demonstrates how to escape JSON within a shortcut action, allowing for structured data to be passed as arguments. It defines a 'structuredData' action that includes transcription details, original text, application context, selected text, and a timestamp. ```json { "shortcuts": { "structuredData": { "action": "{\"transcription\": \"{{json:swResult}}\", \"original\": \"{{json:result}}\", \"app\": \"{{json:frontApp}}\", \"selected\": \"{{json:selectedText}}\", \"date\": \"{{json:date:ISO8601}}\"}" } } } ``` -------------------------------- ### Define Enhanced Session Structure in Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Defines the data structure for enhanced session monitoring, including clipboard states, selected text, timestamps, and activity flags. It also includes a nested structure for tracking individual clipboard changes. ```swift private struct EarlyMonitoringSession { let userOriginalClipboard: String? // User's clipboard when folder appeared let selectedText: String? // Selected text captured at session start let startTime: Date // Session start time var clipboardChanges: [ClipboardChange] = [] // All clipboard changes during session var isActive: Bool = true // Session active state var isExecutingAction: Bool = false // Controls clipboard change logging visibility let preRecordingClipboard: String? // Clipboard content from global history (within buffer window before recording) } private struct ClipboardChange { let content: String? // Clipboard content let timestamp: Date // When change occurred } ``` -------------------------------- ### Macrowhisper: Set Active & Dictate Action (Bash) Source: https://github.com/ognistik/macrowhisper/blob/main/alfred/README.md Activates a Macrowhisper action and simultaneously initiates dictation. This is useful for workflows requiring immediate action and voice input. It also supports optional mode switching and Keyboard Maestro macro triggering. ```bash macrowhisper --action "" open -g "superwhisper://record" # optional: switch Superwhisper mode open -g "superwhisper://mode?key=" # optional: trigger Keyboard Maestro menu bar macro osascript -e 'tell application "Keyboard Maestro Engine" to do script "MW MBar"' ``` -------------------------------- ### XML Extraction from LLM Results (JSON) Source: https://context7.com/ognistik/macrowhisper/llms.txt JSON configuration for extracting data from XML content provided by LLM results. Supports extracting specific tags and handling nested XML structures. ```json { "inserts": { "extractTags": { "action": "Title: {{xml:title}}\nContent: {{xml:content}}\nKeywords: {{xml:keywords}}" }, "nestedXml": { "action": "User: {{xml:user_request}}\nAI: {{xml:ai_response}}" } } } ``` -------------------------------- ### Macrowhisper: Set Action as Active (Bash) Source: https://github.com/ognistik/macrowhisper/blob/main/alfred/README.md Sets a Macrowhisper action as active, preparing it for execution. This command can be combined with other automation steps. It optionally allows switching Superwhisper modes and triggering Keyboard Maestro macros. ```bash macrowhisper --action "" # optional: switch Superwhisper mode open -g "superwhisper://mode?key=" # optional: trigger Keyboard Maestro menu bar macro osascript -e 'tell application "Keyboard Maestro Engine" to do script "MW MBar"' ``` -------------------------------- ### Macrowhisper: Schedule Only Action (Bash) Source: https://github.com/ognistik/macrowhisper/blob/main/alfred/README.md Schedules a Macrowhisper action without initiating dictation. This command can be integrated into automation workflows. Optionally, Superwhisper modes can be switched using a provided key. ```bash macrowhisper --schedule-action "" # optional: switch Superwhisper mode open -g "superwhisper://mode?key=" ``` -------------------------------- ### Macrowhisper: Execute Action (Bash) Source: https://github.com/ognistik/macrowhisper/blob/main/alfred/README.md Executes a Macrowhisper action using the last valid transcription result. This command is straightforward and requires only the action name. It's ideal for re-running or confirming previous actions. ```bash macrowhisper --exec-action "" ``` -------------------------------- ### Validate Meta.json Result in Swift Source: https://github.com/ognistik/macrowhisper/blob/main/src/PROCESSING_FLOW.md Checks if the 'result' field in the meta.json object is valid and not empty. If the validation fails, it continues to watch for updates. ```swift // Must have valid result guard let result = metaJson["result"], !(result is NSNull), (result as? String)?.isEmpty == false else { // Continue watching for updates return } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.