A cross-platform desktop application that automatically brings selected browser windows to the foreground based on configurable rules.
- System Tray Operation: Runs primarily in the system tray
- Automatic Focus: Brings Chromium-based browser windows to foreground
- Multiple Modes: Single mode (focus one window) or Cycle mode (rotate through windows)
- Configurable Interval: Set focus interval from 1 second to 24 hours
- Idle Detection: Optional idle detection to only focus when user is away
- Global Shortcut: Press
Ctrl+Alt+Qto stop scheduler and exit
- Windows: Full support using Windows API
- Linux: X11 environments only (requires xdotool and xprintidle)
- Node.js 18+
- npm 9+
npm installRun the application in development mode:
npm run devThis will compile TypeScript and launch Electron.
Build the application:
npm run build# Package for current platform
npm run pack
# Package for Windows
npm run dist:win
# Package for Linux
npm run dist:linuxOn Linux, the following dependencies are required:
Window manipulation tool used to detect and focus windows.
# Debian/Ubuntu
sudo apt install xdotool
# Fedora
sudo dnf install xdotool
# Arch Linux
sudo pacman -S xdotoolTool to detect user idle time.
# Debian/Ubuntu
sudo apt install xprintidle
# Fedora
sudo dnf install xprintidle
# Arch Linux
sudo pacman -S xprintidleIn single mode, the scheduler focuses the first selected window every interval:
- Start scheduler with selected windows
- Every
intervalMsmilliseconds:- Check if user is idle (if idle threshold is set)
- If idle, focus the first selected window
- Skip if already focused or window doesn't exist
In cycle mode, the scheduler rotates through selected windows:
- Start scheduler with selected windows
- Every
intervalMsmilliseconds:- Check if user is idle (if idle threshold is set)
- If idle, focus the next window in the sequence
- Skip if already focused or window doesn't exist
- Move to next window for next cycle
- Never focus if already focused: Skips focus attempts if the target window is already active
- Window existence check: Verifies window still exists before attempting focus
- Idle detection: Optional threshold to only focus when user is away
- Graceful error handling: Handles missing windows and errors without crashing
Configuration is stored in:
- Windows:
%APPDATA%/FocusKeeper/config.json - Linux:
$HOME/.config/FocusKeeper/config.json
| Field | Type | Description | Default |
|---|---|---|---|
mode |
string | "single" or "cycle" | "single" |
selectedWindows |
array | Window IDs to focus | [] |
intervalMs |
number | Focus interval in ms | 30000 |
idleThresholdMs |
number/null | Idle threshold in ms | null |
globalShortcut |
string | Global shortcut to exit | "CommandOrControl+Alt+Q" |
intervalMs: Clamped to 1,000 - 86,400,000 ms (1s to 24h)idleThresholdMs: Clamped to 1,000 - 86,400,000 ms if set
- Launch: App starts in system tray
- Open Settings: Double-click tray icon or use tray menu
- Select Windows: Check browser windows you want to focus
- Choose Mode: Single (one window) or Cycle (rotate through)
- Set Interval: Choose preset or enter custom interval
- Start: Click "Start Scheduler"
- Ctrl+Alt+Q: Stop scheduler and exit application immediately
The app detects these Chromium-based browsers:
- Google Chrome
- Chromium
- Microsoft Edge
- Brave
Key actions are logged to console:
- Scheduler start/stop
- Window focus attempts
- Errors and warnings
⚠️ Warning: Focus Stealing Behavior
This application automatically brings windows to the foreground. This can:
- Interrupt typing: If you're typing in another application, the focus switch can interrupt your work
- Cause data loss: Focus changes in applications with unsaved data could lead to lost work
- Be disruptive: Frequent focus changes can be annoying during focused work
- Use with caution in professional environments
- Set appropriate intervals (avoid very short intervals)
- Enable idle detection to only focus when you're away
- Test with non-critical applications first
focuskeeper/
├── src/
│ ├── main/
│ │ ├── main.ts # Main entry point
│ │ ├── tray.ts # System tray management
│ │ ├── ipc.ts # IPC handlers
│ │ ├── scheduler.ts # Focus scheduling
│ │ ├── focusManager.ts # Focus operations
│ │ ├── windowManager.ts# Window detection
│ │ ├── idleMonitor.ts # Idle detection
│ │ └── preload.ts # Preload script
│ ├── config/
│ │ ├── defaultConfig.ts# Default configuration
│ │ └── configManager.ts# Config persistence
│ ├── platform/
│ │ ├── windows.ts # Windows-specific code
│ │ └── linux.ts # Linux-specific code
│ └── renderer/
│ ├── index.html # Settings UI
│ ├── app.ts # UI logic
│ └── style.css # Styles
├── package.json
├── tsconfig.json
└── README.md
MIT