-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdmesg-notify-user
40 lines (31 loc) · 1.5 KB
/
dmesg-notify-user
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /bin/bash
#----------------------------------------------------------------------
# Description: show dmesg messages on the screen for modern Linux'es
# Fined tuned for lxdm-session
#
# Author: Artem S. Tashkinov
# Created at: Tue 10 Dec 2019 03:29:57 AM
# 2020-03-07 18:34:57 - skip FW messages
# 2020-04-05 01:18:14 - fix grep taking forever to process input (add --line-buffered)
# Computer: localhost.localdomain
# System: Linux 5.4.2-zen2 on x86_64
#
# Copyright (c) 2019 Artem S. Tashkinov All rights reserved.
#----------------------------------------------------------------------
icon=/usr/share/icons/gnome/48x48/status/dialog-warning.png
#git
#icon=/path/to/icon_32x32.png
timeout=3 # visual cue for this number of seconds
nl='
'
journalctl -kf | grep --line-buffered --invert-match "FW-INGRESS" | while read -r line1; read -r -t 1 line2; read -r -t 1 line3; true; do
test -n "$line2" && line1="$line1$nl"
test -n "$line3" && line2="$line2$nl"
# pid_lxdm=`pidof lxdm-session`
# Xuser=0 # this might not work - needs to be tested
# test -z "$pid_lxdm" || Xuser=`ps -u --ppid "$pid_lxdm" | tail -1 | awk '{print $1}'`
# if [ -n "$Xuser" ]; then
# su "$Xuser" -c "DISPLAY=:0 notify-send --expire-time="${timeout}000" --icon="${icon}" 'Kernel message' '$line1$line2$line3' &> /dev/null" &
# fi
notify-send --expire-time="${timeout}000" --icon="${icon}" "Kernel message" "$line1$line2$line3" &> /dev/null &
done