Jump to content

Screen Wakeup Hack/Workaround


  • Please log in to reply
17 replies to this topic

#1
mosx

mosx

    InsanelyMac Protégé

  • Members
  • Pip
  • 18 posts
  • Gender:Male
  • Location:America
First this was tested on a Dell Latitude d820 & d620 running Kalyway 10.5.2 and iAtkos 2.0i (10.5.2) respectively. TThis also works for Latitude d620's. Both had Nvidia 120M graphics running NVInject. I haven't tested it on any other systems. This might also work with 10.4 systems. Even though this really can't break anything, I'm not responsible if this causes any damage to your system, yourself, your pets, or any other property. Use at your own risk.

Problem: Display goes to sleep and won't come back. Moving the mouse makes the screen brighten like it has returned but the screen is still black.

Solution: I noticed that changing the screen resolution and then changing it back makes the screen return. You can easily test if this hack/workaround will work for you. Here's how.

Open up your Display properties, click your screen resolution to highlight it. Now wait for the screen to sleep (I recommend setting it to sleep the display after 1 minute to speed this up). Now once the screen goes blank move your mouse, it should brighten but still be black. Hit the up arrow on your keyboard, it should change the screen resolution and return the screen. If that worked, this hack will work for you.

All we're going to do is change the screen resolution and then change it back when the wakeup command is sent. For that we need 2 packages. (link to zip below)

Cscreen - command line utility to change the screen resolution

Sleepwatcher - command line daemon to execute commands on sleep or wakeup (highly configurable)

The installation instructions are also included in the zip file. I've pasted them here for reference. Sorry if my instructions are hard to follow, if you can write a better set please do.

##################

OSx86 Monitor Refresh Workaround.

If your notebook goes to sleep and wakes up properly but the monitor doesn't come back this is for you. If your computer won't return from sleep or you have other sleep related issues this is NOT for you.

I found that changing the screen resolution actually wakes up the screen. This package just runs a command line app (cscreen) on wakeup to change the screen resolution back and forth to refresh the display.


1. Double click cscreen.dmg. Move the cscreen binary to /usr/bin. From the terminal
sudo -s
<enter password>
mv /Volumes/cscreen/cscreen /usr/bin
chown root:wheel /usr/bin/cscreen
chmod 755 /usr/bin/cscreen

2. Double click sleepwatcher_2.0.5.dmg. Install sleepwatcher.pkg and SleepWatcher StartupItem.pkg

3. In terminal, we need to modify the startup item for sleepwatcher.

sudo -s
<enter your password>
nano -w /Library/StartupItems/Sleepwatcher/Sleepwatcher

Scroll down to line 18, it looks like this:
/usr/local/sbin/sleepwatcher -d -V -s /etc/rc.sleep -w /etc/rc.wakeup

Change it to look like this:
/usr/local/sbin/sleepwatcher -d -V -s /etc/rc.sleep -W /etc/rc.wakeup

** NOTICE: The only change is changing the lower case 'w' to an uppercase 'W' **

Scroll down to line 28 (it's identical to the one above) and do the same thing.

Save and exit

4. Next we need to make the wakeup file for sleepwatcher to use

nano -w /Users/YOUR-USER-NAME/.wakeup

Substitute YOUR-USER-NAME with your home folder name.

In .wakeup put this:

#Begin wakeup script
#!/bin/bash
cscreen -d 16 -x 1680 -y 1050 && cscreen -d 32 -x 1680 -y 1050
#End wakeup script

cscreen is a command line utility to change screen resolutions, all we need to do is get it to refresh the screen. We can do that easily by just changing it from 32bit color (Millions of colors) to 16bit (Thousands of colors) and back to 32 bit again. Substitute your screen resolution after the -x and -y flags, leave the -d flag alone. (Mine was 1680x1050)

Save and exit.

5. the .wakeup file has to be executable.
chown root:wheel /Users/YOUR-USER-NAME/.wakeup
chmod 755 /Users/YOUR-USER-NAME/.wakeup

6. Thats it you're done. If everything was done right it should work. You can test this by setting the display sleep time to 1 minute and then wait for the display to turn off. If everything was done right when you move the mouse your screen should flicker a little and then come back.


Issues:
The screen flickers for a moment and then returns while it swaps resolutions, not a big deal really. It also does the flicker/refresh on boot because the daemon launches the script on boot. This is just a minor annoyance really and is hardly noticeable.

Final Thoughts:
If anyone cares to clean this up, improve it, turn it into a package go for it. Its not very elegant but it works. Sleepwatcher is highly configurable and can execute all sorts of commands on sleep, wake up, display wake up, display sleep, etc .. You could probably pair this with a nice clean applescript that does the same thing cscreen does. I hope someone smarter than me comes up with a more elegant solution.

- mOSX

Attached Files



#2
youngi

youngi

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 180 posts
  • Location:Alexandria, Egypt
hey man,
thanks alot, ive been searching for similar workaround FOREVER...it works fine, but the flickering is not very nice...

well i tried editing .wakeup file and putting only the 16 bit part, it doesnt flicker of course, but then u dont get nice colours, also if u then put the screen back to sleep the workaround wont work coz the screen setting is same as the workaround file.

the thing that i dont like is that this script has to work on boot and on wake from sleep, is there a way to prevent that and only work on screen wake???

#3
pmkoch

pmkoch

    InsanelyMac Protégé

  • Members
  • Pip
  • 14 posts
When I try to do this fix. I get an read-only error when I type:
mv /Volumes/cscreen/cscreen /usr/bin

#4
bertybassett

bertybassett

    InsanelyMac Protégé

  • Members
  • PipPip
  • 51 posts
cheer buddy this is the last thing I needed for my install of a D620, I will test tonight. Once again thanx buddy, now have an almost fully working mac OS 10.5.5

#5
hecker

hecker

    InsanelyMacaholic

  • Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 2,669 posts
  • Gender:Male
A similar thing can be found here. One small improvement, is that the resolution will not toggle at startup:
http://forum.insanel...o...=133920&hl=

#6
bertybassett

bertybassett

    InsanelyMac Protégé

  • Members
  • PipPip
  • 51 posts
mv /Volumes/cscreen/cscreen /usr/bin

had to use CP not MV as file was read only.

Also now my screen resolution will change colour depth causing the mentioned flicking at random times without reason.

#7
bertybassett

bertybassett

    InsanelyMac Protégé

  • Members
  • PipPip
  • 51 posts
on wake as suggested by hecker in this thread does not seem to work for the Dell blank screen problem. The reason being is the on wake program only works when the device wakes up from sleep. The Dell screen problem happens both when the screen goes blank and when returning from sleep too.

#8
allan88923

allan88923

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 4 posts
thank very much

#9
SA22C

SA22C

    Escaping the Reality Distortion Field

  • Members
  • PipPipPipPipPip
  • 333 posts
  • Gender:Male
  • Location:Soviet Kanukistan
Thanks very much for this tutorial. It works perfectly on my Toshiba Satellite A100 w/ nVidia 7600 video.

#10
danillll

danillll

    InsanelyMac Protégé

  • Members
  • Pip
  • 26 posts
First thanks for this workaround and for people, like me, who are annoyed by all the unnecessary flickers when starting the laptop, waking up "system" sleep or getting rid of screensaver, here is how i worked around it and made sure that only display wake changes the resolutions.

Note that I am lazy and I used the instructions but modified it with my steps.
So the idea is that, wake in sleepwatcher is reacting on any of the above events which is causing all the unnecessary flickers, however the sleep display function was acting correctly only on when the display sleep, so my solution was creating a "boolean flag" when the real sleep happens, the flag is an empty file, now when the wake execute the script, it checks the flag to make sure this is a real sleep and based if the file exists or not it changes the resolution.

1) follow the steps mentioned in the main post and make sure you get it working
2) In terminal, we need to modify the startup item for sleepwatcher.

sudo -s
<enter your password>
nano -w /Library/StartupItems/Sleepwatcher/Sleepwatcher

Scroll down to line 18, it looks like this:
/usr/local/sbin/sleepwatcher -d -V -s /etc/rc.sleep -W /etc/rc.wakeup

Change it to look like this:
/usr/local/sbin/sleepwatcher -d -V -S /etc/rc.sleep -W /etc/rc.wakeup

** NOTICE: The only change is changing the lower case 's' to an uppercase 'S' **

Scroll down to line 28 (it's identical to the one above) and do the same thing.

Save and exit

3) Next we need to make a sleep file for sleepwatcher to use

nano -w /Users/YOUR-USER-NAME/.sleep

Substitute YOUR-USER-NAME with your home folder name.

In .sleep put this:

#!/bin/bash
touch sleepdate



Save and exit.

4) the .sleep file has to be executable.
chown root:wheel /Users/YOUR-USER-NAME/.sleep
chmod 755 /Users/YOUR-USER-NAME/.sleep


5) change the .wakeup to look like this

#!/bin/bash
if [ -f ~/sleepdate ]
then
cscreen -d 16 -x 1440 -y 900 && cscreen -d 32 -x 1440 -y 900
rm -f ~/sleepdate
fi


6) restart and you should be gold

#11
Farkonian

Farkonian

    InsanelyMac Protégé

  • Members
  • Pip
  • 10 posts
Thanks to you both, this works great!! :thumbsup_anim:

#12
Matthew W

Matthew W

    InsanelyMac Protégé

  • Members
  • Pip
  • 24 posts
I seem to have a weird problem with this. My screen comes back but when it comes back it says I need to restart the computer. So I have to hold down the power button and restart, weird. Anybody know any solution for this. I am going to try and play a bit with it.

#13
Matthew W

Matthew W

    InsanelyMac Protégé

  • Members
  • Pip
  • 24 posts

I seem to have a weird problem with this. My screen comes back but when it comes back it says I need to restart the computer. So I have to hold down the power button and restart, weird. Anybody know any solution for this. I am going to try and play a bit with it.


Anybody know anything about this.
Im on my 36th Install. Almost everything is worked out. Except

Wifi 3945 - Buying Dell Wireless Card to replace
Return from Sleep - Blank screen - This thread
Mouse Artifcats - Kinda annoying looking for fix but if not I will not be too said.

#14
Matthew W

Matthew W

    InsanelyMac Protégé

  • Members
  • Pip
  • 24 posts
Awesome....now with reinstall I get a kernel panic everytime. I mount cscreen.dmg.....wow thats odd. Well time for 40th reinstall.
EDIT: Back to square one. Fresh install....follow directions exactally. But it doesnt do anything.

EDIT: I don't get why it won't work it worked once before but I was using - "w" not - "W" but it then gave me kernel panic. So I was forced to restart. I am going to try now with lowercase -w's

EDIT: This is what I believe is happeneing. When my computer wakes from sleep mode I think it has a kernel panic but I can't see it because the screen is blank and it cannot executes any commands or something like that. Because when I press the button to awaken from sleep mode it disables my keyboard or something.

#15
Ger Teunis

Ger Teunis

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 4 posts
Another real simple solution:

Press power button on your computer, this will popup a screen on which you can choose shutdown, sleep etc. (not visible ofcourse because screen is still in stanby).
Press letter S (for standby). The PC will go standby
Press any key to wakeup computer

et voila, the screen wakes up.

ps> still searching for a real solution though.
It seems that the nvidia driver is putting the screen to standby whatever setting I choose in power savings.
The timeout is large, my OSX will first enable the screensaver and if I wait a lot longer it will go to standby.

#16
BugsB

BugsB

    InsanelyMac Deity

  • Members
  • PipPipPipPipPipPipPipPipPipPip
  • 1,513 posts
  • Gender:Male
  • Location:Kauai, Hawai'i
I confirm mosx' approach with danillll's mods working perfectly in 10.6.3 with a GeForce 7600 Go in 32 bit mode.

Since this is working so good (WakeFix isn't) I greatly simplified the installation and also reflected that in the instructions.

Improved package attached.

Attached Files



#17
sw170

sw170

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 212 posts
  • Gender:Male
  • Location:UK

I confirm mosx' approach with danillll's mods working perfectly in 10.6.3 with a GeForce 7600 Go in 32 bit mode.

Since this is working so good (WakeFix isn't) I greatly simplified the installation and also reflected that in the instructions.

Improved package attached.

Hey BugsB, your perfect package works great, I had keystroke combination before but this is so much better, even screen wakeup from touchpad works, thanks a million !

thanks to mos'x and danilll too
cheers
s

#18
dewlim

dewlim

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts

Hey BugsB, your perfect package works great, I had keystroke combination before but this is so much better, even screen wakeup from touchpad works, thanks a million !

thanks to mos'x and danilll too


I confirm mosx' approach with danillll's mods working perfectly in 10.6.3 with a GeForce 7600 Go in 32 bit mode.

Since this is working so good (WakeFix isn't) I greatly simplified the installation and also reflected that in the instructions.

Improved package attached.



Can someone help me with this? I'm trying to run install from CSreeen and I will get an message saying that the document ".wakeup" could not be opened. You don't have permission.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy