Zend certified PHP/Magento developer

macOS: pkill a specific process without sudo?

Because of some recent bluetooth issues, I need to be able to run sudo pkill bluetoothd quite frequently, so I decided to create a shell script Shortcut to have on my menu bar for quick access. I usually need to run this command in urgent situations, so I hope you can understand typing in my password or waiting for Touch ID to finally recognise my finger can become annoying very quickly.

At first I thought to use blueutil as it doesn’t require sudo, but unfortunately it doesn’t seem to work the same (it reconnects to my devices slower than terminating bluetoothd), so unless there’s a way to make blueutil faster I want to avoid using it.

Then I considered modifying my sudoers file to make pkill runnable without sudo, but it sounds like a huge security risk doing that. Because of this, I thought of creating a .command file and specifying it in my sudoers file, but I’m afraid the file can be edited without privileges, again creating a big security risk.

I’m looking for the best way to do this, but if there’s a method to either make bluetoothd killable without sudo, or to make a .command file executable but non-writeable, do let me know.

Thanks in advance! 🙂