Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] A bluetooth switch shortcut? (Read 814 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

[SOLVED] A bluetooth switch shortcut?

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?


Re: A bluetooth switch shortcut?

Reply #2
@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.


 

Re: A bluetooth switch shortcut?

Reply #4
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?

Re: A bluetooth switch shortcut?

Reply #5
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
Code: [Select]
#!/bin/sh
kdesu -c '66-stop bluetoothd'
or
Code: [Select]
#!/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):
Code: [Select]
chmod 755 $HOME/bin/turnoffbt
and add it to shortcut.

Re: A bluetooth switch shortcut?

Reply #6
Wouldn't simple rfkill do the job?


Re: A bluetooth switch shortcut?

Reply #8
@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. 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?

Re: A bluetooth switch shortcut?

Reply #9
Than I suggest to use rfkill.
Code: [Select]
rfkill block bluetooth
or to toggle it
Code: [Select]
rfkill toggle bluetooth

For more commands check
Code: [Select]
man rfkill

Re: A bluetooth switch shortcut?

Reply #10
@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...
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.

Re: A bluetooth switch shortcut?

Reply #11
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

Re: A bluetooth switch shortcut?

Reply #12
Apply some reason and you will accomplish what you wanted.
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.