I have an OLED screen on my laptop that I have configured to show status information. The current driver I have installed in Linux for it is able to display messages by sending them to a script as an argument separated by spaces.
Example: the command /opt/asusg50oled/utils/notify.sh Hi Everybody "Hello World"
displays on the oled screen:
Hi
Everybody
Hello World
If another message is sent before the old ones disappear and it reverts to status info, it pushes off the top message. Example: less than 30 seconds after the previous example, /opt/asusg50oled/utils/notify.sh "Bananas have potassium"
is executed:
Everybody
Hello World
Bananas have potassium
What I want to do is have kernel messages (the kind you see by running dmesg
) forwarded to this script. For example, when I insert a USB drive, the following information would show on the OLED screen as they're logged:
[ 1283.200150] usb 2-4: new high speed USB device using ehci_hcd and address 4
[ 1283.353322] scsi9 : usb-storage 2-4:1.0
[ 1284.351366] scsi 9:0:0:0: Direct-Access SanDisk Cruzer 1.03 PQ: 0 ANSI: 2
[ 1284.352697] sd 9:0:0:0: Attached scsi generic sg4 type 0
[ 1284.355669] sd 9:0:0:0: [sdd] 31266816 512-byte logical blocks: (16.0 GB/14.9 GiB)
[ 1284.357032] sd 9:0:0:0: [sdd] Write Protect is off
[ 1284.357041] sd 9:0:0:0: [sdd] Mode Sense: 03 00 00 00
[ 1284.357047] sd 9:0:0:0: [sdd] Assuming drive cache: write through
[ 1284.364356] sd 9:0:0:0: [sdd] Assuming drive cache: write through
[ 1284.364371] sdd: sdd1
[ 1284.371656] sd 9:0:0:0: [sdd] Assuming drive cache: write through
[ 1284.371666] sd 9:0:0:0: [sdd] Attached SCSI removable disk
Note that given the limited width of the screen, stripping the timestamps would also be useful. So at the end of the logging, the screen would show for about 30 seconds:
sdd: sdd1
sd 9:0:0:0: [sdd] Assuming drive cache: write through
sd 9:0:0:0: [sdd] Attached SCSI removable disk
So, to clarify, I want kernel messages to be sent live by executing /opt/asusg50oled/utils/notify.sh "$MESSAGE"
I can throw in filters to weed out anything I don't want to see later, I just want to know how to do the parts mentioned above. How can I do this?