diff --git a/data/gsettings/com.gexperts.Terminix.gschema.xml b/data/gsettings/com.gexperts.Terminix.gschema.xml
index f81cc618..2ab35b53 100644
--- a/data/gsettings/com.gexperts.Terminix.gschema.xml
+++ b/data/gsettings/com.gexperts.Terminix.gschema.xml
@@ -77,6 +77,12 @@
'system'
Which theme variant to use
+
+
+ true
+ Whether to notify when a process is completed
+ If true, notifications will be sent when non-visible processes complete in terminals.
+
false
diff --git a/source/gx/terminix/appwindow.d b/source/gx/terminix/appwindow.d
index c38b9c5e..9e706d58 100644
--- a/source/gx/terminix/appwindow.d
+++ b/source/gx/terminix/appwindow.d
@@ -104,6 +104,8 @@ private:
SessionNotificationPopover poSessionNotifications;
SessionNotification[string] sessionNotifications;
+
+ GSettings gsSettings;
/**
* Create the user interface
@@ -386,14 +388,16 @@ private:
void onSessionProcessNotification(string summary, string _body, string terminalUUID, string sessionUUID) {
trace(format("Notification Received\n\tSummary=%s\n\tBody=%s", summary, _body));
- //If window not active, send notification to shell
- if (!isActive()) {
+ // If window not active, send notification to shell
+ if (!isActive() && gsSettings.getBoolean(SETTINGS_NOTIFY_ON_PROCESS_COMPLETE_KEY)) {
Notification n = new Notification(_(summary));
n.setBody(_body);
n.setDefaultAction("app.activate-session::" ~ sessionUUID);
getApplication().sendNotification("command-completed", n);
//if session not visible send to local handler
- } else if (sessionUUID != getCurrentSession().sessionUUID) {
+ }
+ // If session not active, keep copy locally
+ if (sessionUUID != getCurrentSession().sessionUUID) {
trace(format("SessionUUID: %s versus Notification UUID: %s", sessionUUID, getCurrentSession().sessionUUID));
//handle session level notifications here
ProcessNotificationMessage msg = ProcessNotificationMessage(terminalUUID, summary, _body);
@@ -555,8 +559,8 @@ public:
this(Application application) {
super(application);
- trace("Adding window to terminix");
terminix.addAppWindow(this);
+ gsSettings = new GSettings(SETTINGS_ID);
setTitle(_("Terminix"));
setIconName("terminal");
diff --git a/source/gx/terminix/preferences.d b/source/gx/terminix/preferences.d
index 1f8d7a0a..3b6d828d 100644
--- a/source/gx/terminix/preferences.d
+++ b/source/gx/terminix/preferences.d
@@ -23,6 +23,7 @@ enum SETTINGS_THEME_VARIANT_LIGHT_VALUE = "light";
enum SETTINGS_THEME_VARIANT_DARK_VALUE = "dark";
enum SETTINGS_PROMPT_ON_NEW_SESSION_KEY = "prompt-on-new-session";
+enum SETTINGS_NOTIFY_ON_PROCESS_COMPLETE_KEY = "notify-on-process-complete";
enum SETTINGS_SEARCH_DEFAULT_MATCH_CASE = "search-default-match-case";
enum SETTINGS_SEARCH_DEFAULT_MATCH_ENTIRE_WORD = "search-default-match-entire-word";
diff --git a/source/gx/terminix/prefwindow.d b/source/gx/terminix/prefwindow.d
index e3606415..d6812a26 100644
--- a/source/gx/terminix/prefwindow.d
+++ b/source/gx/terminix/prefwindow.d
@@ -14,6 +14,7 @@ import gdk.Event;
import gio.Settings;
+import gobject.Signals;
import gobject.Value;
import gtk.AccelGroup;
@@ -40,6 +41,8 @@ import gtk.TreeView;
import gtk.TreeViewColumn;
import gtk.Widget;
+import vte.Terminal;
+
import gx.gtk.actions;
import gx.gtk.util;
@@ -372,6 +375,14 @@ private:
settings.bind(SETTINGS_PROMPT_ON_NEW_SESSION_KEY, cbPrompt, "active", GSettingsBindFlags.DEFAULT);
attach(cbPrompt, 0, row, 2, 1);
row++;
+
+ //Show Notifications, only show option if notifications are supported
+ if (Signals.lookup("notification-received", Terminal.getType()) != 0) {
+ CheckButton cbNotify = new CheckButton(_("Send desktop notification on process complete"));
+ settings.bind(SETTINGS_NOTIFY_ON_PROCESS_COMPLETE_KEY, cbNotify, "active", GSettingsBindFlags.DEFAULT);
+ attach(cbNotify, 0, row, 2, 1);
+ row++;
+ }
Label lblAppearance = new Label("");
lblAppearance.setUseMarkup(true);
diff --git a/source/gx/terminix/session.d b/source/gx/terminix/session.d
index 147f57ae..2e3d2795 100644
--- a/source/gx/terminix/session.d
+++ b/source/gx/terminix/session.d
@@ -445,7 +445,9 @@ private:
}
}
- //De/Serialization code in this private block
+/************************************************
+ * De/Serialization code in this private block
+ ************************************************/
private:
string _filename;
diff --git a/source/gx/terminix/terminal/terminal.d b/source/gx/terminix/terminal/terminal.d
index efc53d99..f0747d3f 100644
--- a/source/gx/terminix/terminal/terminal.d
+++ b/source/gx/terminix/terminal/terminal.d
@@ -406,7 +406,7 @@ private:
vte.addOnFocusIn(&onTerminalFocusIn);
vte.addOnFocusOut(&onTerminalFocusOut);
vte.addOnNotificationReceived(delegate(string summary, string _body, VTE terminal) {
- if (titleInitialized) {
+ if (titleInitialized && !terminal.hasFocus()) {
notifyProcessNotification(summary, _body, terminalUUID);
}
});