M1tch 2 Posted May 11, 2019 Share Posted May 11, 2019 I saw this a few times on the windows server and ended up just setting sleep in the os to 3 hrs. The Mac appears to do the same I have tried 15 and 30 mins and each time the server sleeps mid stream to a Samsung tv . Anything else I check ? Link to comment Share on other sites More sharing options...
Luke 37023 Posted May 11, 2019 Share Posted May 11, 2019 Hi, on MacOS we don't currently have any sleep prevention so you'll need to configure it in system settings. It's something we plan to add in the future. Thanks. Link to comment Share on other sites More sharing options...
M1tch 2 Posted May 11, 2019 Author Share Posted May 11, 2019 That would explain it then! Thanks Luke Link to comment Share on other sites More sharing options...
M1tch 2 Posted May 18, 2019 Author Share Posted May 18, 2019 (edited) For anyone searching for similar, here is a stop gap that works pretty well until the Emby team add it in the future. I can't take credit I just reused from a cool script from "Parnty" here https://forums.plex.tv/t/plex-server-should-keep-mac-awake-after-wake-on-lan/60590/3 It checks the last 20 lines of the Emby Server log file for "emby/Sessions/Playing/Progress" every 30 secs and uses caffeinate to keep the mac awake. When it can't see that string the assertion gets removed and the mac sleeps per the system settings. Note: I may try to change this to look for any update to the log file as if emby is updating metadata etc the playing/progress piece gets lost in the noise. If anyone has a better way to approach i'd been keen to hear as i'm no dev.. 1. Create ~/Library/LaunchAgents/embyCaffeinate.plist as follows: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>embyCaffeinate</string> <key>ProgramArguments</key> <array> <string>sh</string> <string>-c</string> <string>"$HOME/Library/Scripts/embyCaffeinate.sh"</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> </dict> </plist> 2. Create ~/Library/Scripts/embyCaffeinate.sh as follows: #!/bin/bash # Paths embyLog=~/emby-server/logs/embyserver.txt caffLog=~/emby-server/logs/Caffeinate.log # Kill subprocess on exit trap '[[ -z "$(jobs -p)" ]] || kill $(jobs -p)' EXIT # Functions timestamp() { date "+%b %d %H:%M:%S"; } today() { date "+%d"; } embyUpdateTime() { stat -f %m "$embyLog" 2>/dev/null; } embyUserAction() { tail -20 "$embyLog" | \ grep "emby/Sessions/Playing/Progress" | \ tail -1 2>/dev/null; } # Init globals initDay() { day=$(today); } initembyState() { updateTime=$(embyUpdateTime); userAction=$(embyUserAction); } # Day check isSameDay() { local myDay=$(today) if [ "$myDay" = "$day" ]; then return 0 else day=$myDay return 1 fi } # Idle check isembyIdle() { local myUpdateTime=$(embyUpdateTime) if [ -z "$myUpdateTime" ] || \ [ "$myUpdateTime" = "$updateTime" ]; then return 0 else updateTime=$myUpdateTime return 1 fi } # Housekeeping check isembyHousekeeping() { local myUserAction=$(embyUserAction) if [ -z "$myUserAction" ] || \ [ "$myUserAction" = "$userAction" ]; then return 0 else userAction=$myUserAction return 1 fi } # Wait until user has finished using emby waitForUser() { initembyState while true; do echo "$(timestamp) Caffeinating..." >> "$caffLog" sleep 120 if isembyIdle; then break; fi if isembyHousekeeping; then break; fi done } # Check emby and caffeinate if needed initDay initembyState while true; do sleep 30 # Rotate logs if ! isSameDay; then mv "$caffLog" "$caffLog".1 2>/dev/null; fi # Check emby if isembyIdle; then echo "$(timestamp) emby is idle" >> "$caffLog" elif isembyHousekeeping; then echo "$(timestamp) emby is running background tasks" >> "$caffLog" # Caffeinate else echo "$(timestamp) Caffeinate" >> "$caffLog" waitForUser & caffeinate -is -w $! 2>/dev/null echo "$(timestamp) Caffeinated" >> "$caffLog" initembyState fi done 3.In Terminal, run the following chmod a+x ~/Library/Scripts/embyCaffeinate.sh launchctl load ~/Library/LaunchAgents/embyCaffeinate.plist Edited May 18, 2019 by M1tch Link to comment Share on other sites More sharing options...
Luke 37023 Posted May 18, 2019 Share Posted May 18, 2019 Hi, that's great info, thanks ! Link to comment Share on other sites More sharing options...
Luke 37023 Posted May 26, 2019 Share Posted May 26, 2019 The beta server has this now if you'd like to help test that: https://emby.media/community/index.php?/topic/65165-emby-server-beta-for-macos/ Thanks. Link to comment Share on other sites More sharing options...
M1tch 2 Posted June 7, 2019 Author Share Posted June 7, 2019 The beta server has this now if you'd like to help test that: https://emby.media/community/index.php?/topic/65165-emby-server-beta-for-macos/ Thanks. up for testing - link to beta not working at the moment Link to comment Share on other sites More sharing options...
Luke 37023 Posted June 7, 2019 Share Posted June 7, 2019 We'll have a new one for MacOS up soon. Thanks. Link to comment Share on other sites More sharing options...
macv 2 Posted January 14, 2023 Share Posted January 14, 2023 Is sleep prevention working? Seemed to go to sleep in the middle of playback on my M1 Mackbook Pro. Link to comment Share on other sites More sharing options...
Luke 37023 Posted February 13, 2023 Share Posted February 13, 2023 On 1/14/2023 at 12:51 PM, macv said: Is sleep prevention working? Seemed to go to sleep in the middle of playback on my M1 Mackbook Pro. Hi, do you have wake for network access enabled on your mac? https://support.apple.com/en-in/guide/mac-help/mh27905/mac#:~:text=Mac desktop computer-,On your Mac%2C choose Apple menu > System Settings%2C then,may need to scroll down.)&text=Turn on “Wake for network access” on the right. Link to comment Share on other sites More sharing options...
macv 2 Posted February 27, 2023 Share Posted February 27, 2023 On 2/13/2023 at 2:38 PM, Luke said: Hi, do you have wake for network access enabled on your mac? https://support.apple.com/en-in/guide/mac-help/mh27905/mac#:~:text=Mac desktop computer-,On your Mac%2C choose Apple menu > System Settings%2C then,may need to scroll down.)&text=Turn on “Wake for network access” on the right. Yup, it's enabled, seems to have been on by default. For now I still have to run `caffeinate` while playing. Link to comment Share on other sites More sharing options...
Luke 37023 Posted February 28, 2023 Share Posted February 28, 2023 22 hours ago, macv said: Yup, it's enabled, seems to have been on by default. For now I still have to run `caffeinate` while playing. What version of macOS are you on? Link to comment Share on other sites More sharing options...
Luke 37023 Posted February 28, 2023 Share Posted February 28, 2023 Also, try playing something from an Emby app, and then while it's playing, enter this into the macOS terminal: pmset -g assertions That will list the processes that are keeping the system awake. It may take up to five minutes from when playback starts until Emby Server gets listed there. Link to comment Share on other sites More sharing options...
macv 2 Posted March 1, 2023 Share Posted March 1, 2023 MacOS 13.2.1 (22D68) `pmset -g assertions` did show emby strangely still shut down if I don't also run caffeinate pid 71684(EmbyServer): [0x0004b92f0001a534] 00:21:58 PreventUserIdleSystemSleep named: "Emby Server has active sessions" Link to comment Share on other sites More sharing options...
Luke 37023 Posted March 1, 2023 Share Posted March 1, 2023 What does it say when you run caffeinate? Link to comment Share on other sites More sharing options...
macv 2 Posted March 1, 2023 Share Posted March 1, 2023 (edited) I like to run it with the -d option so it says pid 95536(caffeinate): [0x0004fbf50005a116] 00:00:06 PreventUserIdleDisplaySleep named: "caffeinate command-line tool" Details: caffeinate asserting forever Localized=THE CAFFEINATE TOOL IS PREVENTING SLEEP. Without -d, it says the same thing as emby: pid 95150(caffeinate): [0x0004fad20001a058] 00:00:02 PreventUserIdleSystemSleep named: "caffeinate command-line tool" Haven't tested emby playback without the -d, might be worth trying for someone (I'm traveling today & out of action for next few weeks). Edited March 1, 2023 by macv Link to comment Share on other sites More sharing options...
Luke 37023 Posted March 1, 2023 Share Posted March 1, 2023 When it sleeps, how long does it take to do so? Link to comment Share on other sites More sharing options...
macv 2 Posted March 1, 2023 Share Posted March 1, 2023 2 hours ago, Luke said: When it sleeps, how long does it take to do so? around an hour, laptop is always plugged in Link to comment Share on other sites More sharing options...
Luke 37023 Posted March 1, 2023 Share Posted March 1, 2023 what Emby app are you playing from? Link to comment Share on other sites More sharing options...
macv 2 Posted March 1, 2023 Share Posted March 1, 2023 Roku and Nvidia Shield (cigar version) Link to comment Share on other sites More sharing options...
Luke 37023 Posted March 17, 2023 Share Posted March 17, 2023 When you run it with the -d option, what does that produce for Emby Server? 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