python - Sleepwatcher on OS X 10.11 not executing script on wake -


in installed sleepwatcher 2.2 on os x 10.11 , launching via launchd agent.

it launches okay , shows in activity monitor.

however, want fire off python script when computer wakes up.

my installation commands follows.

sudo mkdir -p /usr/local/sbin /usr/local/share/man/man8 sudo cp ~/desktop/sleepwatcher_2.2/sleepwatcher /usr/local/sbin sudo cp ~/desktop/sleepwatcher_2.2/sleepwatcher.8 /usr/local/share/man/man8 sudo cp ~/desktop/sleepwatcher_2.2/sleepwatcher/config/rc.sleep /etc sudo cp ~/desktop/sleepwatcher_2.2/sleepwatcher/config/rc.wakeup /etc sudo cp ~/desktop/sleepwatcher_2.2/sleepwatcher/config/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist /library/launchagents  chmod +x /etc/rc.sleep chmod +x /etc/rc.wakeup chmod +x /usr/local/bin/test.py 

my rc.wakeup file follows.

#!/bin/sh /usr/local/bin/python3 /usr/local/bin/test.py 

when executing sleepwatcher @ terimnal window typing in following, seems work.

/usr/local/sbin/sleepwatcher --verbose --wakeup /usr/local/bin/test.py  

however, when trying run start-up item under launchd, not seem work execute python script.

i have search on , cannot figure out why not working when being launched in launchd.

has ran type of problem?

thanks in advance.

i encountered similar problems took different approach using open source tool called hammerspoon. can provide automation of bunch of things on macos including sleep/wake events. it's quite simple replicate sleepwatcher's functionality adding following hammerspoon's ~/.hammerspoon/init.lua (or create 'spoon') script triggers when machine wakes or sleeps , calls corresponding wake , sleep scripts sleepwatcher:

function caffeinatewatcher(eventtype)     if (eventtype == hs.caffeinate.watcher.systemwillsleep or             eventtype == hs.caffeinate.watcher.systemwillpoweroff)             print ("willsleep...")         -- sleep:start()                 hs.task.new("/etc/rc.sleep", nil):start()     elseif (eventtype == hs.caffeinate.watcher.systemdidwake)         print ("woken...")         -- wake:start()                 hs.task.new("/etc/rc.wake", nil):start()     end end  sleepwatcher = hs.caffeinate.watcher.new(caffeinatewatcher) sleepwatcher:start() 

note if want hammerspoon launch shell scripts need ensure start standard bash shell header #!/bin/bash.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -