raguay.customct Posted March 4, 2015 Share Posted March 4, 2015 Hi, I am only seeing the issue in the morning. But, I am active on the system during the day/night. My logs do not show it working in the morning until I force it to get the light theme on. Launch Control doesn't show any errors either. I just updated the script again from your gist. I will check it again in the morning. Link to comment Share on other sites More sharing options...
deanishe Posted March 4, 2015 Author Share Posted March 4, 2015 I've added a wrapper script to the Gist. You can put all your settings in there, so you can update the Python script without having to edit it every time. The wrapper should go in the same directory as the Python script and you should run the script via the wrapper instead. The Launch Agent will still call the Python script, but any settings from the wrapper will be preserved. Link to comment Share on other sites More sharing options...
raguay.customct Posted March 4, 2015 Share Posted March 4, 2015 I have your wrapper and new script in place. Waiting to see how they work. Will keep you updated. Thanks. Link to comment Share on other sites More sharing options...
deanishe Posted March 4, 2015 Author Share Posted March 4, 2015 Thanks. I'll be glad to hear if it's working. I'm at a bit of a loss here: launchd is explicitly designed to run missed jobs on wake. I'll try and replicate the problem on my notebook. I can't sleep my main machine, as the network doesn't come back up on wake (thanks, Yosemite!) If you unload and reload the Launch Agent, does it run correctly then? As a stop-gap, you could try using SleepWatcher to unload and reload the Launch Agent on wake. That should make the script run with your desired settings. Link to comment Share on other sites More sharing options...
deanishe Posted March 4, 2015 Author Share Posted March 4, 2015 Are you two both using Yosemite? It seems that launchd also has some issues on Yosemite. Are your other Launch Agents working correctly? Link to comment Share on other sites More sharing options...
raguay.customct Posted March 4, 2015 Share Posted March 4, 2015 If it doesn't work, I will use Keyboard Maestro's Run on Wake to get it working. Don't know SleepWatcher, but I already have Keyboard Maestro running. Don't need too many programs going. Yes, I have the latest 10.10.3. I haven't noticed anything else having issues, but I do not have any Launch Agents that run on sleep ControlPlane works fine and I believe it uses launch agents. But, I only run ControlPlane when on the go. Link to comment Share on other sites More sharing options...
deanishe Posted March 4, 2015 Author Share Posted March 4, 2015 I didn't know KM has a run-on-wake feature (probably could have guessed, though. It has every feature.) Handy to know. Doesn't ControlPlane need to be running all the time to do its thing? Link to comment Share on other sites More sharing options...
raguay.customct Posted March 4, 2015 Share Posted March 4, 2015 It does, but I mostly have it control what programs are launched when running battery and what to use for printing. So, I launch it before going on the move and use it while on the move. I run so many utilities that unloading one does help my load. I am still trying to get all the settings good, but it gets distracting sometimes. That one is a hard one to really master. Link to comment Share on other sites More sharing options...
roccitman Posted March 4, 2015 Share Posted March 4, 2015 Gents $ bash toggle-alfred-theme.bash DEBUG Started with options : {u'help': False, u'light': 'OS X Yosemite', u'quiet': False, u'times': False, u'dark': 'OS X Yosemite Dark', u'timezones': False, u'nothing': False, u'verbose': False} DEBUG Deleted stale PID file : /tmp/net.deanishe.alfred-toggle-theme.pid DEBUG light at 2015-03-04 17:26:49 UTC INFO Light theme : OS X Yosemite INFO Dark theme : OS X Yosemite Dark INFO Alfred theme set to `OS X Yosemite` INFO Next change : Theme `OS X Yosemite Dark` at sunset in 11 hours, 15 minutes at 18:42 HST DEBUG Forking into background ... Looks right. And from the console: 04/03 07:26:46 DEBUG [alfred-theme] Started with options : {u'help': False, u'light': 'OS X Yosemite', u'quiet': False, u'times': False, u'dark': 'OS X Yosemite Dark', u'timezones': False, u'nothing': False, u'verbose': False} 04/03 07:26:46 DEBUG [alfred-theme] Deleted stale PID file : /tmp/net.deanishe.alfred-toggle-theme.pid 04/03 07:26:49 DEBUG [alfred-theme] light at 2015-03-04 17:26:49 UTC 04/03 07:26:49 INFO [alfred-theme] Light theme : OS X Yosemite 04/03 07:26:49 INFO [alfred-theme] Dark theme : OS X Yosemite Dark 04/03 07:26:49 INFO [alfred-theme] Alfred theme set to `OS X Yosemite` 04/03 07:26:49 INFO [alfred-theme] Next change : Theme `OS X Yosemite Dark` at sunset in 11 hours, 15 minutes at 18:42 HST 04/03 07:26:49 DEBUG [alfred-theme] Forking into background ... 04/03 07:26:49 DEBUG [alfred-theme] Wrote PID (813) file : /tmp/net.deanishe.alfred-toggle-theme.pid 04/03 07:26:49 DEBUG [alfred-theme] Running in background 04/03 07:26:51 INFO [alfred-theme] Updated and reloaded Launch Agent /Users/roccoapril/Library/LaunchAgents/net.deanishe.alfred-toggle-theme.plist 04/03 07:26:51 DEBUG [alfred-theme] Pausing for 3 seconds before exiting ... 04/03 07:26:51 DEBUG [alfred-theme] Started with options : {u'help': False, u'light': 'OS X Yosemite', u'quiet': False, u'times': False, u'dark': 'OS X Yosemite Dark', u'timezones': False, u'nothing': False, u'verbose': False} 04/03 07:26:51 DEBUG [alfred-theme] Script already running with PID : 813 04/03 07:26:51 INFO [alfred-theme] Script is already running. Exiting. 04/03 07:26:54 DEBUG [alfred-theme] Done -------------------------------- And when I relaunched the launch agent: DEBUG Started with options : {u'help': False, u'light': 'OS X Yosemite', u'quiet': False, u'times': False, u'dark': 'OS X Yosemite Dark', u'timezones': False, u'nothing': False, u'verbose': False} DEBUG Deleted stale PID file : /tmp/net.deanishe.alfred-toggle-theme.pid DEBUG light at 2015-03-04 17:33:41 UTC INFO Light theme : OS X Yosemite INFO Dark theme : OS X Yosemite Dark INFO Alfred theme set to `OS X Yosemite` INFO Next change : Theme `OS X Yosemite Dark` at sunset in 11 hours, 8 minutes at 18:42 HST DEBUG Forking into background ... DEBUG Started with options : {u'help': False, u'light': 'OS X Yosemite', u'quiet': False, u'times': False, u'dark': 'OS X Yosemite Dark', u'timezones': False, u'nothing': False, u'verbose': False} DEBUG Script already running with PID : 903 INFO Script is already running. Exiting. Thought that might help. Oh and all this after updating to the latest script and running from the new wrapper. Link to comment Share on other sites More sharing options...
raguay.customct Posted March 5, 2015 Share Posted March 5, 2015 Hi, It still did not fix it this morning. The logs show that it has not run today and LaunchControl doesn't show an error. It is definitely not being ran after a sleep. Looks like launchd definitely has a bug there. Using other solutions for now.... Link to comment Share on other sites More sharing options...
roccitman Posted March 12, 2015 Share Posted March 12, 2015 Some odd Console activity today. Not sure what to make of it. Just turned the theme to dark though and it's 2:15ish HST (14:15) 11/03 00:30:46 DEBUG [alfred-theme] Started with options : {u'help': False, u'light': 'OS X Yosemite', u'quiet': False, u'times': False, u'dark': 'OS X Yosemite Dark', u'timezones': False, u'nothing': False, u'verbose': False} 11/03 00:30:46 DEBUG [alfred-theme] Deleted stale PID file : /tmp/net.deanishe.alfred-toggle-theme.pid 11/03 00:30:50 DEBUG [alfred-theme] dark at 2015-03-11 10:30:50 UTC 11/03 00:30:50 INFO [alfred-theme] Light theme : OS X Yosemite 11/03 00:30:50 INFO [alfred-theme] Dark theme : OS X Yosemite Dark 11/03 00:30:51 INFO [alfred-theme] Alfred theme set to `OS X Yosemite Dark` 11/03 00:30:51 INFO [alfred-theme] Next change : Theme `OS X Yosemite` at sunrise in 6 hours, 18 minutes at 06:49 HST 11/03 00:30:51 DEBUG [alfred-theme] Forking into background ... 11/03 00:30:51 DEBUG [alfred-theme] Wrote PID (14053) file : /tmp/net.deanishe.alfred-toggle-theme.pid 11/03 00:30:51 DEBUG [alfred-theme] Running in background 11/03 00:30:53 INFO [alfred-theme] Updated and reloaded Launch Agent /Users/roccoapril/Library/LaunchAgents/net.deanishe.alfred-toggle-theme.plist 11/03 00:30:53 DEBUG [alfred-theme] Pausing for 3 seconds before exiting ... 11/03 00:30:53 DEBUG [alfred-theme] Started with options : {u'help': False, u'light': 'OS X Yosemite', u'quiet': False, u'times': False, u'dark': 'OS X Yosemite Dark', u'timezones': False, u'nothing': False, u'verbose': False} 11/03 00:30:53 DEBUG [alfred-theme] Script already running with PID : 14053 11/03 00:30:53 INFO [alfred-theme] Script is already running. Exiting. 11/03 00:30:56 DEBUG [alfred-theme] Done -------------------------------- 11/03 14:15:54 DEBUG [alfred-theme] Started with options : {u'help': False, u'light': 'OS X Yosemite', u'quiet': False, u'times': False, u'dark': 'OS X Yosemite Dark', u'timezones': False, u'nothing': False, u'verbose': False} 11/03 14:16:03 DEBUG [alfred-theme] dark at 2015-03-12 00:16:03 UTC 11/03 14:16:03 INFO [alfred-theme] Light theme : OS X Yosemite 11/03 14:16:03 INFO [alfred-theme] Dark theme : OS X Yosemite Dark 11/03 14:18:08 CRITICAL [alfred-theme] AppleScript command failed. osascript exited with 1 11/03 14:18:08 INFO [alfred-theme] Next change : Theme `OS X Yosemite` at sunrise in 16 hours, 32 minutes at 06:48 HST 11/03 14:18:08 DEBUG [alfred-theme] Forking into background ... Link to comment Share on other sites More sharing options...
albertkinng Posted November 26, 2015 Share Posted November 26, 2015 too geeky for me. I wasn't able to installed it. Link to comment Share on other sites More sharing options...
deanishe Posted November 27, 2015 Author Share Posted November 27, 2015 Yeah, it's not exactly super user friendly. If you can be more precise regarding what problem(s) you're having installing the script, perhaps I can offer some actionable help. Perhaps with your feedback, I could write an installer script that would make it (relatively) painless to install and use. Link to comment Share on other sites More sharing options...
cands Posted December 28, 2016 Share Posted December 28, 2016 Thanks deanishe for making this valuable workflow. I have a problem with the automatic start via launchd (Alfred 3.2.1, macOS 10.12.2). I think it is related to execute permissions since: 1) I need to use sudo to run manually from terminal (the function then works as expected). 2) I followed your advice to check errors via LaunchControl, from which I found "OSError: [Errno 13] Permission denied: '/tmp/net.deanishe.alfred-toggle-theme.pid'". Any advice on how to solve this? Link to comment Share on other sites More sharing options...
deanishe Posted December 28, 2016 Author Share Posted December 28, 2016 You shouldn't need to use sudo. The error is most likely because you used sudo. The temp file is now owned by root, so your user can't overwrite it. Deleting the file manually should do the trick. Link to comment Share on other sites More sharing options...
cands Posted December 29, 2016 Share Posted December 29, 2016 You were right indeed! I needed to change permissions (chmod) for the executable files, then it worked without sudo, and after deleting the temp file manually it now works. By the way, f.lux does not seem to be able to toggle dark mode anymore (not for me at least), but I called the "Yosemite Dark Mode Toggle (With Alfred Theme Toggle)" from your "toggle_alfred_theme.py" script this way (change at line 196): ALFRED_SCRIPT = """tell application "Alfred 3" run trigger "toggle-dark-mode" in workflow "rodgerw.toggle.yosemite.dark" with argument "test" delay 0.5 set theme "{theme}" end tell""" Just figured I mention this if any other users also would like to use this solution. Thank you very much for all the great workflows you have made! They have made me much more productive (Searchio!, MailTo, Default Folder X, Secure SHell, to name some of my most used), and I've also learned a lot about programming by studying them. Thank you also for your kind help to all users with troubleshooting workflows and giving so much advice! deanishe 1 Link to comment Share on other sites More sharing options...
deanishe Posted December 30, 2016 Author Share Posted December 30, 2016 ? That's a great tip regarding f.lux. I've updated the script to default to themes present in Alfred 3.2. cands 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now