Log file OSD

When working on something in GUI mode it's not easy to keep track of the logs. I wrote the following bash script to tail a log file and send each line to libnotify so I get OSD log events.

watch-log.sh
  1. #!/bin/bash
  2. # watch-log.sh: monitor text file for a new line of entry and display it via libnotify
  3. #
  4. # Copyright 2011 Sudaraka Wijesinghe
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program.  If not, see <http: //www.gnu.org/licenses/>.
  18. #
  19. #
  20. # USAGE:
  21. #	./watch-log.sh file [&]
  22. #
  23.  
  24. if [[ ! -f $1 ]];
  25. then
  26. 	echo "Unable to read file $1"
  27. 	exit 1
  28. fi
  29.  
  30. tail -n0 -f $1|while read line;
  31. do
  32. 	notify-send "$1" "$line"
  33. done