Skip to content

Commit 61f142f

Browse files
committed
Do not set a default app activation for terminal-notifier
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.
1 parent ab8c0d1 commit 61f142f

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

send-notification/src/main/java/fr/jcgay/notification/notifier/notificationcenter/TerminalNotifier.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ public void send(Notification notification) {
5757
commands.add(notification.message());
5858
commands.add(CMD_GROUP);
5959
commands.add(application.id());
60-
commands.add(CMD_ACTIVATE);
61-
commands.add(configuration.activateApplication());
60+
if (configuration.activateApplication() != null) {
61+
commands.add(CMD_ACTIVATE);
62+
commands.add(configuration.activateApplication());
63+
}
6264
commands.add(CMD_CONTENT_IMAGE);
6365
commands.add(notification.icon().asPath());
6466
if (configuration.sound() != null) {

send-notification/src/main/java/fr/jcgay/notification/notifier/notificationcenter/TerminalNotifierConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
public abstract class TerminalNotifierConfiguration {
1010

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

1515
public abstract String bin();
1616

17+
@Nullable
1718
public abstract String activateApplication();
1819

1920
@Nullable

send-notification/src/test/groovy/fr/jcgay/notification/notifier/notificationcenter/SimpleNotificationCenterSpec.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class SimpleNotificationCenterSpec extends Specification {
1616
def setup() {
1717
def configuration = TerminalNotifierConfiguration.create([
1818
'notifier.notification-center.path':TerminalNotifierConfiguration.byDefault().bin(),
19-
'notifier.notification-center.activate':TerminalNotifierConfiguration.byDefault().activateApplication(),
2019
'notifier.notification-center.sound':'default'
2120
] as Properties)
2221
notifier = new SimpleNotificationCenterNotifier(configuration, executor)

send-notification/src/test/groovy/fr/jcgay/notification/notifier/notificationcenter/TerminalNotifierSpec.groovy

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TerminalNotifierSpec extends Specification {
2121
def setup() {
2222
def configuration = TerminalNotifierConfiguration.create([
2323
'notifier.notification-center.path':TerminalNotifierConfiguration.byDefault().bin(),
24-
'notifier.notification-center.activate':TerminalNotifierConfiguration.byDefault().activateApplication(),
24+
'notifier.notification-center.activate':'com.apple.Terminal',
2525
'notifier.notification-center.sound':'default'
2626
] as Properties)
2727
notifier = new TerminalNotifier(application, configuration, executor)
@@ -61,7 +61,7 @@ class TerminalNotifierSpec extends Specification {
6161
!executor.executedCommand.contains('-subtitle')
6262
}
6363

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

76+
def "should not set activation when configuration does not include one"() {
77+
given:
78+
def notifier = new TerminalNotifier(application, TerminalNotifierConfiguration.byDefault(), executor)
79+
def notification = Notification.builder('title', 'message', TestIcon.ok()).build()
80+
81+
when:
82+
notifier.send(notification)
83+
84+
then:
85+
!executor.executedCommand.contains('-activate')
86+
}
87+
7688
def "should return true when binary is available"() {
7789
given:
7890
RuntimeExecutor executor = Mock()

0 commit comments

Comments
 (0)