Watching over logs in KDE

I know of a lot of people who enjoy having a terminal window with scrolling logs on their desktop. Setting one up was never a challange, but there are some nice KDE options that one could use that not so many people know about. At least I didn’t know until today.

First of all, the simpliest way you could have it is konsole -e tail -f some_log_file. Substitute some_log_file with your choice of log file. If you are out of ideas, /var/log/messages or /var/log/httpd/access.log might be a good start.

The problem that you might have discovered just now is that you’re running KDE as a regular user, while most of log files require root priviledges. At least all the interesting ones. Not to worry – sudo will save the day. As root edit /etc/sudoers and add the following line:

someuser  ALL=(ALL) NOPASSWD: ALL

Change someuser to your username. From now on, you can do whatever root can do by prepending sudo to your command. For example: sudo tail -f /var/log/messages. Nice, eh?

Back to that konsole window of yours. Simple watching of logs in it can now be done with konsole -e sudo tail -f some_log_file.

Good. What else?

By default, konsole window has a lot of attributes that are otherwise useful, but not when scrolling logs in it. I am talking about menubar, statusbar, scrollbar, history, and things like that. You can switch them all off. Take a look at the output of konsole --help. It suggests a number of options. Here is my first selection:

konsole --nohist --nomenubar --noframe \
--noscrollbar -e sudo tail -f some_log_file

It looks better now, but not perfect. More options are available with profiles. Right-click in konsole window and choose Settings menu. Change everything else to suit your needs. For example, make font smaller and configure proper encoding. Now select the Settings &raquo Save Sessions Profile menu. You’ll be asked for a name of the profile. Name it “Logs” or something meaningful.

Here is the full konsole command line that I use. Except for the some_log_file, of course.

konsole --vt_sz 120x3 --profile Logs \
--nohist --nomenubar --noframe --noscrollbar \
--schema Transparent.schema \
-e sudo tail -f some_log_file

You can see that I specify the profile to use, the schema that I want and terminal window size (columns by rows), as well as use all arguments discussed previously.

Now my terminal window looks even better, but there is still room for improvement. What else can be done? A bit. I want to get rid of the window title bar as I don’t need at all. And I want to have my logs terminal on all desktops.

KDE has an excellent utility which one could use to control window’s properties from the command line (as opposite from activating Window menu by pressing Alt+F3). It’s called kstart. You can have a look at its options by executing kstart --help.

Here is how the whole thing looks like:

kstart --alldesktops --type Override \
konsole --vt_sz 120x3 --profile Logs --nohist \
--nomenubar --noframe --noscrollbar \
--schema Transparent.schema \
-e sudo tail -f some_log_file

kstart starts on all desktops with the window that has no titlebar (type: Override) in which it runs konsole. konsole in turn resizes the window to 120 columns by 3 rows, switches off menus, scrollbars, frames, etc. Than it makes the window transparent, decreases the font size and executes the sudo. sudo adjusts the access level of the current user and makes it possible for tail -f some_log_file to work.

Presto!

Leave a Comment