The conversation on this page has been archived and is no longer active.

Program / API to put monitor to sleep

Message #1 - Posted 2003/06/20 - Brian Medley

Hi,

I am looking for either an API or a program to place my monitor, but not my computer / hard drive to sleep. This would be similar to "xset dpms force off" in Linux. Thanks for any assistance.

Message #2 - Posted 2003/06/20 - Lawrence D'Oliveiro

Previously, Brian Medley wrote:

I am looking for either an API or a program to place my monitor, but not my computer / hard drive to sleep. This would be similar to "xset dpms force off" in Linux. Thanks for any assistance.

From Power.h:

/* bits in bitfield returned by PMFeatures */
enum {
...
hasDimmingSupport = 9, /* 1=has dimming support built in (DPMS standby by default) */
...
};

/*
* DimmingControl()
*
* Availability:
* Non-Carbon CFM: in PowerMgrLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 or later
*/
#if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM #pragma parameter DimmingControl(__D0)
#endif
EXTERN_API( void )
DimmingControl(Boolean enableSleep) FOURWORDINLINE(0x4840, 0x303C, 0x001F, 0xA09E);

/*
* IsDimmingControlDisabled()
*
* Availability:
* Non-Carbon CFM: in PowerMgrLib 1.0 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 or later
*/
#if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM #pragma parameter __D0 IsDimmingControlDisabled
#endif
EXTERN_API( Boolean )
IsDimmingControlDisabled(void) TWOWORDINLINE(0x7020, 0xA09E);

and also

/*
* GetDimSuspendState()
*
* Availability:
* Non-Carbon CFM: in PowerMgrLib 1.1 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 or later
*/
#if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM #pragma parameter __D0 GetDimSuspendState
#endif
EXTERN_API( Boolean )
GetDimSuspendState(void) TWOWORDINLINE(0x702B, 0xA09E);

/*
* SetDimSuspendState()
*
* Availability:
* Non-Carbon CFM: in PowerMgrLib 1.1 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 or later
*/
#if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM #pragma parameter SetDimSuspendState(__D0)
#endif
EXTERN_API( void )
SetDimSuspendState(Boolean dimSuspendState) FOURWORDINLINE(0x4840, 0x303C, 0x002C, 0xA09E);

Message #3 - Posted 2003/06/21 - Brian Medley

On Fri, 20 Jun 2003 18:56:24 +1200, Lawrence D39;Oliveiro wrote:

I am looking for either an API or a program to place my monitor, but not my computer / hard drive to sleep. This would be similar to "xset dpms force off" in Linux. Thanks for any assistance.

From Power.h:

/*
* SetDimSuspendState()
*
* Availability:
* Non-Carbon CFM: in PowerMgrLib 1.1 and later
* CarbonLib: in CarbonLib 1.0 and later
* Mac OS X: in version 10.0 or later
*/

Thanks for the pointer. The above funcction seems to be most promising for what I want todo. However, I created a small program that used it, but it did not seem to do anything. Below is the program. Do you see anything wrong w/ it?

#import <CoreServices/CoreServices.h>

/*
* $ gcc -c setsleep.m
* $ gcc -o setsleep setsleep.o -lobjc -framework CoreServices * $ ./setsleep
*/

int main(int argc, char * argv[]) {
SetDimSuspendState(1);

return 0;
}

Message #4 - Posted 2003/06/24 - Lawrence D'Oliveiro

Previously, Brian Medley wrote:

* SetDimSuspendState()

The above funcction seems to be most
promising for what I want todo. However, I created a small program that used it, but it did not seem to do anything.

I don't know, maybe you need to call DimmingControl(true) first or something. Did you manage to find any actual documentation for those calls?

Message #5 - Posted 2003/06/27 - Brian Medley

On Tue, 24 Jun 2003 21:22:26 +1200, Lawrence D39;Oliveiro wrote:

I don't know, maybe you need to call DimmingControl(true) first or something. Did you manage to find any actual documentation for those calls?

I guess I should have looked first:

*** begin doc ***
http://developer.apple.com/documentation/Carbon/Reference/Power_Manager/01powermanager/function_group_7.html#//apple_ref/c/func/SetDimSuspendState

Availability

Supported in Carbon. Available in CarbonLib 1.0 and later when PowerMgr 1.1 or later is present. Available in Mac OS X 10.0 and later.

Header: Power.h

Carbon Porting Notes

Calling this function on Mac OS X does nothing. Although available through Carbon on Mac OS X, SetDimSuspendState is unimplemented. *** end doc ***

The part about being unimplemented in OS X seems significant...:{

Need Help? Have a Question?

Looking for more help, comments, and answers?

Ask your questions on Ask Different. Ask Different is a community of Apple users ready to help.