-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
occasional “Applescript error 1” when switching modes #58
Comments
Hi there @sellout ! I'm trying to catch up with the work/hobby messages mountain, I'm sorry it took so much to answer you :) These are really nice ideas, thanks for reporting in, I'll keep this issue open for now, to be reminded when doing some improvement on the macOS codebase. |
Hi I just wanted to check in two years after reporting #13 - the issue is closed but it has never worked for me. I'm now seeing the following: I'm using emacs from the default macOS homebrew formula ( Using
|
@lukehoersten First, similar to what @LionyxML said in #13 (comment), but with a newer screenshot, can you check System Settings > Privacy & Security > Automation > Emacs and see if there is a “System Events” entry there and that it is enabled? (This is in the README, but is out-of-date re: where it says the setting is, so needs to be updated.) If that doesn’t work, could you try (setq auto-dark-allow-osascript t
auto-dark-detection-method 'osascript) As I mention in #61, If that doesn’t work, can you share the result of running (mapcar (lambda (member) (cons (car member) (symbol-value (car member))))
(cl-remove-if-not (lambda (member) (eq (cadr member) 'custom-variable))
(custom-group-members 'auto-dark nil))) in each of the terminal- and Spotlight-launched Emacs instances? That’ll show which settings (if any) differ between the two. |
Terminal
Spotlight
|
Damn – this is likely the culprit. It seems there are some possible solutions to this problem, but I have no idea how reliable any of them are. The tl;dr is
I don’t think it’s relevant to this issue any more, as I’m fairly certain your issue is simply the Automation access1. However, I wanted to mention that both here and in your earlier comment you included the backtrace, but not the error that actually occurred. In the earlier one, I had assumed it was “Applescript error 1”, but with these two commands, I have no idea why Footnotes
|
A quick sidenote on this matter. Historically, the first version of this package was ONLY osascript, and only MacOS was supported. I do think from now on further efforts should be in line with issuing the error to the Messages buffer, while not breaking Emacs startup. @sellout, am I owing some code review/testing for you? I halted the PR sequence while #64 is being discussed, but if you think some other opened PR can/should be merged first, just ping me! 😄 |
Yeah, I have to update #62 as described in #66 (comment), and that might be a good place to just make sure Auto-Dark doesn’t use
No, sorry, no reviews needed at the moment – I got pulled away with work & family stuff, and haven’t had a chance to tie up things yet. I’ll go over what I have open and see if anything there can be reviewed. My revamped approach to #67 is much improved, but still needs some work. |
No worries, no rush. I've also been dragged with some personal issues, first things first :) Nice, I marked #62 as the 'next merge candidate'. Since we now have tagged commits and semver, I think it would be a good idea to point new merges to the https://github.com/LionyxML/auto-dark-emacs/tree/development branch, what do you think? |
When I googled for this error, #13 was the first of very few results, but that is closed, and I feel like I have some more context and some suggestions.
This doesn’t happen to me on startup (as it seemed to in #13), regardless of whether the system is dark or light when I start Emacs. It also doesn’t happen on every timer firing1. Even when the mode changes, it only happens sometimes, and can happen switching in either direction (dark ↔ light). When it happens,
debugger-continue
causes the mode to change as expected.Perhaps the reason it appears to succeed is that it actually doesn’t succeed, but by the time I
debugger-continue
, the timer has fired again successfully, and the change was merely blocked by the debugger state?Backtrace
additional debugging info
I am using my branch for #57, so there’s a chance it’s related to that, but I don’t think any of the changes there come near this code.
recommendation
Since this seems intermittent and seems to work even when this error occurs, perhaps Auto-Dark should catch Applescript errors and re-report them as warnings with some additional context, like “Received the following error from Applescript when trying to determine whether the system is in dark mode. If Emacs has the appropriate appearance for the current mode, then you may ignore this error, otherwise, please report it at https://github.com/LionyxML/auto-dark-emacs/issues.”
Auto-Dark could also collect some statistics in a few vars about things like
and use these in the warning – either reporting them directly, or determining whether to even show the warning. E.g., if the failure is happening like 1/10 firings or less, maybe don’t even report the warning at all (or write it to
*Messages*
) – it’s more of an annoyance to the user than helpful, but if it’s failed the last 10 times in a row, we adjust the warning to say “You may need to give Emacs permission to run Applescript in System Settings > Privacy & Security > …” or something2.Footnotes
As you can infer from the Backtrace, my standard GNU Emacs 29 has
ns-do-applescript
, but notns-system-appearance-change-functions
, so it uses the timer, but notosascript
(and enablingauto-dark-allow-osascript
would have no effect). ↩Is it possible to tell Emacs to request the permissions directly? ↩
The text was updated successfully, but these errors were encountered: