I'm trying to create a shortcut/hotkey for switching bluetooth on and off under latest Artix-s66/Plasma. I've found no such option in regular Shortcuts Settings, so I'm assuming a Custom Shortcut will need to be created. Which command would I need for such a switch?
If you are asking about how to stop the
bluetoothd service, the command in 66 is (as root):
66-stop bluetoothd
to disable the service (as root):
66-disable bluetoothd
Read the wiki (https://wiki.artixlinux.org/Main/Suite66).
Not sure if you meant s6 or 66. They are two different init systems.
@strajder it's suite-66. The first command works under sudo, but how do I turn it into a shortcut?
Creating a custom
sudo 66-stop bluetoothd shortcut has no effect.
You can create a script and execute that script from a shortcut. You can replace sudo with kdesu in Plasma.
The script is kind of what I'm asking for here. I just want a simple hotkey bluetooth on/off switch.
If I replace sudo with kdesu a popup is shown asking for root password. Are you suggesting I should enter it every time I want to simply switch the bluetooth?
Well, yes. Unless you have setup sudo so it doesn't ask for password, then use sudo. It's nothing special, just
#!/bin/sh
kdesu -c '66-stop bluetoothd'
or
#!/bin/sh
sudo 66-stop bluetoothd
Save that to some file, for example
$HOME/bin/turnoffbt (you will need the directory
$HOME/bin created with
mkdir $HOME/bin if it doesn't exist),
chmod 755 it (which will give it execute permission, more info:
man chmod):
chmod 755 $HOME/bin/turnoffbt
and add it to shortcut.
Wouldn't simple rfkill do the job?
Of course. I don't use Bluetooth devices, so I don't have much experience with them. The corresponding command can be easily added to the above script. The commands that I gave merely stop the
bluetoothd service.
@strajder dude I don't want to have to enter root password every time I want to switch BT, not to mention that command seems to only disable it. Perhaps I'm not explaining it well enough...
Here on Plasma, if I click on a BT tray icon there's an option to switch the Bluetooth connectivity (https://i.imgur.com/m0tyc1E.png). It doesn't require sudo or kdesu to work and it sure as biscuits isn't asking me for a root password to function. I want THAT but with a hotkey e.g. Alt+Shift+B. Is it possible?
Than I suggest to use rfkill.
rfkill block bluetooth
or to toggle it
rfkill toggle bluetooth
For more commands check
man rfkill
The opposite from
66-stop is
66-start, which starts the service. You can create a separate script for starting the service if that is what you want/need. Those commands require root privileges, just like the corresponding service-managing commands in any other init. How you obtain root privileges is another matter. Like I mentioned above, sudo can be configured to not require password. kdesu has an option to "remember password" for the duration of the current sesssion.
In Plasma, you can create a script with arbitrary commands and assign it to a shortcut. Activate
Application Menu -> Settings -> System Settings -> Shortcuts -> Custom Shortcuts -> Edit -> New -> Global Shortcut -> Command/URL, then switch to tab
Action and enter the path to your script. Switch to tab
Trigger and configure the keys which will trigger the action. Like
@SGOrava mentioned, you can use the command
rfkill inside of the script. He also gave some examples of using that command. Apply some reason and you will accomplish what you wanted.
Thank you! This is exactly what I was looking for.
I don't see why this thread had to be almost a dozen posts longer than in should have been, but I guess this is common with seeking linux-related help: you ask a question (often a simple one) as clearly as you can and get suggested things that have vague connection to what you asked paired with explanations of things you didn't need to know for your specific case, until someone turns up with a one-line solution.
Anyway, /thread
Kinda funny to hear you say that. A little perspective: had you applied reason and a little attention to the initial post yourself rather than pontificating about semi-related services' functionality, perhaps you would accomplish answering the question right away, saved both of us time, and prevented this thread from bloating out.
I get the feeling that your intention of creating this thread wasn't actually to seek help but to flame/troll and repeat stale memes about "toxicity in Linux community". Locked.