A PyGTK 3 application for managing night mode (dark/light theme switching) in Linux desktop environments
Project description
Nightswitch
Overview
Nightswitch is a sophisticated theme management application that brings intelligent dark/light mode switching to Linux desktop environments. Built with PyGTK 4, it provides seamless integration with your desktop while offering multiple automation modes to match your workflow and preferences.
โจ Features
๐๏ธ Multiple Switching Modes
- Manual Mode: Instant theme switching via system tray interface
- Schedule Mode: Time-based automatic switching with customizable schedules
- Location Mode: Sunrise/sunset-based switching using your geographic location
๐ Extensible Plugin System
- Ubuntu Budgie: Primary desktop environment support
- Generic GTK: Broad compatibility with GTK-based environments
- Extensible Architecture: Plugin system for additional desktop environments
๐ฅ๏ธ Desktop Integration
- System Tray: Minimal footprint with quick access controls
- Notifications: Non-intrusive status updates
- Autostart: Seamless integration with desktop session management
๐ Smart Location Services
- IP-based Location: Automatic location detection for sunrise/sunset calculations
- Privacy-focused: Optional location services with user control
- Offline Fallback: Manual location configuration when needed
๐ฅ๏ธ Supported Desktop Environments
| Desktop Environment | Status | Plugin |
|---|---|---|
| Ubuntu Budgie | โ Primary Support | Built-in |
| GNOME | ๐ Planned | Plugin |
| KDE Plasma | ๐ Planned | Plugin |
| XFCE | ๐ Planned | Plugin |
| Generic GTK | โ Basic Support | Built-in |
๐ Requirements
- Operating System: Linux (X11/Wayland)
- Python: 3.13 or higher
- Desktop: GTK-based environment with system tray support
- Dependencies: PyGObject (PyGTK 4), requests, python-dateutil
๐ฆ Installation
Flatpak (Recommended)
The easiest way to install Nightswitch is through Flatpak, which provides sandboxed execution and automatic updates.
# Install from Flathub (when available)
flatpak install flathub org.nightswitch.Nightswitch
# Or build and install locally
flatpak-builder build-dir org.nightswitch.Nightswitch.yml --install --user --force-clean
From Source
For developers or users who prefer traditional installation:
# Clone the repository
git clone https://github.com/pygillier/nightswitch.git
cd nightswitch
# Install using the installation script (recommended)
./install.sh --user # For user installation
./install.sh --system # For system-wide installation (requires sudo)
# Or install manually with uv
uv pip install -e .
Installation Script Options
The install.sh script provides several options:
# Install for current user (default)
./install.sh --user
# Install system-wide (requires sudo)
./install.sh --system
# Uninstall Nightswitch
./install.sh --uninstall
# Show help
./install.sh --help
The installation script will:
- Install required dependencies
- Install Nightswitch package
- Create desktop entry
- Set up autostart via desktop file and systemd service
- Install application icon
๐ Usage
Starting the Application
# Launch Nightswitch
nightswitch
# Launch minimized to system tray
nightswitch --minimized
# The application will appear in your system tray
# Look for the theme switcher icon in your system tray area
Autostart Configuration
Nightswitch can be configured to start automatically when you log in:
# Enable autostart (creates desktop and systemd service entries)
./enable-autostart.sh
# Disable autostart
./enable-autostart.sh --disable
The installation script automatically sets up autostart. This separate script is provided for users who want to enable or disable autostart after installation.
Basic Operations
- Manual Switching: Click the system tray icon and select "Switch to Dark/Light Mode"
- Schedule Mode: Configure automatic switching times in the settings
- Location Mode: Enable location-based switching for sunrise/sunset automation
Configuration
Nightswitch follows the FreeDesktop.org XDG Base Directory Specification for configuration storage:
- Configuration:
~/.config/nightswitch/(or$XDG_CONFIG_HOME/nightswitch/) - Application Data:
~/.local/share/nightswitch/(or$XDG_DATA_HOME/nightswitch/) - Cache:
~/.cache/nightswitch/(or$XDG_CACHE_HOME/nightswitch/) - State:
~/.local/state/nightswitch/(or$XDG_STATE_HOME/nightswitch/)
The main configuration file is stored as config.json in the configuration directory.
๐ ๏ธ Development
Setting Up Development Environment
# Clone the repository
git clone https://github.com/pygillier/nightswitch.git
cd nightswitch
# Install development dependencies
uv pip install -e ".[dev]"
# Or with pip
pip install -e ".[dev]"
Development Workflow
Important: This project uses uv for all Python operations. Never use pip or direct python commands.
# Run tests
uv run pytest
# Code formatting
uv run black src tests
uv run isort src tests
# Type checking
uv run mypy src
# Linting
uv run flake8 src tests
# Run all checks
uv run pytest && uv run black --check src tests && uv run isort --check src tests && uv run mypy src && uv run flake8 src tests
Testing
The project includes comprehensive test coverage:
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=src/nightswitch --cov-report=html
# Run specific test categories
uv run pytest -m unit # Unit tests only
uv run pytest -m integration # Integration tests only
๐๏ธ Architecture
Nightswitch follows a modular architecture designed for extensibility and maintainability:
src/nightswitch/
โโโ core/ # Application lifecycle and mode management
โ โโโ app.py # Main application controller
โ โโโ modes/ # Mode implementations (manual, schedule, location)
โ โโโ config.py # Configuration management
โโโ plugins/ # Desktop environment plugins
โ โโโ base.py # Plugin interface
โ โโโ budgie.py # Ubuntu Budgie support
โ โโโ gtk.py # Generic GTK support
โโโ services/ # External service integrations
โ โโโ location.py # IP-based location detection
โ โโโ schedule.py # Time-based scheduling
โ โโโ sunrise.py # Astronomical calculations
โโโ ui/ # GTK 4 user interface
โโโ tray.py # System tray integration
โโโ settings.py # Settings dialog
โโโ notifications.py # User notifications
Key Design Principles
- Plugin Architecture: Easy extension for new desktop environments
- Service-Oriented: Clean separation of concerns
- Event-Driven: Reactive architecture for mode switching
- Configuration-Driven: User preferences control behavior
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Process
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
uv run pytest) - Format code (
uv run black src tests && uv run isort src tests) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- GTK Team: For the excellent GTK 4 toolkit
- GNOME Project: For PyGObject bindings
- Flatpak Community: For modern Linux application distribution
- Ubuntu Budgie Team: For desktop environment collaboration
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: team@nightswitch.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nightswitch-0.1.0.tar.gz.
File metadata
- Download URL: nightswitch-0.1.0.tar.gz
- Upload date:
- Size: 105.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11a514b1ac41fb595fc291f8f120dfc6282821a98563fbf8f20175a08b55933e
|
|
| MD5 |
d47d20a7545ecf32a1482ee824fe0b98
|
|
| BLAKE2b-256 |
6402f1bea692301d8d8b3beea2b32e4e79b9d2b446f7d56ce3d2c5b33e3be44d
|
File details
Details for the file nightswitch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nightswitch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 78.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26c237e2302b13cbc4b03664d2494c61a6e67a8a6bcb8cc7ae6ca4f2f43516f8
|
|
| MD5 |
2a4fe12040582b7f4802baad2cd48e0e
|
|
| BLAKE2b-256 |
311b8421c5c7a68471a47fbf89bbc724511f0e6cf98226627def5c40cab6c295
|