{"id":35174956,"url":"https://github.com/aaronsb/fake-battery-nut","last_synced_at":"2026-05-21T19:33:58.683Z","repository":{"id":329536774,"uuid":"1119949336","full_name":"aaronsb/fake-battery-nut","owner":"aaronsb","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-20T19:40:03.000Z","size":5788,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-22T14:00:00.699Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aaronsb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-20T06:56:56.000Z","updated_at":"2025-12-20T19:40:07.000Z","dependencies_parsed_at":"2025-12-22T14:00:03.473Z","dependency_job_id":null,"html_url":"https://github.com/aaronsb/fake-battery-nut","commit_stats":null,"previous_names":["aaronsb/fake-battery-nut"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/aaronsb/fake-battery-nut","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Ffake-battery-nut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Ffake-battery-nut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Ffake-battery-nut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Ffake-battery-nut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aaronsb","download_url":"https://codeload.github.com/aaronsb/fake-battery-nut/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Ffake-battery-nut/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33311838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"ssl_error","status_checked_at":"2026-05-21T12:22:11.673Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-28T22:07:07.775Z","updated_at":"2026-05-21T19:33:58.678Z","avatar_url":"https://github.com/aaronsb.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fake-battery-nut\n\nA Linux kernel module that bridges NUT (Network UPS Tools) to the desktop power stack, making any NUT-supported UPS appear as a laptop battery to your desktop environment.\n\n![Walnut-powered PC](docs/media/battery-nut.png)\n\n### The Duality of Engineering\n\n**Power delivery:**\n```\nWall → 1350VA UPS → surge-only outlet → 450VA mini UPS → monitor\n                  → battery outlet → gaming PC (93% load)\n```\n*\"eh, the cords are beefy, it's probably fine\"*\n\n**Monitoring:**\n```\nUPS → USB HID → NUT daemon → upsc → bash script →\n/dev/fake_battery_nut → custom kernel module →\n/sys/class/power_supply/ → UPower → KDE\n```\n*\"we need proper kernel-level integration for the data to show up correctly\"*\n\nOne is an extension cord chain held together by vibes. The other is a DKMS-managed kernel module with systemd integration.\n\n---\n\n## The Problem\n\nLinux has two parallel power management systems that don't talk to each other:\n\n| System | Focus | Sees UPS? |\n|--------|-------|-----------|\n| **NUT** | Server/infrastructure, scripted shutdown | Yes (1382+ devices) |\n| **UPower** | Desktop UI, suspend/hibernate | Only some USB HID devices |\n\nWhen NUT claims your UPS (which it must, to manage it), UPower can't see it anymore. Your desktop has no idea a UPS exists - no battery icon, no low-power warnings, no auto-hibernate when the UPS battery gets critical.\n\n## The Solution\n\nThis module creates a virtual battery in `/sys/class/power_supply/` that a daemon updates with NUT data:\n\n```\nAny NUT-supported UPS → daemon → kernel module → UPower → Desktop\n```\n\nYour computer now looks like a laptop to the desktop environment. KDE/GNOME see a battery that charges (on mains) and discharges (on UPS battery), and respond accordingly.\n\n**This works with any of NUT's 1382+ supported devices** - serial, USB, SNMP, network-monitored, whatever. If NUT speaks to it, your desktop can now react to it.\n\n## The Origin Story\n\nThis project was born when a gaming PC (Ryzen 9950X3D, RX 7900 XTX, 57\" ultrawide) started tripping UPS overload alarms while running Minecraft with shaders. After plugging in a USB cable ignored for 4 years, we discovered the UPS was running at 123% capacity.\n\nThe fix? Move the monitor to a different UPS. $0 solution.\n\nBut then: \"I want to see UPS stats in btop.\"\n\nbtop doesn't support NUT. So we wrote a kernel module.\n\nThen we discovered UPower couldn't see the UPS either, because NUT had claimed it. So accidentally, we built the missing bridge between NUT and desktop power management.\n\n## Components\n\n- **fake_battery_nut.ko** - Kernel module creating BAT0 and AC0 in `/sys/class/power_supply/`\n- **/dev/fake_battery_nut** - Control interface for updating values\n- **nut-to-fakebattery** - Daemon that reads NUT and writes to the kernel module\n\n## Installation\n\n### From AUR (Arch Linux)\n\n```bash\nyay -S fake-battery-nut-dkms\n```\n\n### Manual Installation\n\n```bash\n# Build\nmake\n\n# Install module\nsudo make install\n\n# Or use DKMS\nsudo cp -r . /usr/src/fake-battery-nut-1.1.0\nsudo dkms add fake-battery-nut/1.1.0\nsudo dkms build fake-battery-nut/1.1.0\nsudo dkms install fake-battery-nut/1.1.0\n\n# Install daemon\nsudo install -m755 nut-to-fakebattery.sh /usr/bin/nut-to-fakebattery\nsudo install -m644 fake-battery-nut.service /etc/systemd/system/\n\n# Enable\necho \"fake_battery_nut\" | sudo tee /etc/modules-load.d/fake-battery-nut.conf\nsudo systemctl enable --now fake-battery-nut\n```\n\n## Configuration\n\nEdit `/etc/systemd/system/fake-battery-nut.service` to set your UPS:\n\n```ini\nEnvironment=NUT_UPS=myups@localhost\n```\n\n## Control Interface\n\nWrite to `/dev/fake_battery_nut` to set values:\n\n```bash\necho \"capacity=100\" | sudo tee /dev/fake_battery_nut    # Battery capacity %\necho \"time=1800\" | sudo tee /dev/fake_battery_nut       # Runtime in seconds\necho \"voltage=24000000\" | sudo tee /dev/fake_battery_nut # Voltage in µV\necho \"temp=260\" | sudo tee /dev/fake_battery_nut        # Temperature (tenths of °C)\necho \"status=2\" | sudo tee /dev/fake_battery_nut        # 0=discharge, 1=charge, 2=full\necho \"charging=1\" | sudo tee /dev/fake_battery_nut      # AC online status\n```\n\n## Data Mapping\n\n| NUT Field | Control Command | power_supply Property |\n|-----------|-----------------|----------------------|\n| battery.charge | capacity | BAT0/capacity |\n| battery.runtime | time | BAT0/time_to_empty_avg |\n| battery.voltage | voltage | BAT0/voltage_now |\n| ups.status (OL/OB) | status, charging | BAT0/status, AC0/online |\n| (optional) | temp | BAT0/temp |\n\n## Requirements\n\n- Linux kernel headers\n- NUT (nut package)\n- bc (for voltage conversion in daemon)\n\n## License\n\nGPL v2 (same as original linux-fake-battery-module)\n\n## Credits\n\nBased on [linux-fake-battery-module](https://github.com/hoelzro/linux-fake-battery-module) by Rob Hoelz.\n\n## See Also\n\n- [ADR-001: Extended NUT Data Mapping](docs/architecture/001-extended-nut-data-mapping.md) - Architecture decisions and the UPower bridge discovery\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronsb%2Ffake-battery-nut","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaronsb%2Ffake-battery-nut","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronsb%2Ffake-battery-nut/lists"}