Program / API to put monitor to sleep

Brian Medley wrote on :

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.

Lawrence D’Oliveiro replied on :

In article aun4fvkn55maqsh90rhcgjsblhmo2jpdgc@redacted.invalid, Brian Medley nonexistant@redacted.invalid 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);
Brian Medley replied on :

On Fri, 20 Jun 2003 18:56:24 +1200, Lawrence D'Oliveiro <ldo@redacted.invalid_zealand> 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;

}

Lawrence D’Oliveiro replied on :

In article t4n7fv8th9t409m49c2i9sjl4ksqlh7u1f@redacted.invalid, Brian Medley nonexistant@redacted.invalid 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?

Brian Medley replied on :

On Tue, 24 Jun 2003 21:22:26 +1200, Lawrence D'Oliveiro <ldo@redacted.invalid_zealand> 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...:{