How is the terminal's "notify when shell command finishes" feature implemented?

I was using gnome-terminal on Fedora 40. There’s a feature where it sends a notification when a shell command completes while another window is focused.

I recently upgraded to Fedora 41, and now gnome-terminal no longer has this behavior, but the new default terminal (Ptyxis) does. I’ve confirmed it has this behavior regardless of whether it’s installed from the Fedora flatpak, RPM (sudo dnf install ptyxis), or Flathub.

However, when I install Ptyxis from Flathub on Ubuntu 24.04, it does not have this behavior, even after I ensured that it has notification permissions in GNOME Settings and Flatseal.

So, I assume this is an extra feature that Fedora adds for its default terminal app in each Workstation release (or perhaps any terminal that supports it, I haven’t tested others), and I’m curious how it’s implemented, particularly because it’s also present in the Flathub version of Ptyxis on Fedora, which suggests that Fedora is somehow implementing this feature without patching its flatpak/RPM version of Ptyxis.

The behavior only works in bash (didn’t work when I ran a command in zsh), and this source suggests it involves setting PROMPT_COMMAND in bash. I do see PROMPT_COMMAND getting set in /etc/bashrc, and if I run echo $PROMPT_COMMAND, I get:

printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"

which doesn’t look relevant to this feature.

How is this feature implemented? Is it documented somewhere? Is there a way to get this behavior on other Linux distros?

I’ve found numerous discussions about this topic, but I haven’t been able to get a clear answer:

Edit: Also works with gnome-console and blackbox-terminal installed via dnf, so it’s not specific to Ptyxis, though I don’t know why it no longer works with gnome-terminal after upgrading to Fedora 41.

Edit 2: Just noticed that Black Box explicitly includes a “Notification on Completed Task” option which also works on Ubuntu, so Black Box must implement that feature itself. But I’m still curious how Fedora is implementing the feature for e.g. Ptyxis.

1 Like

It’s typically implemented using job control, signals, and desktop notifications.

In Fedora 40 it’s implemented by this gnome-terminal patch and this vte patch.

In Fedora 41, we dropped all the downstream gnome-terminal and vte patches. The vte patches were upstreamed here. We do not have any Ptyxis patches either. Probably Ubuntu just has an older version of vte and/or Ptyxis than we do.

1 Like

That’s really helpful, thanks. My only remaining point of confusion is that I observed the notification behavior with Ptyxis installed from Flathub on Fedora, but not on Ubuntu (also installed from Flathub). Shouldn’t the Flathub version be the same regardless of the distro?

  1. Please check the version on the Distro you are installing it. The Software app should give this infos.
  1. There are two patches mentioned, independent of them if there are missing components it will also not work. Why you not just ask in the Ubuntu community for the question about Ubuntu.

We do know a lot here unfortunately we can not know everything. Especially question about other infrastructure/distributions.

I would expect so, yes. We don’t have any system/desktop-level customizations, so the operating system you use really shouldn’t matter. Not sure how to explain this; I must be missing something.

Well the point is when using the Flathub version, the software is identical so any behavior differences must be related to the host operating system. But that seems very strange in this case, since our patches were to the application itself.

1 Like

It’s worth noting that this feature requires VTE integration with the shell, which is usually provided by the host operating system.

In most distributions (including Fedora), you can find the integration script in /etc/profile.d/vte.sh.

I do know that command completion notification works with Flatpak Ptyxis on OpenSUSE, so it might just be an Ubuntu thing.