Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # By LoathingKernel
- # Needs sudo without interactive password for the dmesg command and clears dmesg.
- # Keeps a log of dmesg with conky color information, timestamps and text wrapping.
- # Colors can be easily cleared with sed.
- # At same point will be rewritten with diff
- LOGFILE=$HOME/.conky/dmesg.log
- LOGNEWLINES=$(sudo dmesg -c | sed 's/.\{80\} /&\n\t/g')
- ## Colors
- #RED="${color #EF2929}"
- #ORANGE="${color #FCAF3E}"
- #YELLOW="${color #FCE94F}"
- #GREEN="${color #8AE234}"
- #BLUE="${color #729FCF}"
- #PURPLE="${color #AD7FA8}"
- if [ -n "$LOGNEWLINES" ]
- then
- ## Read the date
- TIMESTAMP=$(date +"%d-%m-%Y %T")
- ## Read the log
- if [ -f $HOME/.conky/dmesg.log ]
- then
- LOGLASTLINE=$(cat $HOME/.conky/dmesg.log | tail -1)
- else
- LOGLASTLINE=""
- fi
- ## Find the color of the last line and append the new lines
- if [ $(echo "$LOGLASTLINE" | grep -c "EF2929") -eq 1 ]
- then
- echo "$LOGNEWLINES" | sed "1i\Timestamp: \\${TIMESTAMP}" | sed 's/^/${color #FCAF3E} /' >> $HOME/.conky/dmesg.log
- elif [ $(echo "$LOGLASTLINE" | grep -c "FCAF3E") -eq 1 ]
- then
- echo "$LOGNEWLINES" | sed "1i\Timestamp: \\${TIMESTAMP}" | sed 's/^/${color #FCE94F} /' >> $HOME/.conky/dmesg.log
- elif [ $(echo "$LOGLASTLINE" | grep -c "FCE94F") -eq 1 ]
- then
- echo "$LOGNEWLINES" | sed "1i\Timestamp: \\${TIMESTAMP}" | sed 's/^/${color #8AE234} /' >> $HOME/.conky/dmesg.log
- elif [ $(echo "$LOGLASTLINE" | grep -c "8AE234") -eq 1 ]
- then
- echo "$LOGNEWLINES" | sed "1i\Timestamp: \\${TIMESTAMP}" | sed 's/^/${color #729FCF} /' >> $HOME/.conky/dmesg.log
- elif [ $(echo "$LOGLASTLINE" | grep -c "729FCF") -eq 1 ]
- then
- echo "$LOGNEWLINES" | sed "1i\Timestamp: \\${TIMESTAMP}" | sed 's/^/${color #AD7FA8} /' >> $HOME/.conky/dmesg.log
- elif [ $(echo "$LOGLASTLINE" | grep -c "AD7FA8") -eq 1 ]
- then
- echo "$LOGNEWLINES" | sed "1i\Timestamp: \\${TIMESTAMP}" | sed 's/^/${color #EF2929} /' >> $HOME/.conky/dmesg.log
- else
- echo "$LOGNEWLINES" | sed "1i\Timestamp: \\${TIMESTAMP}" | sed 's/^/${color #EF2929}/' >> $HOME/.conky/dmesg.log
- fi
- fi
- if [ -f $HOME/.conky/dmesg.log ]
- then
- tail -40 $HOME/.conky/dmesg.log
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement