Possible solution for setting battery threshold in Qubes

On Qubes I had tried it from dom0 and ran into this issue so then I tried it on Kicksecure but ran into the same issue on there.

Then you know the answer :wink:

I was hoping I was wrong and there still was a way :sweat_smile: thanks anyway! :slight_smile:

Related, older thread on the same subject:

1 Like

That file also does not exist for me but my Asus Zenbook automatically limited the charging to 80% when I was first running Windows 11, so I think there’s more to the story there. Possibly missing kernel modules from asus

Do you see anything in dom0 under /sys/class/power_supply? There should be “AC” or “mains” and at least a battery, if you have one.

Yes I have BAT0, AC0 and two directories for the two USBC ports

And nothing looking like “charging threshold” controls in /sys/class/power_supply/BAT0/ ?

Nope. I am tempted to just create the file with my desired value but not sure if that will break something.

Hi, same. If you need to set battery threshold you should build kernel from source and put one fix. CONFIG_HOTPLUG_PCI_CPCI=y to config-base file. Default = n. And on many laptops (my Asus) no file for battery without it. And you should build kernel with qubes-builderv2.

Default =n for protect from attack via attach evil devices to thundrebolt port. May be your laptop haven’t this port lol. This disabled only on Qubes os. All another distrs (Debian, fedora, Ubuntu) use kernel with y by default

1 Like

Ok interesting. Can you link me to the documentation for building the kernel from source? Never did that for an entire OS before.

Also, did you set other options to fix other things like the keyboard backlight?

There’s no documentation for building just the kernel. But you can easily change what’s being built in the example config. Instead of building the entire OS, specify that you want to build only the kernel and its components. You’ll need a Github account for this. Here’s an example; I use it. You’ll also need to create a GPG signing key and add it to the builder. chatgpt is a great tool for this.

git:
baseurl: https://github.com
prefix: QubesOS/qubes-
branch: release4.2
maintainers:

  • ‘KEY’
  • ‘KEY’
    backend-vmm:xen
    debug: true
    verbose: true
    qubes-release: r4.2
    distributions:
  • host-fc37
    components:
  • builder-rpm:
    packages: False
    branch:main
  • linux-utils
    -dracut
  • linux-kernel-latest:
    url: https://github.com//qubes-linux-kernel
    branch:main
    timeout: 21600
    host-fc37:
    stages:
  • build:
    environment:
    MAKEFLAGS: “-j$(($(nproc) * 2))”
    executor:
    type: docker
    options:
    image: “qubes-builder-fedora:latest”
    clean: True
    cpus: “0.000”
    stages:
  • fetch
  • prep
  • build
  • post
  • verify
  • sign:
    executor:
    type: local
  • publish:
    executor:
    type: local

I can’t say whether your keyboard or anything else will work better. I have to compile the kernel regularly because without it, the fans are constantly running at maximum power and the laptop temperature reaches 90 degrees Celsius at idle. Effective management of cores, their frequencies, and other things is probably impossible without this option. It’s very sad that Qubes OS is so inconvenient on many modern laptops.