One-Step Macro for 'Dark Mode' Works, but Shortcut Key Can Cause Havoc!

I have made a number of macros that work fine in my use of Scrivener. Normally I have run screen in Dark mode OFF. Now it is autumn and it fits better, setting Dark mode to ON.

To save mouse action I made my shortest macro, ever :nerd_face: Simply 'Toggle system darkmode', called by pressing CMD F15.

It worked.

Then I did some work on a large Scrivener project (about 26 GB, which is far beyond normal rsize, but it works very fine).

Now hitting CMD F15, Scrivener crashed,"totally gone", but Dark mode did change status...

After a Scrivener crash a reindex is needed and that takes looong time...

I have then changed the hot key to ALT CMD F15, and this works excellent.
So far so good... I talked to support at Scrivener and they indicated that the huge filesize could influence this 'outside' Scrivener behaviour.

So the reason for posting here is my curiosity for the "reason" the crash happened, using the first hot key and not using the latest hotkey...???

I don't know what goes on in the Dark mode Action and both hotkeys were available.

(Checking on KeyCue) so if any of you have ideas / explanations, we could all be wiser.

GreyT

Hey Palle,

Did you save the crash log for Scrivener?

It's very unlikely that Keyboard Maestro did anything to cause Scrivener to crash. Light/Dark mode is just a simple system call.

I've seen apps respond poorly to the light/dark mode changes before, so this is most likely an issue specific to Scrivener.

I'd find the log and send it to them.

@peternlewis – anything to add?

-Chris

1 Like

No I did not save the log...
and the one thing that puzzles me is that changing the shortcut key 'solved ' the problem... maybe there is somewhere in the scrivener code a forgotten/hidden/not in use response for the CMD F15 key?

well thanks for your feedback Chris

P

If you’re curious about that try disabling your dark mode macro and then press CMD F15 when in Scrivener and see what happens…

Ok I tried that, nothing bad happened, then I turned on the macro again and ran it using alt cmd f15... and BUUMMM Scrivener crashed, so I have saved the report in BBE and will send it to Scrivener

Palle

2 Likes

The crash report is likely saved in the ~/Library/Logs/DiagnosticReports folder.

You can get to ~/Library (which is in your Home folder, but generally hidden from you) in the Finder by holding down the shift (or option) key and selecting Library from the Go menu in the Finder.

The action is implemented by the trivial AppleScript:

tell application "System Events" to tell appearance preferences to set dark mode to true

(or to false or to not dark mode).

You can try executing the AppleScript in the script editor, you should likely get the same result.

My wild guess is that Scrivener is doing something when the Option key is pressed which somehow affects the behaviour in a way that causes it to crash or not crash.

If my guess is right, executing the AppleScript, with or without the various Command/Option keys down might cause the issue.

And if you add a Pause Until action at the start of the macro and pause until the modifiers are all released, that might change the behaviour to be consistent regardless of the trigger.

But in any event, the AppleScript is pretty trivial and the system change to dark mode should not cause a crash.

I'm happy to take a look at the crash report if you email it to me, but I don't know if I will be able to see much, and certainly it is the Scrivener folks who should be looking at it. But if you can get a repeatable crash, using only modifiers and AppleScript, that would be better as it eliminates Keyboard Maestro from the equation.

Hi Peter
Thank you for your comments. I have added the Pause conditions but that does not change behavior of Scrivener/Crash. Smaller projects do not crash (mind you here the index rebuild takes about 30-45 minutes, due to the immense size of project)

Just so you know, if I use the Menuline option and click on the darkmode button there is NO crash.

The peculiar thing is that running the same files and macro on my MacMini M1 (same macos) there is NO crash.

I attach the lates crash report I could locate (copied from screen and saved in BBE)

and I will not use the macro while scrivener is running 🥸

Kind regards

Palle Jensen

(Attachment Scrivener darkmode crash.txt is missing)

Problem solved...

Avoided by using ALT CMD Å (Å is the key to the right of P)
:cowboy_hat_face:

Addendum:

Forgot this combo was used for sorting in Scrivener, so I changed it to:

ALT CMD ?

(? is the key two steps to the the right of P, I use danish keyboard)