Samurize utilities muSpec


(command-line utility)

suspend puts your PC to sleep under controlled conditions. It can watch out for a running process, an open window, a locked file, etc. It also logs the exact condition your PC was in when it went to sleep.


I wrote suspend because the power saving feature in Win7 64 doesn't work for me. On a new PC, it worked fine. Over time, however, my PC failed to fall asleep in due time, perhaps due to some stray processes taking up >10% CPU (the threshold for power saving). I wrote suspend to know exactly what's going on, power-wise.


suspend reads its settings from a file called suspend.ini, which should be in the same folder as suspend.exe.





command=C:\test.bat [TopProcess]
IdleTime Idle time (min), after which your PC can enter sleep mode. Measured from last keystroke/mouse move.
CPU Allowed CPU usage (%). CPU usage above this level will prevent sleep mode.
Process If this process is active, it will prevent sleep mode. Don't use ".exe" in the process name. You can list up to 4 processes.
FileLock Path to a file. If this file is locked, it will prevent sleep mode. If you use a wildcard "*" (e.g. "C:\*.mpg"), suspend will check the most recent file that matches this pattern. List up to 4 files.
Window Window title. If this window is active (has focus), it will prevent sleep mode. Partial match is allowed at the beginning of the title, e.g. "-w Netflix" will match "Netflix - Film 1" and "Netflix - Film 2". List up to 4 window titles.
Execute Command to run before sleep (10 sec timeout)
TopProcess If CPU usage is high enough to prevent sleep mode, log the most CPU-intensive processes (up to 5).


suspend's logs its activity in a file called suspend.log, in the same folder as suspend.exe.

10/01/2010 3:12:19 PM
Start monitoring
Idle time allowed: 30 min
CPU allowed: 6 %
Monitor file lock [1]: "C:\SageTV\*.mpg" Monitor process [1]: "comskip" Monitor active window [1]: "Netflix"
Run before sleep: "C:\test.bat" 10/01/2010 3:22:45 PM
Sleep mode prevented:
Idle time: 0 min
CPU usage: 20.60 %
Top processes:
1. "Idle", CPU: 75.79 %, RAM: 0 MB
2. "comskip", CPU: 11.66 %, RAM: 18 MB
10/01/2010 4:48:21 PM ===================== Suspending system: Idle time: 30 min CPU usage: 0 % File lock status [1]: False ("C:\SagetTV\*.mpg") Proc. status [1]: False ("comskip") 10/01/2010 5:01:38 PM ===================== System resume

The per-process and total CPU usage data may not add up to 100% because they're computed using different algorithms at slightly different points in time.


I watch over-the-air digital TV with a TV app called SageTV. I have 2 signal amps to boost channels coming from 2 directions. Since suspend is monitoring the system anyway, I added the feature to run commands based on which channel Sage is now recording. In my case, the commands power the amplifiers on/off.

Signal amps switched by suspend
port=8080 host=localhost
flag1OnCommand=antenna.bat 1 on
flag1OffCommand=antenna.bat 1 off
flag2Oncommand=antenna.bat 2 on
flag2Offcommand=antenna.bat 2 off

If you want to use the SageTV feature, you'll need the sagex web service plugin. In Sage 7, go to Main Menu->Setup->Plugins->Availabe plugins. Under the General tab, find and install: "SageTV Web Interface" and "sagex-services".

PreventSleep Prevent sleep mode if Sage is recording
AntennaSwitcher Run commands based on the channel being recorded
port, host
The settings for your Sage web server.
channel The channel name for which suspend will run a command, followed by two on/off flags.
flag1OnCommand Command to run when the 1st flag is on (1)
flag1OffCommand Command to run when the 1st flag is off (0)
flag2OnCommand Command to run when the 2nd flag is on (1)
flag2OffCommand Command to run when the 2nd flag is off (0)


Note: suspend requires .NET. Chances are you already have it installed. Also, suspend works on its own: your PC's power options should be off to avoid conflicts.

Download (19K)