watch
The watch command is the core monitoring functionality of kasl. It tracks user activity to automatically detect work sessions, breaks, and workday boundaries. The command can run in background daemon mode for daily use or in foreground mode for debugging and development.
kasl watch [OPTIONS]Options
Section titled “Options”-
--foreground: Run the watcher in the foreground for debugging- Provides real-time feedback about detected activity
- Shows pause events and workday state changes
- Useful for testing configuration changes and troubleshooting
-
--stop,-s: Stop any running background watcher process- Terminates the background daemon if it’s currently running
- Safely closes database connections and cleans up system resources
- Useful before system shutdown or when restarting with new configuration
Operating Modes
Section titled “Operating Modes”Background Daemon Mode (Default)
Section titled “Background Daemon Mode (Default)”kasl watchRuns silently in the background, perfect for daily use:
- Automatically starts monitoring when you begin working
- Detects work vs. break periods based on configurable thresholds
- Records workday start/end times and pause periods
- Maintains activity state across application restarts
Foreground Debug Mode
Section titled “Foreground Debug Mode”kasl watch --foregroundRuns in the terminal with detailed logging:
- Real-time activity detection feedback
- Pause event notifications
- Workday state change logging
- Configuration testing and validation
Stop Mode
Section titled “Stop Mode”kasl watch --stopTerminates background monitoring:
- Stops any running daemon process
- Properly closes database connections
- Cleans up system resources
How It Works
Section titled “How It Works”Activity Detection
Section titled “Activity Detection”The monitor tracks these input events:
- Keyboard presses and releases
- Mouse button clicks
- Mouse movement
- Mouse wheel scrolling
Work Session Detection
Section titled “Work Session Detection”- Input Detection: Monitors keyboard and mouse activity using system APIs
- Activity Analysis: Determines work vs. break periods based on configurable thresholds
- Database Recording: Automatically records workday start/end times and pause periods
- State Management: Maintains activity state across application restarts
Configuration Settings
Section titled “Configuration Settings”The monitor behavior is controlled by configuration settings:
pause_threshold: Seconds of inactivity before recording a pausepoll_interval: Milliseconds between activity checksactivity_threshold: Seconds of activity needed to start a workdaymin_pause_duration: Minimum pause length to record (filters noise)
Examples
Section titled “Examples”Daily Usage
Section titled “Daily Usage”# Start background monitoring (recommended for daily use)kasl watch
# Check if monitoring is runningps aux | grep kaslDebugging and Development
Section titled “Debugging and Development”# Run in foreground to see activity detection in real-timekasl watch --foreground
# Test configuration changeskasl watch --foreground# Press Ctrl+C to stopSystem Management
Section titled “System Management”# Stop monitoring before system shutdownkasl watch --stop
# Restart with new configurationkasl watch --stopkasl watchDatabase Operations
Section titled “Database Operations”During monitoring, the system automatically:
- Creates workday records when sustained activity is detected
- Records pause start times when inactivity threshold is exceeded
- Records pause end times when activity resumes
- Updates workday end times when monitoring stops
Signal Handling
Section titled “Signal Handling”The daemon process responds to these signals:
- SIGTERM: Graceful shutdown (Unix)
- SIGINT: Interrupt signal (Unix)
- Ctrl+C: Console interrupt (Windows)
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Daemon already running
# Check if daemon is runningps aux | grep kasl
# Stop existing daemonkasl watch --stop
# Start new daemonkasl watchPermission issues
# Run with elevated permissions if neededsudo kasl watch --foregroundConfiguration errors
# Test configuration in foreground modekasl watch --foregroundDebug Mode
Section titled “Debug Mode”Enable debug logging for troubleshooting:
RUST_LOG=kasl=debug kasl watch --foregroundProcess Management
Section titled “Process Management”# Check daemon statusps aux | grep kasl
# View daemon logs (if configured)tail -f ~/.local/share/lacodda/kasl/kasl.log
# Force stop daemon (if needed)pkill -f kaslIntegration with Other Commands
Section titled “Integration with Other Commands”The watch command works with other kasl commands:
task: Create and manage tasks while monitoringreport: Generate reports based on monitored datapauses: Record absences that monitoring did not detectpauses: View recorded breaks and pauses
Best Practices
Section titled “Best Practices”Daily Workflow
Section titled “Daily Workflow”- Start monitoring at the beginning of your workday
- Let it run in the background during work
- Stop monitoring before system shutdown
- Review data using
reportandpausescommands
Configuration
Section titled “Configuration”- Adjust thresholds based on your work patterns
- Test settings using foreground mode
- Monitor performance and adjust as needed
- Backup configuration regularly
Troubleshooting
Section titled “Troubleshooting”- Use foreground mode for debugging
- Check system permissions for input device access
- Verify database connectivity
- Review logs for error messages