|
| 1 | +# Desktop Notifications |
| 2 | + |
| 3 | +Fabric supports desktop notifications to alert you when commands complete, which is especially useful for long-running tasks or when you're multitasking. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +Enable notifications with the `--notification` flag: |
| 8 | + |
| 9 | +```bash |
| 10 | +fabric --pattern summarize --notification < article.txt |
| 11 | +``` |
| 12 | + |
| 13 | +## Configuration |
| 14 | + |
| 15 | +### Command Line Options |
| 16 | + |
| 17 | +- `--notification`: Enable desktop notifications when command completes |
| 18 | +- `--notification-command`: Use a custom notification command instead of built-in notifications |
| 19 | + |
| 20 | +### YAML Configuration |
| 21 | + |
| 22 | +Add notification settings to your `~/.config/fabric/config.yaml`: |
| 23 | + |
| 24 | +```yaml |
| 25 | +# Enable notifications by default |
| 26 | +notification: true |
| 27 | + |
| 28 | +# Optional: Custom notification command |
| 29 | +notificationCommand: 'notify-send --urgency=normal "$1" "$2"' |
| 30 | +``` |
| 31 | +
|
| 32 | +## Platform Support |
| 33 | +
|
| 34 | +### macOS |
| 35 | +
|
| 36 | +- **Default**: Uses `osascript` (built into macOS) |
| 37 | +- **Enhanced**: Install `terminal-notifier` for better notifications: |
| 38 | + |
| 39 | + ```bash |
| 40 | + brew install terminal-notifier |
| 41 | + ``` |
| 42 | + |
| 43 | +### Linux |
| 44 | + |
| 45 | +- **Requirement**: Install `notify-send`: |
| 46 | + |
| 47 | + ```bash |
| 48 | + # Ubuntu/Debian |
| 49 | + sudo apt install libnotify-bin |
| 50 | +
|
| 51 | + # Fedora |
| 52 | + sudo dnf install libnotify |
| 53 | + ``` |
| 54 | + |
| 55 | +### Windows |
| 56 | + |
| 57 | +- **Default**: Uses PowerShell message boxes (built-in) |
| 58 | + |
| 59 | +## Custom Notification Commands |
| 60 | + |
| 61 | +The `--notification-command` flag allows you to use custom notification scripts or commands. The command receives the title as `$1` and message as `$2` as shell positional arguments. |
| 62 | + |
| 63 | +**Security Note**: The title and message content are properly escaped to prevent command injection attacks from AI-generated output containing shell metacharacters. |
| 64 | + |
| 65 | +### Examples |
| 66 | + |
| 67 | +**macOS with custom sound:** |
| 68 | + |
| 69 | +```bash |
| 70 | +fabric --pattern analyze_claims --notification-command 'osascript -e "display notification \"$2\" with title \"$1\" sound name \"Ping\""' < document.txt |
| 71 | +``` |
| 72 | + |
| 73 | +**Linux with urgency levels:** |
| 74 | + |
| 75 | +```bash |
| 76 | +fabric --pattern extract_wisdom --notification-command 'notify-send --urgency=critical "$1" "$2"' < video-transcript.txt |
| 77 | +``` |
| 78 | + |
| 79 | +**Custom script:** |
| 80 | + |
| 81 | +```bash |
| 82 | +fabric --pattern summarize --notification-command '/path/to/my-notification-script.sh "$1" "$2"' < report.pdf |
| 83 | +``` |
| 84 | + |
| 85 | +**Testing your custom command:** |
| 86 | + |
| 87 | +```bash |
| 88 | +# Test that $1 and $2 are passed correctly |
| 89 | +fabric --pattern raw_query --notification-command 'echo "Title: $1, Message: $2"' "test input" |
| 90 | +``` |
| 91 | + |
| 92 | +## Notification Content |
| 93 | + |
| 94 | +Notifications include: |
| 95 | + |
| 96 | +- **Title**: "Fabric Command Complete" or "Fabric: [pattern] Complete" |
| 97 | +- **Message**: Brief summary of the output (first 100 characters) |
| 98 | + |
| 99 | +For long outputs, the message is truncated with "..." to fit notification display limits. |
| 100 | + |
| 101 | +## Use Cases |
| 102 | + |
| 103 | +### Long-Running Tasks |
| 104 | + |
| 105 | +```bash |
| 106 | +# Process large document with notifications |
| 107 | +fabric --pattern analyze_paper --notification < research-paper.pdf |
| 108 | +
|
| 109 | +# Extract wisdom from long video with alerts |
| 110 | +fabric -y "https://youtube.com/watch?v=..." --pattern extract_wisdom --notification |
| 111 | +``` |
| 112 | + |
| 113 | +### Background Processing |
| 114 | + |
| 115 | +```bash |
| 116 | +# Process multiple files and get notified when each completes |
| 117 | +for file in *.txt; do |
| 118 | + fabric --pattern summarize --notification < "$file" & |
| 119 | +done |
| 120 | +``` |
| 121 | + |
| 122 | +### Integration with Other Tools |
| 123 | + |
| 124 | +```bash |
| 125 | +# Combine with other commands |
| 126 | +curl -s "https://api.example.com/data" | \ |
| 127 | + fabric --pattern analyze_data --notification --output results.md |
| 128 | +``` |
| 129 | + |
| 130 | +## Troubleshooting |
| 131 | + |
| 132 | +### No Notifications Appearing |
| 133 | + |
| 134 | +1. **Check system notifications are enabled** for Terminal/your shell |
| 135 | +2. **Verify notification tools are installed**: |
| 136 | + - macOS: `which osascript` (should exist) |
| 137 | + - Linux: `which notify-send` |
| 138 | + - Windows: `where.exe powershell` |
| 139 | + |
| 140 | +3. **Test with simple command**: |
| 141 | + |
| 142 | + ```bash |
| 143 | + echo "test" | fabric --pattern raw_query --notification --dry-run |
| 144 | + ``` |
| 145 | + |
| 146 | +### Notification Permission Issues |
| 147 | + |
| 148 | +On some systems, you may need to grant notification permissions to your terminal application: |
| 149 | + |
| 150 | +- **macOS**: System Preferences → Security & Privacy → Privacy → Notifications → Enable for Terminal |
| 151 | +- **Linux**: Depends on desktop environment; usually automatic |
| 152 | +- **Windows**: Usually works by default |
| 153 | + |
| 154 | +### Custom Commands Not Working |
| 155 | + |
| 156 | +- Ensure your custom notification command is executable |
| 157 | +- Test the command manually with sample arguments |
| 158 | +- Check that all required dependencies are installed |
| 159 | + |
| 160 | +## Advanced Configuration |
| 161 | + |
| 162 | +### Environment-Specific Settings |
| 163 | + |
| 164 | +Create different configuration files for different environments: |
| 165 | + |
| 166 | +```bash |
| 167 | +# Work computer (quieter notifications) |
| 168 | +fabric --config ~/.config/fabric/work-config.yaml --notification |
| 169 | +
|
| 170 | +# Personal computer (with sound) |
| 171 | +fabric --config ~/.config/fabric/personal-config.yaml --notification |
| 172 | +``` |
| 173 | + |
| 174 | +### Integration with Task Management |
| 175 | + |
| 176 | +```bash |
| 177 | +# Custom script that also logs to task management system |
| 178 | +notificationCommand: '/usr/local/bin/fabric-notify-and-log.sh "$1" "$2"' |
| 179 | +``` |
| 180 | + |
| 181 | +## Examples |
| 182 | + |
| 183 | +See `docs/notification-config.yaml` for a complete configuration example with various notification command options. |
0 commit comments