Skip to content

Instantly share code, notes, and snippets.

@kates
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save kates/b5f052e75e3c52ccac1d to your computer and use it in GitHub Desktop.

Select an option

Save kates/b5f052e75e3c52ccac1d to your computer and use it in GitHub Desktop.

Revisions

  1. kates revised this gist Jun 13, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    make
    ./lockscreen
  2. kates created this gist Jun 13, 2014.
    12 changes: 12 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    TARGET=lockscreen

    all: clean compile

    compile:
    clang -framework Foundation -framework IOKit main.m -o ${TARGET}

    clean:
    rm -f ${TARGET}

    .PHONY: all

    12 changes: 12 additions & 0 deletions main.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #import <objc/runtime.h>
    #import <Foundation/Foundation.h>
    #import <IOKit/IOKitLib.h>

    int main() {
    io_registry_entry_t r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler");
    if (r) {
    IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanTrue);
    IOObjectRelease(r);
    }
    return 0;
    }