From 70386c93f24cf3d36c01321ad3d786f7941f5d57 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 30 Nov 2018 17:16:59 -0500 Subject: Reformat sandman Objective-C code --- sandman.m | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/sandman.m b/sandman.m index 12a4817..7d2f56a 100644 --- a/sandman.m +++ b/sandman.m @@ -40,33 +40,34 @@ int main(int argc, char *argv[]) { pid_t pid = fork(); if (pid < 0) err(EX_OSERR, "fork"); - if (!pid) { execvp(argv[1], &argv[1]); err(EX_NOINPUT, "%s", argv[1]); } - NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; - NSNotificationCenter *center = [workspace notificationCenter]; - NSOperationQueue *main = [NSOperationQueue mainQueue]; - - [center addObserverForName:NSWorkspaceWillSleepNotification - object:nil - queue:main - usingBlock:^(NSNotification *note) { - (void)note; - int error = kill(pid, SIGTSTP); - if (error) err(EX_UNAVAILABLE, "kill %d", pid); - }]; - - [center addObserverForName:NSWorkspaceDidWakeNotification - object:nil - queue:main - usingBlock:^(NSNotification *note) { - (void)note; - int error = kill(pid, SIGCONT); - if (error) err(EX_UNAVAILABLE, "kill %d", pid); - }]; + [ + [[NSWorkspace sharedWorkspace] notificationCenter] + addObserverForName: NSWorkspaceWillSleepNotification + object: nil + queue: [NSOperationQueue mainQueue] + usingBlock: ^(NSNotification *note) { + (void)note; + int error = kill(pid, SIGTSTP); + if (error) err(EX_UNAVAILABLE, "kill %d", pid); + } + ]; + + [ + [[NSWorkspace sharedWorkspace] notificationCenter] + addObserverForName: NSWorkspaceDidWakeNotification + object: nil + queue: [NSOperationQueue mainQueue] + usingBlock: ^(NSNotification *note) { + (void)note; + int error = kill(pid, SIGCONT); + if (error) err(EX_UNAVAILABLE, "kill %d", pid); + } + ]; [[NSApplication sharedApplication] run]; } -- cgit 1.4.1-2-gfad0