Battery popout shows phantom 0% "Stylus" peripheral when no pen is present

Open Beginner friendly
#4,393 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
linux
Domain
desktop

Research direction

Open quickshell/Services/BatteryService.qml and find the peripheralDevices filter that currently requires only dev.ready; read the surrounding peripheralIcon helper and the UPower device properties it relies on to confirm isPresent is exposed there. Add the presence check to the filter, then open the battery popout on a machine (or with a mocked UPower device) whose digitizer reports a not-present battery and confirm the phantom Stylus tile is gone while real peripherals still list. Done means no 0% entry for a device UPower reports as absent.

Written by the indexing model from the issue text.

Description

Summary

The battery popout shows a phantom "Stylus" peripheral at 0% on laptops whose touchscreen digitizer declares a pen battery, even though no pen exists or is connected. The kernel marks that battery as not present, but BatteryService.peripheralDevices does not check this.

Steps to reproduce
  1. Use a laptop with an ELAN HID touchscreen/digitizer (here ELAN9008:00 04F3:2F2C) and no pen.
  2. Open the battery popout / control center battery detail.
  3. A peripheral tile appears: icon, 0%, name ELAN9008:00 04F3:2F2C Stylus.
Expected

Devices that UPower reports as not present are not listed as peripherals.

Actual

A permanent 0% "Stylus" entry is shown.

Analysis

The kernel hid-input driver creates a power_supply for any HID device that declares a battery usage, regardless of whether a pen is paired:

/sys/class/power_supply/hid-0018:04F3:2F2C.0002-battery-7
  type: Battery
  scope: Device
  present: 0
  capacity: 0
  status: Unknown

upower -i for it reports power supply: no, battery-level: unknown, percentage: 0% (should be ignored).

In quickshell/Services/BatteryService.qml, the filter is:

readonly property var peripheralDevices: refCount === 0 ? [] : UPower.devices.values.filter(dev => dev && dev.ready && !dev.isLaptopBattery && peripheralIcon(dev.type) !== "").map(...)

It only requires dev.ready, so the non-present device passes. UPowerDevice.isPresent is false here.

Suggested fix

Also require the device to be present (and optionally skip unknown state):

UPower.devices.values.filter(dev => dev && dev.ready && dev.isPresent && !dev.isLaptopBattery && peripheralIcon(dev.type) !== "")

UPOWER_IGNORE is not an option on the system side: UPower 1.91.5 does not honor it, and the kernel has no runtime switch to drop this battery.

Environment
  • dux-shell 2.1.2-1 (Arch Linux package)
  • UPower 1.91.5
  • Linux 7.3.5-arch1-1
  • Compositor: Hyprland
Dominant language
QML
Stars
8.4k
Forks
549
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AvengeMedia/DankMaterialShell

All issues in AvengeMedia/DankMaterialShell

Similar issues

More Desktop Dev issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.