Does KM support multiple icons for a macro on a palette?

Does KM support multiple icons for a macro on a palette?

Specifically, how could I assign one icon (dimmed bluetooth) to display on a macro palette when Bluetooth is turned off and a different icon (active bluetooth) to display on the same macro palette when Bluetooth is turned on?

Instead, would this need to be accomplished with two palettes, one for the off condition which displays when Bluetooth is off and a counterpart version for the on condition which displays when Bluetooth is on?

Thanks in advance for replies to this post!

I moved this to a new topic since it is quite a different question.

Keyboard Maestro supports “marking” a macro, which you can do with the Mark Macro action, which will put a tick mark on a macro. The same sort of tick marks that show in the Applications Palette when the application is at the front for example.

Alternatively, you can have two different macros with two different icons, and you can use the Set Macro Enable action to enable one and disable the other to “change” the icon.

Hi Peter,

Many thanks for your reply.

I'm using the following AppleScript script to turn Bluetooth on and off (without using or including the Bluetooth menu extra, due to my already filled menu bar).

tell application "Terminal"
   do shell script "/usr/local/bin/blueutil status"
   set _Result to the result
   if _Result is "Status: on" then
      do shell script "/usr/local/bin/blueutil off"
   else if _Result is "Status: off" then
      do shell script "/usr/local/bin/blueutil on"
   end if
   quit
   tell application "System Events"
      tell application process "Safari"
         set frontmost to true
      end tell
   end tell
end tell

I've looked at the help for Set Macro (https://wiki.keyboardmaestro.com/action/Set_Macro_or_Group_Enable) and played with it, but evidently am overlooking or not understanding something.

Could you (or someone else) please elaborate on how to configure one (or two) buttons on a KM palette so that when clicked, the above script executes and the button properly switches between my active and dimmed bluetooth icons?

Many thanks in advance.

Hey Barry,

This AppleScript is just plain wrong in several respects.

Please see this post (and the thread in general).

Switch On/Off Bluetooth

The Terminal is NOT required, and multiple uses of do shell script is inefficient.

If you're going to use Keyboard Maestro to run the script then you may as well run a pure shell script using a Execute a Shell Script action.

A more efficient AppleScript using blueutil v2.4.0 on macOS 10.12.6.

set shCMD to "/usr/local/bin/blueutil --power"
set blueToothPowerStatus to do shell script shCMD

if blueToothPowerStatus is "0" then
   do shell script "/usr/local/bin/blueutil --power ON"
else if blueToothPowerStatus is "1" then
   do shell script "/usr/local/bin/blueutil --power OFF"
end if

status is no longer an available keyword in recent versions of blueutil.

An even better way to run this via AppleScript is:

set shCMD to "
export PATH=/usr/local/bin:$PATH;

if [[ $(type -P blueutil) = '' ]]; then

   echo \"The command line utility 'blueutil' is missing!\"

elif [[ $(blueutil -p) = 1 ]]; then

   blueutil -p OFF
   echo \"OFF\"

else

   blueutil -p ON
   echo \"ON\"

fi
"
set blueToothPowerStatus to do shell script shCMD

And better still is to run the shell script by itself in an Execute a Shell Script action.

Safari Group ⇢ 1-Key Macros.kmmacros (11.3 KB)

There are two of these in the supplied .kmmacros file – one turns BlueTooth ON and the other turns it OFF. (Download and double-click the file to install -- you'll then have to move the macros to your preferred macro group.)

image

MY palette looks like this:

51
05

So – as you can see this task is not exactly simple, but it's not too hard either.

-Chris

1 Like

Hi Chris,

Many thanks for your time and helpful reply.

As your reply helpfully explains, my macro very well could be "wrong," but it does function without any errors or issues. :slight_smile:

Cheers,

Barry

P.S. Yes, I already had read the other thread about on/off bluetooth macros and posted there; Peter then moved my posting into this separate thread.