Skip to content
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

Cannot use light mode for mail app. #7

Closed
KeKsBoTer opened this issue Sep 29, 2018 · 41 comments · Fixed by #16
Closed

Cannot use light mode for mail app. #7

KeKsBoTer opened this issue Sep 29, 2018 · 41 comments · Fixed by #16

Comments

@KeKsBoTer
Copy link

First of all: Nice tool, I have been locking for something like this for a while!

It works fine for all apps but mail. I use global dark mode, but cannot set light mode for the mail app.
The defaults for mail are the following:

$ defaults read com.apple.mail       
{
    NSNavLastRootDirectory = "~/Documents";
    NSNavPanelExpandedSizeForOpenMode = "{720, 465}";
    NSNavPanelExpandedSizeForSaveMode = "{712, 621}";
    NSRequiresAquaSystemAppearance = 1;
}
@zenangst
Copy link
Owner

@KeKsBoTer hey mate, thanks for the feedback. Hmm, that is pretty odd, the output looks correct to me. What about if you close mail and manually run this in the terminal:

defaults write com.apple.mail NSRequiresAquaSystemAppearance -bool YES

Does it have any effect?

@zenangst
Copy link
Owner

zenangst commented Oct 1, 2018

@KeKsBoTer hey mate, I just pushed a new version that should fix this issue, see #16 for more information.

Please try version 0.2.1, you can download it here -
https://github.com/zenangst/Gray/releases/download/0.2.1/Gray.zip

@dsalzr
Copy link

dsalzr commented Oct 1, 2018

Mail doesn't work for me with 0.2.1 🙁 All other apps worked.

Tried defaults write com.apple.mail NSRequiresAquaSystemAppearance -bool YES and it has no effect

@zenangst zenangst reopened this Oct 1, 2018
@zenangst
Copy link
Owner

zenangst commented Oct 1, 2018

Seems like the recent fix didn’t do its job properly. I wonder if this has to do with plist caching. I’ll do some more digging when I’m back from vacation to see if we can’t put a nail in the coffin on this shenanigans. I’ll keep you posted!

@zenangst
Copy link
Owner

zenangst commented Oct 3, 2018

@KeKsBoTer @dsalzr mind testing this issue with version 0.4.0?

@dsalzr
Copy link

dsalzr commented Oct 3, 2018

Still no change @zenangst 🙁 I even tried restarting after setting mail to light mode.

Here's a video of me testing it out:

https://www.youtube.com/watch?v=YMT1SRw8VDo

@zenangst
Copy link
Owner

zenangst commented Oct 4, 2018

@dsalzr bah this issue is tearing me apart, but no worries... we will figure it out eventually.
I've done some testing and Mail works for me with the latest version of the app. I'm curious why certain apps are causing issues for different users. For me, it has been Contacts that has been acting a bit weird while testing but that was fixed in prior versions.

Maybe you could try the following steps.

  1. Restart your machine (just to get a clean slate)
  2. Start terminal and run the following commands:

The first command will kill the preference service for your user, that should clear the plist cache from using the previous value. The second command is what the application run for you when you tap on an icon.

/usr/bin/killall -u $USER cfprefsd
defaults write com.apple.mail NSRequiresAquaSystemAppearance -bool true
  1. Restart again just to make sure that your latest settings are stored.
  2. Launch Mail.app

Sorry for not having the answer to this conundrum just yet, but if you stick with me I'm sure that we can figure something out.

If the following does not work, we can try and use PlistBuddy to obtain the results that we want.

@KeKsBoTer
Copy link
Author

@dsalzr bah this issue is tearing me apart, but no worries... we will figure it out eventually.
I've done some testing and Mail works for me with the latest version of the app. I'm curious why certain apps are causing issues for different users. For me, it has been Contacts that has been acting a bit weird while testing but that was fixed in prior versions.

Maybe you could try the following steps.

1. Restart your machine (just to get a clean slate)

2. Start terminal and run the following commands:

The first command will kill the preference service for your user, that should clear the plist cache from using the previous value. The second command is what the application run for you when you tap on an icon.

/usr/bin/killall -u $USER cfprefsd
defaults write com.apple.mail NSRequiresAquaSystemAppearance -bool true
1. Restart again just to make sure that your latest settings are stored.

2. Launch Mail.app

Sorry for not having the answer to this conundrum just yet, but if you stick with me I'm sure that we can figure something out.

If the following does not work, we can try and use PlistBuddy to obtain the results that we want.

Did not work for me :/

@dsalzr
Copy link

dsalzr commented Oct 4, 2018

Same here. Did not work with the terminal commands and restarting. Also tried version 0.4.2. Happy to continue testing as you try different things @zenangst

@zenangst
Copy link
Owner

zenangst commented Oct 5, 2018

@dsalzr @KeKsBoTer Still fighting the good fight! A new version just landed which has some minor changes to how preferences are written to their property lists. Mind taking the new version for a spin to see if it does not resolve the issues you have been seeing?

https://github.com/zenangst/Gray/releases/download/0.5.0/Gray.zip

@zenangst
Copy link
Owner

zenangst commented Oct 5, 2018

Sketch that, there is a new version that further tries to correct the issue, you can find it here: https://github.com/zenangst/Gray/releases/download/0.5.1/Gray.zip

@KeKsBoTer
Copy link
Author

@zenangst Thanks for your efforts! Sadly it does not work :/

@zenangst
Copy link
Owner

zenangst commented Oct 5, 2018

I can make a special version that prints some of the output from the shell commands, that might help to narrow things down.

@zenangst
Copy link
Owner

zenangst commented Oct 5, 2018

I’ve started brewing on a new version with better logging when it saves settings. While implementing it I was one thing that might be the culprit.

Right now I’m going to a museum with my kid but I’ll make a new build and notify you peeps when life allows.

Stay tuned and thanks for your patience ;)

@zenangst
Copy link
Owner

zenangst commented Oct 5, 2018

@KeKsBoTer @dsalzr mind taking 0.5.2 for a spin - https://github.com/zenangst/Gray/releases/download/0.5.2/Gray.zip

If it still does not work with that version, you should be able to use Console.app to get information about the commands that are sent and what the command output is.

Please provide that info here if you are still having issue :)

@dsalzr
Copy link

dsalzr commented Oct 6, 2018

@zenangst did not work but here are the relevant log entries:

`default 12:50:10.399054 -0700 Gray New settings for Mail = true

default 12:50:10.399101 -0700 Gray command: /usr/bin/killall -u $USER cfprefsd
/usr/libexec/PlistBuddy -c "Set :NSRequiresAquaSystemAppearance true" /Users/daniel/Library/Preferences/com.apple.mail.plist

defaults read com.apple.mail NSRequiresAquaSystemAppearance /Users/daniel/Library/Preferences/com.apple.mail.plist

error 12:50:10.421866 -0700 kernel Sandbox: defaults(32203) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.VoiceMemos/Data/Library/Preferences

error 12:50:10.425372 -0700 kernel Sandbox: defaults(32203) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.Home/Data/Library/Preferences

error 12:50:10.425398 -0700 kernel Sandbox: defaults(32203) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.Safari/Data/Library/Preferences

error 12:50:10.427555 -0700 kernel Sandbox: defaults(32203) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.iChat/Data/Library/Preferences

error 12:50:10.428254 -0700 kernel Sandbox: defaults(32203) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.mail/Data/Library/Preferences

error 12:50:10.430973 -0700 kernel Sandbox: defaults(32203) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.news/Data/Library/Preferences

error 12:50:10.432752 -0700 kernel Sandbox: defaults(32203) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.stocks/Data/Library/Preferences

default 12:50:10.463622 -0700 Gray output: (1
)
error 12:50:10.532872 -0700 kernel Sandbox: Gray(32069) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.news/Data/Library/Preferences/com.apple.news.plist

error 12:50:10.534067 -0700 kernel Sandbox: Gray(32069) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.mail/Data/Library/Preferences/com.apple.mail.plist

error 12:50:10.534429 -0700 kernel Sandbox: Gray(32069) System Policy: deny(1) file-read-data /Users/daniel/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari.plist

error 12:50:10.534825 -0700 kernel Sandbox: Gray(32069) System Policy: deny(1) file-read-data /Users/daniel/Library/Preferences/com.apple.AddressBook.plist
`

@KeKsBoTer
Copy link
Author

@zenangst didn't work eather :/
Console Log

@zenangst
Copy link
Owner

zenangst commented Oct 7, 2018

@KeKsBoTer @dsalzr thanks guys, it seems like there is something wonky going on with the entitlements.

I made a new version, could you try this one?

Gray 0.7.1.zip

@johnoscott
Copy link

For me, the Mail app does not show in the app list at all (I just tried Gray 0.7.1)

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

Hey @johnoscott, I think that it has to do with how the applications are being validated. If the Gray is unable to resolve the application plist for the app, it will simply ignore it. I think this needs changing for everything to work properly, I'll look into that issue as well even if it is unrelated to this specific problem.

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

@johnoscott mind trying this new version, it should fix the issue with Mail being missing.

Gray 0.7.1a.zip

@johnoscott
Copy link

@johnoscott mind trying this new version, it should fix the issue with Mail being missing.

Gray 0.7.1a.zip

Yes that fixes the missing Mail app but changing the setting does not seem to make any difference.

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

@johnoscott mind sharing some log files using the Console.app?

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

@KeKsBoTer @dsalzr @johnoscott Here is a question for all of you. Where are you running the application? Did you guys move it to /Applications before running it? I'm curious to see if this has any effect on the capabilities that the apps get when it comes to modifying other application preferences.

If you don't do that, please try and "install" the app in /Applications and re-test changing settings on apps.

@johnoscott
Copy link

Yes I copied to Applications folder first

@johnoscott
Copy link

@johnoscott mind sharing some log files using the Console.app?

Yes happy to. What exactly do you want ?

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

Just post anything that the Gray app spits out :)

@johnoscott
Copy link

In the log above I did the following :`

  1. open the app
  2. search for "Mail"
  3. click Mail to change its setting to "Light Appearance"
  4. quit the app

Hope this helps

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

@johnoscott thanks mate, I'm gonna dig through them later on! cheers!

@johnoscott
Copy link

gray.console.log

@johnoscott
Copy link

I deleted the post and uploaded the log file instead (above)

@KeKsBoTer
Copy link
Author

@KeKsBoTer @dsalzr @johnoscott Here is a question for all of you. Where are you running the application? Did you guys move it to /Applications before running it? I'm curious to see if this has any effect on the capabilities that the apps get when it comes to modifying other application preferences.

If you don't do that, please try and "install" the app in /Applications and re-test changing settings on apps.

I have installed all Gray versions to the Applications folder so far. Also the new 0.71a does not solve the problem with the mail app :(

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

Seems like the common theme that I can see is that this is due to sandboxing.
I'm gonna bring out the big shovel and get us out of this, I'll post more updates when life allows for more investigation.

@KeKsBoTer @dsalzr @johnoscott thanks y'all for the debug information and again... thanks for your patience ❤️

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

Investigation

I've done some further digging, and it seems that Apple has made it tricky for us.
Preference files are not all located in ~/Library/Preferences. The exceptions to the rule are the following:

kernel	Sandbox: Gray(4664) System Policy: deny(1) file-read-data /Users/username/Library/Containers/com.apple.Home/Data/Library/Preferences/com.apple.Home.plist
kernel	Sandbox: Gray(4664) System Policy: deny(1) file-read-data /Users/username/Library/Containers/com.apple.news/Data/Library/Preferences/com.apple.news.plist
kernel	Sandbox: Gray(4664) System Policy: deny(1) file-read-data /Users/username/Library/Containers/com.apple.stocks/Data/Library/Preferences/com.apple.stocks.plist
kernel	Sandbox: Gray(4664) System Policy: deny(1) file-read-data /Users/username/Library/Containers/com.apple.mail/Data/Library/Preferences/com.apple.mail.plist
kernel	Sandbox: Gray(4664) System Policy: deny(1) file-read-data /Users/username/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari.plist

So what we are looking at here is the SIP (System Integrity Protection) telling us that we cannot read the files. The reason why this was overlooked when I tested this was that I was running macOS Mojave with SIP disabled (mainly to get TotalSpaces2 and cDock working).

I'm still investigating this to see if there is any light at the end of the tunnel.
While I continue digging a larger hole in the sandbox, there is one workaround that I can think of, a bit wonky but it seems to work.

Workaround

  1. Restart your machine while holding ⌘R to go into recovery.
  2. Click Utilities.
  3. Select Terminal.
  4. Open the terminal and run csrutil disable this will disable SIP.
  5. Restart your machine.
  6. Open Gray and configure the apps that you want to configure.
  7. Perform step 1, 2 and 3 again.
  8. Open the terminal and run csrutil enable, this will enable SIP again.
  9. Restart your machine.

For screenshots about the process, check out MacWorld's article

Your preferences should stay intact even with SIP-enabled.

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

@KeKsBoTer @dsalzr @johnoscott So. I did some more digging and found this setting under Security & Privacy.

screen shot 2018-10-08 at 19 15 14

I tried it out with SIP-enabled and it worked. Please try giving the app the privileges it needs to see if that doesn't fix the issue :)

@dsalzr
Copy link

dsalzr commented Oct 8, 2018

@zenangst That worked 🤩^^^ (Security & Privacy > Full Disk Access > + > Gray.app)

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

Fantastic, me and @RamonGilabert are working on some killer UX for the app to make the process more streamlined. If you launch Gray without enough privileges to change Mail, we will show what needs to be done for it to work :) Thank you so much for sticking with us in all of this ❤️

@zenangst
Copy link
Owner

zenangst commented Oct 8, 2018

We just released 0.8.0 so its time to put this issue to rest. Thanks to everyone for their participation, sending logs and following up played an enormous part in tracking this issue down. Loads of love ❤️

https://github.com/zenangst/Gray/releases/tag/0.8.0

@zenangst zenangst closed this as completed Oct 8, 2018
@KeKsBoTer
Copy link
Author

Thanks man! it works ❤️

@johnoscott
Copy link

Working now for Mail BUT when Mail is open and Gray changes the setting, Mail restart doesnt work. It does Quit, but doesnt start up automatically again.

@zenangst
Copy link
Owner

zenangst commented Oct 9, 2018

@johnoscott Yeah, it seems like the restart mechanism needs a bit of work. Still struggling a bit with some stutter when invoking shell scripting. Hoping to improve this in future versions of the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants