Im using ubuntu with cinnamon and im tired of not having a bluetooth switch, and having to use rfkill to turn BT off. For now, i use blueman to turn BT on and manage devices and connections, and I use rfkill on my terminal to turn it back off after im done using it. I wanted to create a clickable macro (ie : as a cinnamon applet that would display on my taskbar) that rfkills on and off BT.
My question is : is there a command of rfkill that lets you simply invert a device's state (that is unblock if blocked and blocked if unblocked) ?
./BT_switch.sh: 3: [[: not found.
3 is indeed the BT id i need to switch on and off, but idk what could be wrong here. The if statement doesnt seem to be ever satisfied thus it can only unblock, even tho"$(rfkill list $BTDEVNO)"
does seem to return a string that contains your regex. Any idea ? – Bruh Oct 23 '20 at 20:23/etc/sudoers
usingusername ALL=NOPASSWD: /usr/sbin/rfkill
– Bruh Oct 26 '20 at 10:31<bruhs uname> ALL=(ALL) NOPASSWD:<output_of_which rfkill>
Please make sure you edit sudoers file using visudo
– MidwayNomad Oct 27 '20 at 12:37$currentState | grep 'Bluetooth Soft blocked: no'
instead of what you provided. I also added th e shebang in case. Adding the provided line in sudoers didnt do anything, i still seem to be needing sudo. IE : launching the shortcut in terminal mode opens a terminal on sudo password prompt. Launching the shortcut normally doesnt do anything – Bruh Oct 28 '20 at 13:00id
&which rfkill
. Also, please share the sudoers entry you created verbatim. – MidwayNomad Oct 30 '20 at 05:58uid=1000(iamgron) gid=1000(iamgron) groups=1000(iamgron),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare)
is returned byid
and/usr/sbin/rfkill
is returned bywhich rfkill
Finally, this is what i have in my sudoers :iamgron ALL=(ALL) NOPASSWD: /usr/sbin/rfkill
– Bruh Oct 30 '20 at 18:52