A simple, offline terminal application to track your application usage time. Built with Python standard library only - no external dependencies required.
- Cross-Platform: Works on Linux, macOS, and Windows
- No Dependencies: Uses only Python standard library
- Offline: All data stored locally in JSON files
- Privacy-Focused: No data leaves your computer
- Idle Detection: Automatically pauses tracking when inactive
- Detailed Statistics: View daily, weekly, and all-time usage stats
- Simple Interface: Easy-to-use terminal menu
# Clone or download the project
cd screen_time_tracker
# Run the application
python -m screen_time_tracker# Install in development mode
pip install -e .
# Run using command
screen-time-tracker
# or
sttInstall xdotool for window detection:
sudo apt install xdotoolOr alternatively:
sudo apt install x11-utils # for xpropNo additional requirements - uses built-in AppleScript.
No additional requirements - uses built-in PowerShell.
python -m screen_time_tracker- Start tracking - Begin monitoring your application usage
- Stop tracking - Stop monitoring and save current session
- View today's usage - See detailed breakdown of today's app usage
- View weekly summary - See usage statistics for the past 7 days
- View all-time statistics - See complete usage history
- Clear old data - Remove entries older than specified days
- Check system compatibility - Verify window detection is working
- Exit - Stop tracking and exit the application
============================================================
SCREEN TIME & APP USAGE TRACKER
File-Based Offline Tracker
============================================================
========================================
TRACKER STATUS
========================================
Status: TRACKING
Current App: Visual Studio Code
Session Duration: 5m 23s
Sessions Recorded: 12
Total Tracked: 2h 15m 30s
========================================
----------------------------------------
MAIN MENU
----------------------------------------
[1] Start tracking
[2] Stop tracking
[3] View today's usage
[4] View weekly summary
[5] View all-time statistics
[6] Clear old data
[7] Check system compatibility
[0] Exit
----------------------------------------
Activity data is stored in JSON format at:
screen_time_tracker/data/activity_log.json
[
{
"app_name": "Visual Studio Code",
"start_time": "2024-01-15T10:30:00",
"end_time": "2024-01-15T11:45:30",
"duration_seconds": 4530,
"date": "2024-01-15"
}
]You can modify tracking behavior by editing constants in tracker.py:
POLL_INTERVAL = 2 # Seconds between window checks
IDLE_THRESHOLD = 300 # Seconds of inactivity before idle state
MIN_SESSION_DURATION = 3 # Minimum seconds to record a sessionscreen_time_tracker/
├── __init__.py # Package initialization
├── __main__.py # Entry point
├── menu.py # Terminal menu interface
├── tracker.py # Core tracking logic
├── storage.py # JSON file storage
├── window_detector.py # Cross-platform window detection
├── data/
│ └── activity_log.json # Activity data (created on first run)
├── requirements.txt # Dependencies (none required)
├── setup.py # Package setup
├── README.md # This file
├── LICENSE # MIT License
└── .gitignore # Git ignore rules
- Window Detection: The tracker polls the system every 2 seconds to detect the currently active window
- Session Management: When you switch applications, the previous session is saved and a new one begins
- Idle Detection: If no window change is detected for 5 minutes, the tracker enters idle state
- Data Storage: Sessions are saved to a JSON file with atomic writes to prevent corruption
Linux: Install xdotool
sudo apt install xdotoolmacOS: Grant accessibility permissions to Terminal/iTerm in System Preferences > Security & Privacy > Privacy > Accessibility
Windows: Run as administrator if detection fails
- Check system compatibility using menu option 7
- Ensure the application has necessary permissions
- Verify the
data/directory is writable
The application automatically creates backups. If the main file is corrupted, it will attempt to restore from activity_log.json.backup.
Contributions are welcome! Please feel free to submit issues or pull requests.
MIT License - see LICENSE file for details.
This application:
- Stores all data locally on your computer
- Does not send any data over the network
- Does not require an internet connection
- Only tracks application names, not window contents or keystrokes