Skip to content

Commit

Permalink
Do not set a default app activation for terminal-notifier
Browse files Browse the repository at this point in the history
As using -activate is blocking terminal-notifier execution (julienXX/terminal-notifier#223),
a default value is not set anymore.

It will only block users that really want the feature.
  • Loading branch information
jcgay committed Nov 1, 2017
1 parent ab8c0d1 commit 61f142f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ public void send(Notification notification) {
commands.add(notification.message());
commands.add(CMD_GROUP);
commands.add(application.id());
commands.add(CMD_ACTIVATE);
commands.add(configuration.activateApplication());
if (configuration.activateApplication() != null) {
commands.add(CMD_ACTIVATE);
commands.add(configuration.activateApplication());
}
commands.add(CMD_CONTENT_IMAGE);
commands.add(notification.icon().asPath());
if (configuration.sound() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
public abstract class TerminalNotifierConfiguration {

private static final TerminalNotifierConfiguration DEFAULT = new AutoValue_TerminalNotifierConfiguration(
"terminal-notifier", "com.apple.Terminal", null
"terminal-notifier", null, null
);

public abstract String bin();

@Nullable
public abstract String activateApplication();

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class SimpleNotificationCenterSpec extends Specification {
def setup() {
def configuration = TerminalNotifierConfiguration.create([
'notifier.notification-center.path':TerminalNotifierConfiguration.byDefault().bin(),
'notifier.notification-center.activate':TerminalNotifierConfiguration.byDefault().activateApplication(),
'notifier.notification-center.sound':'default'
] as Properties)
notifier = new SimpleNotificationCenterNotifier(configuration, executor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TerminalNotifierSpec extends Specification {
def setup() {
def configuration = TerminalNotifierConfiguration.create([
'notifier.notification-center.path':TerminalNotifierConfiguration.byDefault().bin(),
'notifier.notification-center.activate':TerminalNotifierConfiguration.byDefault().activateApplication(),
'notifier.notification-center.activate':'com.apple.Terminal',
'notifier.notification-center.sound':'default'
] as Properties)
notifier = new TerminalNotifier(application, configuration, executor)
Expand Down Expand Up @@ -61,7 +61,7 @@ class TerminalNotifierSpec extends Specification {
!executor.executedCommand.contains('-subtitle')
}

def "should not set sound when configuration does not includes one"() {
def "should not set sound when configuration does not include one"() {
given:
def notifier = new TerminalNotifier(application, TerminalNotifierConfiguration.byDefault(), executor)
def notification = Notification.builder('title', 'message', TestIcon.ok()).build()
Expand All @@ -73,6 +73,18 @@ class TerminalNotifierSpec extends Specification {
!executor.executedCommand.contains('-sound')
}

def "should not set activation when configuration does not include one"() {
given:
def notifier = new TerminalNotifier(application, TerminalNotifierConfiguration.byDefault(), executor)
def notification = Notification.builder('title', 'message', TestIcon.ok()).build()

when:
notifier.send(notification)

then:
!executor.executedCommand.contains('-activate')
}

def "should return true when binary is available"() {
given:
RuntimeExecutor executor = Mock()
Expand Down

0 comments on commit 61f142f

Please sign in to comment.