Skip to content

ctsdownloads/led-battery-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LED Battery Monitor (With Spotify Compatibility)

(This a personal project I put together, because it was fun)

License Python Platform Release Downloads

A sophisticated Python application that displays real-time battery status and time remaining on Framework Laptop 16 LED modules, featuring Spotify integration, customizable brightness controls, and a comprehensive menu system.

πŸ“– Quick Navigation

πŸš€ Get Started Fast

πŸ“± Features & Examples

βš™οΈ Configuration & Support

πŸ“Š Compatibility

πŸ–ΌοΈ Live Display Examples

Battery Monitoring Mode

Battery Display Left module shows battery level with animated fill, right module displays time remaining

Charging Mode with Pulse Animation

Charging Display Pulse animation indicates active charging, real-time power consumption tracking

Spotify Integration Mode

Spotify Mode 1 Automatically switches to music mode when Spotify is playing

Spotify Mode 2 Left module: track progress bar (not battery, a progress indicator), Right module: scrolling artist and song information

🌟 Features

πŸ”‹ Framework Laptop 16 LED Module Integration

  • Dual LED Modules: Perfect fit for Framework Laptop 16 LED modules
  • Left Module: Battery level visualization with animated fill levels
  • Right Module: Time remaining display with digital clock format
  • Pulse Animation: Visual feedback during charging/discharging cycles

🎡 Spotify Integration

  • Automatic Detection: Seamlessly switches to music mode when Spotify is playing
  • Track Progress: Left module shows song progress bar in real-time
  • Scrolling Display: Right module displays scrolling artist and track information
  • MPRIS Support: Uses Linux MPRIS interface for reliable music detection

πŸ”† Advanced Brightness Control

  • Dual Brightness Settings: Current brightness (temporary) and startup brightness (permanent)
  • Auto-Dim Functionality: Automatically dims displays after configurable inactivity
  • Individual Control: Separate brightness settings for battery and time displays
  • Flash Testing: Built-in testing to verify LED module connectivity

βš™οΈ Comprehensive Menu System

  • Interactive Configuration: Full menu-driven setup and customization
  • Settings Persistence: All configurations saved to ~/.led_battery_monitor_settings.json
  • Real-time Adjustments: Change settings while monitoring is active
  • Diagnostic Tools: Built-in testing and troubleshooting features

πŸ›’ Getting Started

Step 1: Purchase Hardware

  1. Get Framework Laptop 16: If you don't have one already
  2. You need LED Modules: 2Γ— LED Matrix modules from Framework

Step 2: Hardware Installation

  1. Power Down: Shut down your Framework Laptop 16
  2. Install Modules: Insert LED Matrix modules on either side of the keyboard
  3. Power On: Boot your Framework Laptop 16

Step 3: Software Installation

# Download the universal Linux binary
wget https://github.com/ctsdownloads/led-battery-monitor/releases/latest/download/led-battery-monitor-linux-x64

# Make executable
chmod +x led-battery-monitor-linux-x64

# Log out and back in (or restart) for group changes to take effect
./led-battery-monitor-linux-x64

Platform Compatibility

Distribution Binary Status
Fedora 42+ (Bluefin, Aurora) led-battery-monitor-linux-x64 βœ… Fully Tested
Ubuntu 24.04+ led-battery-monitor-linux-x64 βœ… Fully Tested
Debian 12+ (Bookworm) led-battery-monitor-linux-x64 βœ… Compatible
Arch Linux, Manjaro led-battery-monitor-linux-x64 βœ… Compatible
Pop!_OS, Linux Mint led-battery-monitor-linux-x64 βœ… Compatible
openSUSE Tumbleweed led-battery-monitor-linux-x64 βœ… Compatible

Ubuntu-Specific Alternative: If the universal binary doesn't work:

wget https://github.com/ctsdownloads/led-battery-monitor/releases/latest/download/led-battery-monitor-ubuntu-24.04-x64
chmod +x led-battery-monitor-ubuntu-24.04-x64
./led-battery-monitor-ubuntu-24.04-x64

πŸš€ Usage

Main Menu

πŸ”‹ LED BATTERY MONITOR v2.0
==================================================
1. Start Battery Monitoring (Silent)
2. Battery Brightness (Left LED)
3. Time Brightness (Right LED)
4. Display Settings
5. Music Settings
6. Battery Status
7. About
8. Dim displays now (one-time)
9. Disable auto-dim (stop timeout)
0. Exit

Brightness Settings

  • Current Brightness: Immediate changes (temporary)
  • Startup Brightness: Permanent default (saved across restarts)

Recommended Settings:

Environment Battery LED Time LED Auto-Dim
Office/Daytime 75% (192) 75% (192) 50% after 2 min
Evening Work 50% (128) 50% (128) 25% after 1 min
Night/Dark 25% (64) 25% (64) 10% after 30 sec
Presentations 10% (25) 10% (25) Disabled

Spotify Setup

Prerequisites: Spotify desktop app (not web player) and dbus-send command

Test Connection:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:PlaybackStatus

Display Modes:

  • Normal Mode: Battery percentage (left) + Time remaining (right)
  • Music Mode: Track progress (left) + Scrolling artist/title (right)

πŸ› οΈ Development

Building from Source

git clone https://github.com/ctsdownloads/led-battery-monitor.git
cd led-battery-monitor
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python leds.py  # Run directly
python -m PyInstaller --onefile --console --name led-battery-monitor leds.py  # Build binary

Distrobox Development (Recommended for Immutable Distros)

distrobox create --name led-dev --image fedora:39
distrobox enter led-dev
sudo dnf install python3 python3-pip
pip install pyinstaller pyserial psutil
python -m PyInstaller --onefile leds.py

πŸ” Troubleshooting

Common Solutions

  1. Reseat Modules: Remove and reinsert LED modules
  2. Flash Test: Use built-in flash test from brightness menu

Battery Issues

upower -i $(upower -e | grep 'BAT')                          # Check battery
python3 -c "import psutil; print(psutil.sensors_battery())"  # Test psutil

Spotify Issues

  1. Desktop App Only: Must use Spotify desktop, not web player
  2. Must Be Playing: Spotify must be actively playing (not paused)
  3. Restart Spotify: Close and reopen application

Debug Mode

export LED_MONITOR_DEBUG=1
./led-battery-monitor-linux-x64

πŸ“‹ Configuration

Settings are saved to: ~/.led_battery_monitor_settings.json

Example Configuration:

{
  "battery_brightness": 128,
  "time_brightness": 128,
  "startup_battery_brightness": 96,
  "startup_time_brightness": 96,
  "fps": 10,
  "pulse_enabled": true,
  "dim_timeout": 120,
  "auto_dim_level": 20,
  "music_scroll_speed": 2
}

🀝 Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature-name
  3. Test on Framework Laptop 16 hardware
  4. Submit pull request with testing details

Made with ❀️ for the Framework Laptop 16 community

Optimized for Framework Laptop 16 LED modules on modern Linux distributions

About

Battery monitor with LED display and Spotify integration

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages