Reformat sandman Objective-C code
parent
af2a4ef1f8
commit
70386c93f2
23
sandman.m
23
sandman.m
|
@ -40,33 +40,34 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid < 0) err(EX_OSERR, "fork");
|
if (pid < 0) err(EX_OSERR, "fork");
|
||||||
|
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
execvp(argv[1], &argv[1]);
|
execvp(argv[1], &argv[1]);
|
||||||
err(EX_NOINPUT, "%s", argv[1]);
|
err(EX_NOINPUT, "%s", argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
|
[
|
||||||
NSNotificationCenter *center = [workspace notificationCenter];
|
[[NSWorkspace sharedWorkspace] notificationCenter]
|
||||||
NSOperationQueue *main = [NSOperationQueue mainQueue];
|
addObserverForName: NSWorkspaceWillSleepNotification
|
||||||
|
|
||||||
[center addObserverForName:NSWorkspaceWillSleepNotification
|
|
||||||
object: nil
|
object: nil
|
||||||
queue:main
|
queue: [NSOperationQueue mainQueue]
|
||||||
usingBlock: ^(NSNotification *note) {
|
usingBlock: ^(NSNotification *note) {
|
||||||
(void)note;
|
(void)note;
|
||||||
int error = kill(pid, SIGTSTP);
|
int error = kill(pid, SIGTSTP);
|
||||||
if (error) err(EX_UNAVAILABLE, "kill %d", pid);
|
if (error) err(EX_UNAVAILABLE, "kill %d", pid);
|
||||||
}];
|
}
|
||||||
|
];
|
||||||
|
|
||||||
[center addObserverForName:NSWorkspaceDidWakeNotification
|
[
|
||||||
|
[[NSWorkspace sharedWorkspace] notificationCenter]
|
||||||
|
addObserverForName: NSWorkspaceDidWakeNotification
|
||||||
object: nil
|
object: nil
|
||||||
queue:main
|
queue: [NSOperationQueue mainQueue]
|
||||||
usingBlock: ^(NSNotification *note) {
|
usingBlock: ^(NSNotification *note) {
|
||||||
(void)note;
|
(void)note;
|
||||||
int error = kill(pid, SIGCONT);
|
int error = kill(pid, SIGCONT);
|
||||||
if (error) err(EX_UNAVAILABLE, "kill %d", pid);
|
if (error) err(EX_UNAVAILABLE, "kill %d", pid);
|
||||||
}];
|
}
|
||||||
|
];
|
||||||
|
|
||||||
[[NSApplication sharedApplication] run];
|
[[NSApplication sharedApplication] run];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue