Awesome

Graue Fenster von Java-Programmen

_JAVA_AWT_WM_NONREPARENTING=1; export _JAVA_AWT_WM_NONREPARENTING

poplog.sh

   1 #!/bin/bash
   2 
   3 # Usage: ./popLog.sh /var/log/yourlog
   4 # pops a colored log with the last line of the log
   5 
   6 export DISPLAY=":0.0"
   7 export SYNTAXHIGHLIGHTFILE="/home/robert/.config/awesome/awesome.outlang" # CHANGE ME
   8 
   9 #Urgency
  10 infoUrgency='low'
  11 warningUrgency='normal'
  12 errorUrgency='critical'
  13 securityUrgency='critical'
  14  
  15 #Popup time
  16 infoPopupTime=5000
  17 warningPopupTime=8000
  18 errorPopupTime=11000
  19 securityPopupTime=11000
  20  
  21 #Icons
  22 infoIcon='/usr/share/icons/gnome/32x32/status/dialog-information.png'
  23 warningIcon='/usr/share/icons/gnome/32x32/status/dialog-warning.png'
  24 errorIcon='/usr/share/icons/gnome/32x32/status/dialog-error.png'
  25 securityIcon='/usr/share/icons/gnome/32x32/status/security-medium.png'
  26 
  27 coloredLog=$(tail -n 1 $1 |                   \
  28   source-highlight --failsafe                 \
  29                    --src-lang=log             \
  30                    --style-file=default.style \
  31                    --outlang-def=${SYNTAXHIGHLIGHTFILE})
  32 
  33 if [ -n "$coloredLog" ] ; then
  34     echo $coloredLog
  35     
  36     if $(echo $coloredLog | grep -q info) ; then messageType='info'; fi
  37     if $(echo $coloredLog | grep -q warn) ; then messageType='warning'; fi
  38     if $(echo $coloredLog | grep -q err) ; then messageType='error'; fi
  39     if $(echo $coloredLog | grep -q auth) ; then messageType='security'; fi
  40     if $(echo $coloredLog | grep -q access) ; then messageType='security';fi
  41     if $(echo $notification|grep 'UFW BLOCK INPUT') ; then
  42         messageType='security'; fi
  43     if [ -z "$messageType" ] ; then messageType='info'; fi
  44        echo $messageType
  45     case $messageType in
  46     info)
  47         urgency=$infoUrgency
  48         icon=$infoIcon
  49         popupTime=$infoPopupTime
  50     ;;
  51     warning)
  52         urgency=$warningUrgency
  53         icon=$warningIcon
  54         popupTime=$warningPopupTime
  55     ;;
  56     error)
  57         urgency=$errorUrgency
  58         icon=$errorIcon            
  59         popupTime=$errorPopupTime
  60     ;;
  61     security)
  62         urgency=$securityUrgency
  63         icon=$securityIcon        
  64         popupTime=$securityPopupTime
  65     ;;
  66     *)
  67         urgency=$errorUrgency
  68         icon=$errorIcon            
  69         popupTime=$errorPopupTime
  70     ;;
  71     esac
  72 
  73     notify-send -u $urgency -t $popupTime -i "$icon" "$1" "$coloredLog" 2> /tmp/notify-send-error
  74     #Maybe you will get something like „(notify-send:15339): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed“ when started from incrond :/ What to do in this case?
  75 fi

Wikinger: ComputerKram/Awesome (zuletzt geändert am 2017-01-02 11:35:41 durch Robert)