Solved: Detecting if a specific monitor is attached

Hello,
I want to change light and dark mode depending on if a specific monitor is attached. i.e. If I am in my basement, I'll always want dark mode. If I am at the office, I'll always want light mode.

I had searched the forum to see if there was a solution to this, and I didnt find one - so I ended up figuring it out and wanted to post my solution - just in case someone else needs it in the future.

Luckily for me, I have two different monitor models in the different locations. I found a tool called m1ddc that will, amongst many other things, give you a list of attached monitors. Its availabe via homebrew, and only supprorts silicon macs. (There are similar tools available for intel macs)

So, my conditional KM macro has a bit like this:

CleanShot 2025-02-28 at 09.45.00

And thats all it took - I have several conditions for different monitors in my world - and I can set the light/dark mode based on which is connected!

Hope that helps someone, and thank you @peternlewis for a great tool!

Nice solution! Just for reference, you can do this without any third party tools:

system_profiler SPDisplaysDataType | grep -B 1 Resolution:

That will output something like this (both my displays are identical):

        PA27JCV:
          Resolution: 5120 x 2880 (5K/UHD+ - Ultra High Definition Plus)
--
        PA27JCV:
          Resolution: 5120 x 2880 (5K/UHD+ - Ultra High Definition Plus)

In your case, just check if the output contains U3425WE, and you should get the same results as with m1ddc. One advantage of this method is that it'll work on any Mac.

-rob.

1 Like

I always love a good open source tool. I would just mention as an alternative (for those who might prefer it) that this is also possible to do natively with Shortcuts. And of course KM and Shortcuts can communicate with each other and set and pass variables.

@hemicyon @griffman Thanks for your follow-ups! Those are great solutions too! I didn't know about those!