Skip to content

Commit

Permalink
terminal-screen: show notifications
Browse files Browse the repository at this point in the history
when a foreground process terminates
if the window isn't active
  • Loading branch information
sc0w committed Oct 27, 2023
1 parent e3d0c7d commit e833d88
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ requires:
- git
- libdconf-dev
- libglib2.0-dev
- libnotify-dev
- libsm-dev
- libtool
- libx11-dev
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ PKG_CHECK_MODULES([TERM],
gio-2.0 >= $GIO_REQUIRED
ctk+-3.0 >= $CTK_REQUIRED
dconf >= $DCONF_REQUIRED
libnotify
x11])

# ********
Expand Down
27 changes: 27 additions & 0 deletions src/terminal-screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo.h>

#include <libnotify/notify.h>

#include "terminal-accels.h"
#include "terminal-app.h"
#include "terminal-debug.h"
Expand Down Expand Up @@ -129,6 +131,8 @@ static void terminal_screen_window_title_changed (BteTerminal *bte_terminal
TerminalScreen *screen);
static void terminal_screen_icon_title_changed (BteTerminal *bte_terminal,
TerminalScreen *screen);
static void terminal_screen_text_inserted (BteTerminal *bte_terminal,
TerminalScreen *screen);

static void update_color_scheme (TerminalScreen *screen);

Expand Down Expand Up @@ -380,6 +384,9 @@ terminal_screen_init (TerminalScreen *screen)
g_signal_connect (screen, "icon-title-changed",
G_CALLBACK (terminal_screen_icon_title_changed),
screen);
g_signal_connect (screen, "text-inserted",
G_CALLBACK (terminal_screen_text_inserted),
screen);

g_signal_connect (terminal_app_get (), "notify::system-font",
G_CALLBACK (terminal_screen_system_font_notify_cb), screen);
Expand Down Expand Up @@ -1928,6 +1935,26 @@ terminal_screen_icon_title_changed (BteTerminal *bte_terminal,
FALSE);
}

static void
terminal_screen_text_inserted (BteTerminal *bte_terminal,
TerminalScreen *screen)
{
if ((ctk_window_is_active (CTK_WINDOW (terminal_screen_get_window (screen))) == FALSE) &&
(terminal_screen_has_foreground_process (screen) == FALSE))
{
notify_init ("cafe-terminal");
NotifyNotification *notification;

notification = notify_notification_new ("cafe-terminal",
_("Process completed"),
"utilities-terminal");

notify_notification_show (notification, NULL);
g_object_unref (G_OBJECT (notification));
notify_uninit();
}
}

static void
terminal_screen_child_exited (BteTerminal *terminal, int status)
{
Expand Down

0 comments on commit e833d88

Please sign in to comment.