A lightweight daemon written in Go that tracks your application usage time on Ubuntu/Linux systems. Perfect for monitoring productivity and understanding how you spend time across different applications.
- 🕒 Automatic Time Tracking - Monitors active application usage in real-time
- 📊 Simple Reporting - Generate usage reports with time breakdown
- 🚀 Lightweight Daemon - Runs efficiently in the background
- 💾 Persistent Storage - Saves data between sessions
- 🛠 Easy CLI Control - Simple start/stop/report commands
# Install xdotool for window detection
sudo apt update
sudo apt install xdotool# Clone or download the source code
git clone https://github.com/Golangcodes/app-tracker.git
cd app-tracker
# Build the binary
go build -o app-tracker
# Make executable
chmod +x app-tracker# Start the tracking daemon
./app-tracker start
# Use your computer normally...
# Work in terminal, browser, editor, etc.
# Check your usage report
./app-tracker report
# Stop tracking when done
./app-tracker stop| Command | Description |
|---|---|
./app-tracker start |
Start the tracking daemon in background |
./app-tracker stop |
Stop the running daemon |
./app-tracker report |
Show usage summary report |
./app-tracker |
Show help and run in foreground for testing |
$ ./app-tracker report
=== Usage Report ===
brave : 2.1 hours
neovim : 3.5 hours
terminal : 0.8 hours
tmux : 1.2 hours
ide : 0.5 hours- Polling: Checks active window every 3 seconds using
xdotool - App Detection: Identifies applications based on window titles
- Session Tracking: Records time spent in each application
- Data Storage: Saves sessions to
/tmp/app-usage.json
The tracker automatically detects:
- Brave Browser - Web browsing and AI tools
- Neovim - Code editing sessions
- Terminal - Command line usage
- tmux - Terminal multiplexer sessions
- IDEs - VS Code, GoLand, IntelliJ
- Other - Fallback for unidentified applications
For automatic startup, create a systemd service:
# Create service file
sudo nano /etc/systemd/system/app-tracker.serviceAdd the following content:
[Unit]
Description=App Usage Tracker
After=network.target
[Service]
Type=simple
User=your-username
ExecStart=/path/to/your/app-tracker
WorkingDirectory=/path/to/your/
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetEnable the service:
sudo systemctl daemon-reload
sudo systemctl enable app-tracker
sudo systemctl start app-trackerYou can modify the app detection logic in the detectApp() function to add support for additional applications or customize the naming.
- Binary: Your compiled
app-trackerexecutable - PID File:
/tmp/app-tracker.pid(process tracking) - Data File:
/tmp/app-usage.json(usage statistics)
-
"xdotool not found"
sudo apt install xdotool
-
Daemon not starting
- Check if another instance is running:
./app-tracker stop - Verify xdotool is installed
- Check permissions on the binary
- Check if another instance is running:
-
No data in report
- Ensure daemon is running: check PID file
- Verify the data file exists:
/tmp/app-usage.json
Run in foreground to see real-time activity:
./app-trackerThe code is structured to be easily extensible:
- Add new app detection in
detectApp()function - Modify tracking interval in the ticker (default: 3 seconds)
- Enhance reporting with additional metrics
# Requires Go 1.16+
go mod init app-tracker
go build -o app-trackerMIT License - feel free to modify and distribute.
Contributions welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
Note: This tool respects your privacy - all data is stored locally and never transmitted elsewhere.