Slimbookbattery and the frequent password prompt on Ubuntu

I just upgraded my laptop and with that performed a fresh and clean installation of my OS of choice: Ubuntu. At the same time I came across Slimbook Battery 3: application for optimize battery of your laptop – SLIMBOOK Ultrabook, laptops, computers in this article on OMG! ubuntu!. I’ve been using TLP for a long time and Slimbook Battery is using it under the hood. This post offers a solution to the frequent password prompt when using slimbookbattery on Ubuntu by augmenting polkit policies.

I’m not reviewing the app here, but suffice it to say that the GUI on top of TLP is very attractive, as is the tray icon that makes changing power profiles quick and easy. However, on Ubuntu, it would prompt for a password every time I changed the profile, since it requires root level privileges. That was certainly annoying.

I tried using sudo, but was unable to get the password prompt to go away. The makers of the app even included a sudoers config in /etc/sudoers.d/sudo-slimbookbattery. Clearly, sudo was not the right tool.

After some more digging I found that the privilege escalation wasn’t using sudo and instead was based on Polkit. The man pages for it are pretty dense, but in the logs I could tell that Slimbook Battery was using the pkexec call to fire up it’s supporting scripts.

All that said, here’s how to get Slimbook Battery to stop asking you for a password.

  1. Fire up an editor as root and edit the file /etc/polkit-1/localauthority/50-local.d/03-allow_slimbookbattery.pkla
  2. Put the following in that file:
   [Allow slimbookbattery]
   Identity=unix-group:sudo
   Action=org.freedesktop.policykit.exec
   ResultActive=yes
  1. Save the file and enjoy. Nothing seems to need to be restarted.

Basically, this allows all users in the sudo group, which includes the user created during install, to call things via pkexec aka the org.freedesktop.policykit.exec action. You can restrict this further by forcing it to just a single unix-user or add extra spice and lots of power by changing the action to *.

10 Replies to “Slimbookbattery and the frequent password prompt on Ubuntu”

      1. Did you remove the file sudo-slimbookbattery?
        I don’t understand why it doesn’t work for me, I also tried to put my username:
        identity=unix-user:monic

        1. Didn’t touch that file either. I’m on a fresh install of Ubuntu 20.10. do you see the slimbookbattery calls to pkexec in your logs?

  1. Awesome information, this should really be done by default when installing the software. Or at least have the installer give the option to do this.

Leave a Reply

Your email address will not be published. Required fields are marked *