Skip to content

Commit

Permalink
Fixed macOS notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
rundong08 committed Jul 28, 2021
1 parent 17e803b commit 3e1ca91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Future<void> cancel(int id) async {
}

_notifications.remove(id);
await Process.run(_alerterBinary, ['-remove', '$id']);
await Process.start(_alerterBinary, ['-remove', '$id'],
mode: ProcessStartMode.inheritStdio);
}

Future<int> notify(int id, String title, String body, {int timeout = 0}) async {
Expand Down
9 changes: 9 additions & 0 deletions taqo_client/macos/TaqoLauncher/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

import Cocoa
import Darwin

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
Expand All @@ -32,9 +33,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
NSLog("Launching taqo_daemon at")
NSLog(taqoDaemon.absoluteString)

// Create a pseudo tty as the stdin of taqo_daemon, so that when taqo_daemon calls
// alerter, alerter won't read an empty message from the stdin.
let fd = posix_openpt(O_RDWR)
grantpt(fd)
unlockpt(fd)
let pty = FileHandle.init(forUpdatingAtPath: String.init(cString: ptsname(fd)))

let task = Process()
task.executableURL = URL(fileURLWithPath: taqoDaemon.absoluteString)
task.arguments = []
task.standardInput = pty
do {
try task.run()
} catch {
Expand Down

0 comments on commit 3e1ca91

Please sign in to comment.