Skip to content

Commit

Permalink
Prevent starting conflicting jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
richinfante committed Feb 15, 2019
1 parent b3a2547 commit edf6184
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions shbar2/AppDelegate.swift
Expand Up @@ -118,6 +118,8 @@ class ItemConfig : Codable {
}

@objc func startJob() {
self.currentJob?.terminate()

if let script = self.jobScript {
script.execute (launched: {
process in
Expand Down Expand Up @@ -180,6 +182,7 @@ class ItemConfig : Codable {
let subMenu = NSMenu()
let statusItem = NSMenuItem(title: "stopped", action: nil, keyEquivalent: "")
self.jobStatusItem = statusItem

let startItem = NSMenuItem(title: "start", action: nil, keyEquivalent: "")
startItem.action = #selector(ItemConfig.startJob)
startItem.target = self
Expand All @@ -188,9 +191,14 @@ class ItemConfig : Codable {
stopItem.action = #selector(ItemConfig.stopJob)
stopItem.target = self

let restartItem = NSMenuItem(title: "restart", action: nil, keyEquivalent: "")
restartItem.action = #selector(ItemConfig.startJob)
restartItem.target = self

subMenu.addItem(statusItem)
subMenu.addItem(startItem)
subMenu.addItem(stopItem)
subMenu.addItem(restartItem)

menuItem.submenu = subMenu

Expand Down

0 comments on commit edf6184

Please sign in to comment.