I'm searching for a way to show the content of a notify-send message in the lockscreen of Gnome 3.20. Normally this is configured under settings > notifications, but "notify-send" isn't mentioned there, only installed apps are.

Playing with dconf, especially under org.gnome.desktop.notifications application-children ['org-gnome-software', 'firefox', 'org-gnome-pomodoro', 'gnome-tweak-tool', 'evolution', 'ca-desrt-dconf-editor'] didn't help much either.

My notify-send script shows me affirmations, fetched from another file, every 30mins:

while : ; do
    notify-send -i /usr/share/icons/gnome/scalable/emotes/face-smile-big-symbolic.svg --hint int:transient:1 "$(sort -R ~/Sonstiges/Affirmationen/Affirmationen.txt | head -n 1)"
    sleep 30m           # Zeit in Minuten

Any ideas how to accomplish this?

  • I think you can't show notifications while on lightdm-greeter, maybe the notifications are going to your locked session. Maybe you can test something like this, try to send many (many) notifications maybe from a loop while session is locked, and then login to try to catch if they are been sended to locked session (I observed that notifications are stacked).
    – dgonzalez
    Jan 5, 2017 at 22:17
  • 1
    @dgonzalez Notifications are definitely shown in Gnome's 3.20 lockscreen, see here. My aim is to see the content of the notify-send message and not that I have one new message from notify-send.
    – DMT
    Jan 8, 2017 at 13:14
  • Sorry, my fault, somehow I missed you are running Gnome (so gdm instead of lightdm), i think too many tabs on my browser led me to misread the full title.
    – dgonzalez
    Jan 8, 2017 at 20:42

1 Answer 1


Thanks to Chris Williams (chrisawi) from the Gnome IRC Channel the following solution was found:

Create a script called notifier in /.local/bin/ with this content:


# License: MIT
# Author: Chris Williams

APP_ID = "com.example.Notifier"

import sys
from gi.repository import GLib, GObject, Gio

class Notifier(Gio.Application):
    def __init__(self):
        Gio.Application.__init__(self, application_id=APP_ID, flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
        self.set_option_context_parameter_string ("ID TITLE [MESSAGE...]")
        self.add_main_option("icon", ord('i'), GLib.OptionFlags.NONE, GLib.OptionArg.STRING, "Icon name or file", None)
        #self.add_main_option("quit", ord('q'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Quit", None)
        self.add_main_option(GLib.OPTION_REMAINING, 0, GLib.OptionFlags.NONE, GLib.OptionArg.STRING_ARRAY, "", None)

    def do_command_line(self, cl):
        Gio.Application.do_command_line(self, cl)
        opts = cl.get_options_dict().end().unpack()

        #if opts.get("quit"):
        #    self.quit()

        args = opts.get(GLib.OPTION_REMAINING, [])
        if len(args) >= 2:
            notification = Gio.Notification()

            if len(args) >= 3:
                notification.set_body(" ".join(args[2:]))

            icon_str = opts.get("icon")
            if icon_str:
                    icon = Gio.Icon.new_for_string(icon_str)
                except GLib.Error as e:
                    if not e.matches(Gio.io_error_quark(), Gio.IOErrorEnum.INVALID_ARGUMENT):

            self.send_notification(args[0], notification)
            print ("not enough arguments")

        return 0

if __name__ == '__main__':
    app = Notifier()

Mention it in the original notify-send script, that also lies in /.local/bin/:

while : ; do
    notifier -i emote-love-symbolic idxyz "$(sort -R ~/Sonstiges/Affirmationen/Affirmationen.txt | head -n 1)"
    sleep 30m   # time in minutes

You also have to create a .desktop file, either in /.local/share/applications/ or in /.config/autostart/ if you want this script to be executed at startup. My /affirmationen.desktop in /.config/autostart/ looks like this:

[Desktop Entry]


  • ubuntu 18.04? when I run the script nothing happens, any idea? also, this is not notify-send right? this is another application (in python)
    – VeganEye
    May 23, 2020 at 5:52
  • Works under 20.04, should also work under 18.04. Yes, it's a python script and not notify-send.
    – DMT
    Aug 11, 2020 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.