Hack and / - Message for You Sir
It's easy to forget dæmons are there unless they demand your attention. A few years ago, I was walking through the expo floor at OSCON, when I noticed someone in a full BSD dæmon costume getting his picture taken with a few fans. When I saw them trying to figure out how to arrange everyone for the picture I couldn't help but yell, “No! The dæmon is always in the background!”
In case you didn't get the joke, dæmon is a name UNIX people give to processes that run behind the scenes (in the background). Dæmons perform all sorts of useful functions from executing scripts at a certain time (atd and crond) to listening for network connections and spawning the appropriate process to serve the request (inetd). In fact, the d at the end of those scripts stands for dæmon, and you might notice that a number of processes on your system right now end in d.
The whole point of a dæmon is to perform tasks without your intervention or knowledge, but sometimes, it's handy for a dæmon to alert you when a certain condition occurs. On a server, this usually means the dæmon will send an e-mail alert to the administrator, but what about on a desktop? What if you want a dæmon to alert you when you have new e-mail? In that case, it makes more sense for some sort of notice to pop up on your desktop. In this column, I discuss three different methods I use so that dæmons can get my attention on my desktop.
I think the first time I noticed OSD (On-Screen Display) notifications on Linux was with a volume control program. I increased the volume on my computer, and right in the middle of the screen was a volume meter floating above all my other windows, just like on a TV. I instantly was intrigued and had to figure out how they did it. These days, there are a number of different OSD libraries and programs, but my favorite is still osd_cat.
The osd_cat program is a command-line program that displays text sent to it in a pipe. The fact that it accepts piped input makes it ideal for dæmon notification, because it's easy to add to any shell script. This command is part of the xosd-bin package on Debian-based systems, or xosd on Red Hat, and has been around for a number of years.
The simplest way to test osd_cat is to pipe some text to it:
$ echo "Hello World" | osd_cat
If you look at the top left-hand side of your screen, you should see your message appear in a small red font for a few seconds and then disappear. Of course, if you didn't know to look there, you might assume the program is broken because the message is so small. Plus, everyone knows green is the ideal foreground color, so let's spruce up that notification a bit and put it front and center:
$ echo "Hello World" | osd_cat --align=center --pos=bottom ↪--color=green --font=lucidasanstypewriter-bold-24
Ahh, that's more like it, a notification right in the middle of the screen. As you can see, osd_cat accepts a number of options that can control how and where it displays your message. The man page covers all the options in detail, but I highlight the options I used here. The --align argument controls the text alignment much like a word processor and can be set to left (default), center or right. The --pos option controls the Y orientation on the screen and can be set to top (default), middle or bottom. The --color option is self-explanatory, as is --font. If you do want a different font but aren't sure what value to use, just run xlsfonts to see a full list.
In addition to the options I listed, osd_cat has many other options, such as --indent and --offset, that allow you to fine-tune where it displays your text, so you can position it virtually anywhere on the screen. You also can tweak the time the message appears on the screen with the --delay option, and if you plan to pipe multiple lines of text to the screen, be sure to look into the --lines, --age and --wait options, so you can control how osd_cat will scroll multiple lines. There are even --barmode and --percentage options that let you draw a slider bar, much like the OSD volume control I saw.
All of those options are nice, but honestly, I find myself sticking to basic text notifications with osd_cat, and although I have migrated many of my scripts to libnotify, I still like to use osd_cat for audio/video notification, such as when I use a script I wrote to turn on the VGA output on my laptop for presentations. I mentioned this script in my original Lightning Hacks column, but in case you didn't see it, here it is again:
#!/bin/sh
if xrandr | grep -q 'VGA connected'; then
echo "LVDS + VGA" | osd_cat --shadow=2 --align=center
↪--pos=bottom --color=green --delay=2
↪--font=lucidasanstypewriter-bold-24 --offset 40 &
# choose my laptop screen's resolution by default;
# if that fails, try the auto-detected mode
xrandr --output VGA --mode 1280x768@60 || xrandr
↪--output VGA --auto
else
echo "LVDS only" | osd_cat --shadow=2 --align=center
↪--pos=bottom --color=green --delay=2
↪--font=lucidasanstypewriter-bold-24 --offset 40 &
xrandr --output VGA --off &
fi
I find it's nice to add visual notifications like this whenever I trigger a script in the background with a keybinding and it's not immediately obvious the script ran, such as in this case, when I'd like to know whether I'm in presentation or regular mode, and it might take the projector a few seconds to respond.
Kyle Rankin is a systems architect; and the author of DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks, and Ubuntu Hacks.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- Home, My Backup Data Center
- Please correct the URL for Salt Stack's web site
1 hour 41 min ago - Android is Linux -- why no better inter-operation
3 hours 56 min ago - Connecting Android device to desktop Linux via USB
4 hours 25 min ago - Find new cell phone and tablet pc
5 hours 23 min ago - Epistle
6 hours 52 min ago - Automatically updating Guest Additions
8 hours 49 sec ago - I like your topic on android
8 hours 47 min ago - This is the easiest tutorial
15 hours 22 min ago - Ahh, the Koolaid.
21 hours 1 min ago - git-annex assistant
1 day 3 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Blink
Unable to locate this blink program....
One of the main issues of this program is that it has such a generic name. There was a kernel driver by this name that was removed because it was buggy and problematic. I however am not using a distro so maybe the programs is listed somewhere in a respoistory but a google search turns up no sources or anything for it. If anyone is following this article maybe you can post sources for it or post a location for the sources. If nothing gets posted I may consider writing something small in c if its even possible.
blink?
I'm using fedora 12, but I can't seem to find blink in any packages.
Any suggestions?