A PowerShell-based client for the Sleepy API that runs in the background and periodically sends "online" status with the foreground window title as the application name. When the script is closed, it automatically sends an "offline" status.
- Runs as a background client with a simple TUI (Text User Interface)
- Automatically detects the active window title and sends it as the application name
- Periodically updates status based on a configurable refresh interval
- Sends "offline" status when the script is closed
- Configurable device ID and name
- Debug mode for troubleshooting
- PowerShell 5.1 or higher
- Access to a running Sleepy API server
- Clone or download this repository
- Ensure PowerShell execution policy allows running scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
-
Run the script from PowerShell:
.\Sleepy-Client.ps1You can also enable debug mode directly from the command line:
# Enable debug mode .\Sleepy-Client.ps1 -DebugMode
-
On first run, you'll be prompted to configure:
- API URL (default: http://localhost:9010)
- Secret for authentication
- Refresh interval
- Device ID and name
-
The client will display a simple TUI with:
- Server status information
- Client status information
- Current active window information
- Available commands
-
Available commands:
- S - Open settings
- R - Force refresh now
- Q - Quit (sends offline status)
The client stores its configuration in a sleepy-client-config.json file in the same directory as the script. This file contains:
ApiUrl: The URL of the Sleepy API serverSecret: The authentication secret for the API (used in standard Bearer token authentication)RefreshInterval: How often to refresh status information (in seconds)DeviceId: The device ID to use when sending status updatesDeviceName: The device name to displayDebugMode: When enabled, outputs detailed logging information
- The client periodically checks the active window title using Windows API calls
- When the active window changes or the refresh interval passes, it sends an update to the Sleepy API
- The update includes:
- Device ID and name
- "Using" status set to true
- Application name set to the active window title
- When the script is closed (either by pressing Q or using Ctrl+C), it sends an "offline" status
This project is open source and available under the GNU GPL v3 License.