Debian Codegraph @

ex/notify.d/400-notify-send

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/bin/sh
2
3 # needrestart - Restart daemons after library updates.
4 #
5 # Authors:
6 # Thomas Liske <[email protected]>
7 #
8 # Copyright Holder:
9 # 2013 - 2025 (C) Thomas Liske <[email protected]>
10 #
11 # License:
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17
18 # Use notify-send (from libnotify-bin) to notify a user session via dbus.
19
20 NSEND='/usr/bin/notify-send'
21 test -x "$NSEND" || exit 1
22
23 . /usr/lib/needrestart/notify.d.sh
24
25 if [ "$NR_NOTIFYD_DISABLE_NOTIFY_SEND" = '1' ]; then
26 echo "[$0] disabled in global config" 1>&2
27 exit 1
28 fi
29
30 case "$NR_SESSION" in
31 session*)
32 DBUS_SESSION_BUS_ADDRESS=$(sed -z -n s/^DBUS_SESSION_BUS_ADDRESS=//p "/proc/$NR_SESSPPID/environ")
33 if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
34 unset DBUS_SESSION_BUS_ADDRESS
35 fi
36
37 DISPLAY=$(sed -z -n s/^DISPLAY=//p "/proc/$NR_SESSPPID/environ")
38 export DISPLAY
39 XAUTHORITY=$(sed -z -n s/^XAUTHORITY=//p "/proc/$NR_SESSPPID/environ")
40 export XAUTHORITY
41
42 if [ -z "$DISPLAY" ]; then
43 echo "[$0] could not find DISPLAY for $NR_USERNAME on $NR_SESSION" 1>&2
44 exit 1
45 fi
46
47 echo "[$0] notify user $NR_USERNAME on $DISPLAY" 1>&2
48
49 MSGTITLE=$(gettext 'Relogin or restarts required!')
50 MSGBODY=$(gettext 'Your session is running obsolete binaries or libraries as listed below.
51 <i><b>Please consider a relogin or restart of the affected processes!</b></i>')'\n'$(cat)
52
53 runuser -p -u "$NR_USERNAME" -- "$NSEND" -a needrestart -u critical -i dialog-warning "$MSGTITLE" "$MSGBODY"
54 ;;
55 *)
56 echo "[$0] skip session '$NR_SESSION'" 1>&2
57 exit 1;
58 ;;
59 esac