Rainmeter Samurize utilities

Suspend

(command-line utility)

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

History

I wrote suspend because the power options in Windows are not sufficiently configurable for me. suspend lets me control precisely when Windows is allowed to (or foreced to) go to sleep.

suspend.ini

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

[General]
IdleTime=30
CPU=7
AudioCheck=1

[Process]
1=comskip
2=capture

[FileExists]
1=%TMP%\CHECKFILE

[FileLock]
1=C:\logs\*.csv

[Window]
1=Netflix

[Window]
1=Netflix

[Suspend]
command=C:\onsuspend.bat
prevent=%TMP%\LOCKFILE

[Resume]
command=C:\onresume.bat [TopProcess]
count=5
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.
AudioCheck If audio is coming from the sound card, it will prevent sleep mode. Good for watching movies for a long time.
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.
FileExists If this file exists, it will prevent sleep mode.
FileLock 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.
Suspend Command to run before going to sleep.
prevent it this file exists, it will prevent the execution of the above command
Resume Command to run when Windows wakes up from sleep
TopProcess If CPU usage is high enough to prevent sleep mode, log the most CPU-intensive processes (up to 5).

suspend.log

suspend 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.

Download

suspend requires .NET Framework. 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 suspend_1.2.zip (201K)