This guide helps you diagnose and fix common issues with Refocus Shell.
Refocus Shell uses standardized exit codes to help with script integration and error diagnosis:
| Exit Code | Meaning | Common Causes |
|---|---|---|
0 |
Success | Command completed successfully |
1 |
General Error | Unspecified error, session not found, etc. |
2 |
Invalid Arguments | Missing required arguments, invalid format, etc. |
3 |
Database Error | Database connection failed, SQL errors, etc. |
4 |
Permission Error | Insufficient file permissions, etc. |
5 |
File System Error | File not found, disk space issues, etc. |
6 |
Configuration Error | Invalid config, missing config files, etc. |
7 |
State Error | Invalid application state (already active, disabled, etc.) |
#!/bin/bash
focus on "my-project"
case $? in
0) echo "Focus started successfully" ;;
2) echo "Invalid arguments - check usage" ;;
7) echo "Focus already active or disabled" ;;
*) echo "Unexpected error occurred" ;;
esac# Success
focus on "coding" # Exit code: 0
# Invalid arguments
focus on # Exit code: 2 (missing project)
focus past add # Exit code: 2 (missing arguments)
# State errors
focus off # Exit code: 7 (no active session)
focus on "test" # Exit code: 7 (already active)
# General errors
focus past delete 999 # Exit code: 1 (session not found)$ focus on "test"
bash: focus: command not found# Check if focus is installed
which focus
ls -la ~/.local/refocus/
# Check shell integration
type focus
grep -r "refocus" ~/.bashrc ~/.profileOption 1: Reinstall
cd refocus-shell
./setup.sh install
source ~/.bashrcOption 2: Manual shell integration
echo 'source ~/.local/refocus/lib/focus-function.sh' >> ~/.bashrc
source ~/.bashrcOption 3: Check PATH
# If using manual installation
echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.bashrc
source ~/.bashrc$ focus on "test"
./focus: line 25: sqlite3: command not found# Debian/Ubuntu
sudo apt-get install sqlite3 libnotify-bin jq
# Arch/Manjaro
sudo pacman -S sqlite libnotify jq
# Fedora/RHEL
sudo dnf install sqlite libnotify jq
# openSUSE
sudo zypper install sqlite3 libnotify-tools jq$ focus on "test"
mkdir: cannot create directory '/home/user/.local/refocus': Permission denied# Fix directory permissions
sudo chown -R $USER:$USER ~/.local
chmod 755 ~/.local
# Create directories manually
mkdir -p ~/.local/refocus
chmod 755 ~/.local/refocus$ focus status
❌ Database not found: /home/user/.local/refocus/refocus.db# Check database file
ls -la ~/.local/refocus/refocus.db
# Check directory
ls -la ~/.local/refocus/
# Check environment variable
echo $REFOCUS_DBInitialize new database:
focus initRestore from backup:
# Check for automatic backups
ls ~/.local/refocus/refocus.db.backup.*
# Restore latest backup
cp ~/.local/refocus/refocus.db.backup.* ~/.local/refocus/refocus.dbImport from export:
focus import backup.json$ focus status
Error: database disk image is malformed# Check database integrity
sqlite3 ~/.local/refocus/refocus.db "PRAGMA integrity_check;"
# Check file permissions
ls -la ~/.local/refocus/refocus.db
# Check disk space
df -h ~/.local/refocus/Option 1: Restore from backup
ls ~/.local/refocus/refocus.db.backup.*
cp ~/.local/refocus/refocus.db.backup.20250926_143022 ~/.local/refocus/refocus.dbOption 2: Recover data
# Try to dump recoverable data
sqlite3 ~/.local/refocus/refocus.db ".dump" > recovered_data.sql
# Create new database
rm ~/.local/refocus/refocus.db
focus init
# Import recovered data
sqlite3 ~/.local/refocus/refocus.db < recovered_data.sqlOption 3: Nuclear option (loses all data)
focus reset$ focus on "test"
Error: in prepare, no such table: sessions# Force migration
focus init
# Or reset and restore
focus export backup # If possible
focus reset
focus import backup.json- No desktop notifications during focus sessions
- No idle reminders when not focusing
# Check nudge status
focus nudge status
# Test notification system
focus nudge test
# Check if notifications are enabled
notify-send "Test" "This should appear"
# Check desktop environment
echo $XDG_CURRENT_DESKTOP
echo $DISPLAY
echo $WAYLAND_DISPLAYEnable nudges:
focus nudge enableFix notification dependencies:
# Install notification tools
sudo apt-get install libnotify-bin
# Test manual notification
notify-send "Test" "Manual test"Check cron jobs:
# View active cron jobs
crontab -l
# Look for refocus entries
crontab -l | grep focus-nudgeDebug cron environment:
# Enable verbose logging
export REFOCUS_VERBOSE=true
# Check logs
journalctl -f | grep focus-nudge
tail -f /var/log/syslog | grep focus-nudgeBroadcast message from user@host (Thu Sep 26 14:20:02 2025):
FOCUS NUDGE: Focus Reminder - You're focusing on: project (10m elapsed)Desktop notifications are failing, falling back to wall command.
Fix display environment for cron:
# Check current environment
env | grep -E "(DISPLAY|WAYLAND|DBUS)"
# The installer should handle this automatically
./setup.sh installManual cron environment fix:
# Edit crontab
crontab -e
# Ensure the entry includes environment variables:
DISPLAY=:0
WAYLAND_DISPLAY=wayland-0
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
*/10 * * * * /home/user/.local/refocus/focus-nudge- Both desktop notifications AND wall messages
- Multiple notifications for the same event
# Check for multiple cron entries
crontab -l | grep focus-nudge
# Remove duplicate entries
crontab -e # Remove extra lines
# Check for background processes
ps aux | grep focus-nudge⏳ [project]doesn't appear in prompt- Prompt shows wrong project
- Prompt doesn't clear after
focus off
# Check shell function
type focus
type focus-update-prompt
# Check original prompt backup
echo $REFOCUS_ORIGINAL_PS1
# Check current prompt
echo $PS1Manual prompt update:
focus-update-promptReinstall shell integration:
./setup.sh install
source ~/.bashrcManual prompt restoration:
focus-restore-prompt
export PS1="$REFOCUS_ORIGINAL_PS1"- Prompt shows in terminals where focus wasn't started
- Inconsistent prompt across terminals
This is normal behavior - the prompt indicator works across all terminals to show your current focus state.
# Remove prompt integration
export REFOCUS_PROMPT_FORMAT=""
# Or disable via configuration
focus config set PROMPT_FORMAT ""$ focus on "project"
❌ Cannot start new focus session while one is paused.# Check current status
focus status
# Handle paused session
focus continue # Resume paused session
# OR
focus off # Complete paused session- Sessions missing from
focus past list - Incorrect session times
- Missing notes
# Check recent sessions
focus past list 20
focus past list -n 50 # Alternative flag format
# Check database directly
sqlite3 ~/.local/refocus/refocus.db "SELECT * FROM sessions ORDER BY id DESC LIMIT 10;"
# Check for data corruption
sqlite3 ~/.local/refocus/refocus.db "PRAGMA integrity_check;"# Restore from backup
focus import backup.json
# Or check automatic backups
ls ~/.local/refocus/refocus.db.backup.*
cp ~/.local/refocus/refocus.db.backup.* ~/.local/refocus/refocus.db- Negative session durations
- Impossibly long sessions
- Wrong elapsed time in nudges
# Check system time
date
# Check session data
focus past list 5
focus past list -n 10 # Alternative flag format
# Check for invalid sessions
sqlite3 ~/.local/refocus/refocus.db "SELECT * FROM sessions WHERE duration_seconds < 0 OR duration_seconds > 86400;"# Fix system time
sudo ntpdate -s time.nist.gov
# Delete invalid sessions
focus past delete <session_id>
# Or modify session times
focus past modify <session_id> "project" "14:00" "16:00"focus statustakes several secondsfocus past listis very slow- Reports take a long time to generate
# Check database size
ls -lh ~/.local/refocus/refocus.db
# Count sessions
sqlite3 ~/.local/refocus/refocus.db "SELECT COUNT(*) FROM sessions;"
# Check for database issues
sqlite3 ~/.local/refocus/refocus.db "PRAGMA integrity_check;"# Optimize database
sqlite3 ~/.local/refocus/refocus.db "VACUUM;"
sqlite3 ~/.local/refocus/refocus.db "ANALYZE;"
# Clean up old sessions
focus past list 100
focus past list -n 200 # Alternative flag format
# Delete very old sessions manually:
focus past delete <old_session_id>- High memory usage during report generation
- System becomes slow when using Refocus Shell
# Generate smaller reports
focus report custom 7 # Instead of custom 365
# Use database queries for large datasets
sqlite3 ~/.local/refocus/refocus.db "SELECT project, COUNT(*) FROM sessions GROUP BY project;"# Enable verbose output
export REFOCUS_VERBOSE=true
# Run commands with debug info
focus on "debug-test"
focus status
focus offVerbose mode shows:
- Database queries being executed
- File operations
- Cron job management
- Notification attempts
- Prompt updates
# Check system logs for refocus entries
journalctl -u cron | grep focus-nudge
tail -f /var/log/syslog | grep focus
# Check user logs
journalctl --user | grep focus# Enable logging to file
export REFOCUS_LOG_FILE="$HOME/.local/refocus/debug.log"
# Run commands and check log
focus on "test"
cat ~/.local/refocus/debug.log# Backup data first
focus export emergency-backup
# Uninstall completely
./setup.sh uninstall
rm -rf ~/.local/refocus
rm -rf ~/.config/refocus-shell
# Clean shell configuration
grep -v "refocus" ~/.bashrc > ~/.bashrc.new
mv ~/.bashrc.new ~/.bashrc
# Reinstall
./setup.sh install
source ~/.bashrc
# Restore data
focus import emergency-backup.json# Find backup files
find ~/.local/refocus -name "*.backup.*"
# Restore most recent
cp ~/.local/refocus/refocus.db.backup.* ~/.local/refocus/refocus.db# Find export files
find ~ -name "refocus-export-*.json" -o -name "refocus-export-*.sql"
# Import most recent
focus import ~/path/to/export.json# If you've been versioning exports
cd ~/refocus-backups
git log --oneline
git checkout <commit> -- refocus-data.json
focus import refocus-data.jsonBefore seeking help, gather this information:
# System information
uname -a
echo $SHELL
echo $XDG_CURRENT_DESKTOP
# Refocus Shell version and status
focus help
focus status
focus config show
# Installation details
ls -la ~/.local/refocus/
ls -la ~/.local/bin/focus
# Error reproduction
export REFOCUS_VERBOSE=true
# Run the problematic command- Installation issues: Reinstall with
./setup.sh install - Database issues:
focus initor restore from backup - Notification issues: Check dependencies and cron jobs
- Prompt issues:
focus-update-promptor reinstall - Performance issues: Database optimization with
VACUUM - Data loss: Restore from automatic backups or exports
# Nuclear option - complete reset (LOSES ALL DATA)
focus reset
# Start fresh
focus init
focus on "recovery-test"
focus statusNext: Advanced Usage