katernet / darkmode

Set macOS dark mode and Alfred dark theme at sunset
GNU General Public License v3.0
149 stars 10 forks source link

Sunrise/Sunset does not work #19

Closed pelillian closed 5 years ago

pelillian commented 5 years ago

For some reason when I run the darkmode.sh script it correctly checks the current time and sets the mode accordingly, but does not automatically do so at sunrise and sunset.

> launchctl list | grep dark
-   78  io.github.katernet.darkmode.sunrise
-   78  io.github.katernet.darkmode.sunset

Mojave 10.14.4 Mid 2015 MacBook

katernet commented 5 years ago

Exit code 78 seems to be configuration error. Which version are you running, 1.8.2?

And are you connected to wifi? (Doesn't require to be only connection, primary connection can be ethernet) and is Setting Timezone enabled as per Readme? Is darkmode allowed in Automation in System Preferences > Security & Privacy > Privacy > Automation ? What does the log contain?

$ cat ~/Library/Logs/io.github.katernet.darkmode.log

Also you could try relaunching the launch agent, to see if it then returns a 0 exit code.

$ launchctl unload ~/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist
$ launchctl unload ~/Library/LaunchAgents/io.github.katernet.darkmode.sunset.plist
$ launchctl load ~/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist
$ launchctl load ~/Library/LaunchAgents/io.github.katernet.darkmode.sunset.plist
pelillian commented 5 years ago

Yeah, I'm running 1.8.2 connected to wifi. I accepted the dialog that popped up about system events but I don't see Darkmode in the list under Automation (iTerm is there if that helps).

Log before relaunching launch agent:

08/05/19 09:53:35 darkmode: Solar query stored - Sunrise: 05:59 Sunset: 19:37
05/08/19 21:06:45 /Users/pelillian/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist: Could not find specified service
05/08/19 21:06:45 /Users/pelillian/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist: Path had bad ownership/permissions
13/05/19 18:03:04 darkmode: Solar query stored - Sunrise: 05:52 Sunset: 19:34
13/05/19 18:06:09 darkmode: Solar query stored - Sunrise: 05:52 Sunset: 19:34
13/05/19 18:58:11 darkmode: Solar query stored - Sunrise: 05:52 Sunset: 19:34

After relaunching launch agent:

> launchctl list | grep dark
-   78  io.github.katernet.darkmode.sunrise
-   0   io.github.katernet.darkmode.sunset

Thanks!

katernet commented 5 years ago

05/08/19 21:06:45 /Users/pelillian/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist: Path had bad ownership/permissions

What are the permissions for sunrise.plist? Run the below

ls -l ~/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist

If they are not -rw-r--r-- [yourusername] staff then run the below and then launchctl unload and launchctl load

chmod 644 ~/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist
chown 501:staff ~/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist
pelillian commented 5 years ago

Here's the result of ls -l: -rw-r--r-- 1 pelillian staff 531 May 13 23:00 /Users/pelillian/Library/LaunchAgents/io.github.katernet.darkmode.sunrise.plist

katernet commented 5 years ago

Before I forget the obvious... what are the permissions on darkmode.sh?

ls -l ~/Library/Application\ Support/darkmode/darkmode.sh

Should be -rwxr-xr-x [yourusername] staff (ignore the @ if it shows).

pelillian commented 5 years ago

-rw-r--r--@ 1 pelillian staff 7886 May 8 09:46 /Users/pelillian/Library/Application Support/darkmode/darkmode.sh

And that might be our problem!

After a quick chmod +x: -rwxr-xr-x@ 1 pelillian staff 7886 May 8 09:46 /Users/pelillian/Library/Application Support/darkmode/darkmode.sh

Anything else I should do or do you think it will work now?

katernet commented 5 years ago

@pelillian should be good now. Let me know if dark mode doesn't schedule.

pelillian commented 5 years ago

Thanks so much! It seems to be working.