knuton/counting-sheep — pull request #1 by janraasch (2011-12-15 14:22:09+00:00)
Title: Fixed an issue with system not going to sleep after screen is locked

Using Counting Sheep v1.2 I realized my Mac would not go to sleep after the screen was locked/the screen went to sleep and required password activation. The problem is that

```tell application "Finder" to sleep
```
will not work on Mac OS Snow Leopard and Lion (I only tested it on Lion, but I also found a [post confirming the issue on 10.6](http://hints.macworld.com/article.php?story=20100424161727333)) after the screen is locked. The command

```pmset sleepnow
```
does the trick, but is not supported on Mac OS Tiger ([man pmset](http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/10.4/man1/pmset.1.html)).

So I used

```
sw_vers -productVersion
```
to solve for x in Mac OS 10.x ([man sw_vers](http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/sw_vers.1.html)) first and then act accordingly.