Hi,
I use a custom desktop entry for enabling and disabling bluetooth using systemctl.
KDE Plasma has a toggle using rfkill, so that may be fine, but better be paranoid than sorry and it works really well.
What it does is enable or disable the bluetooth service, and mask or unmask it, to be extra sure.
This results in 2 password prompts, which is suboptimal.
How could I spawn a pkexec GUI password prompt, pipe that password into some file and just use sudo for the other one, piping the password there?
Into what file, how to protect it? Just a tempfile and delete it after piping? Or use it as a variable in both commands?
I should possibly overthink this:
- Changing the bluetooth service to a user systemd service would allow users to control it.
- Using a general “pkexec” prompt would not allow using dedicated groups for certain actions, locking users to the
wheel
group.
Solution without wheel
group:
# copy the service
sudo cp /usr/lib/systemd/system/bluetooth.service /etc/systemd/user/bluetooth-user.service
# disable the system service
sudo systemctl disable --now bluetooth
sudo systemctl mask bluetooth
systemctl --user daemon-reload
systemctl --user enable --now bluetooth-user