Tech Tip: Use gxmessage for Displaying GUI Messages from Scripts
There are many dialog programs out there, Zenity, Kdialog, xdialog, etc. I love programs like these. They make it so easy to spice up a shell script with a little GUI action. Today I'm going to go look at a dialog program called gxmessage.
I just recently got a Nokia N900 (Every Linux user should get one) and while playing with it I found that a few programs on it were calling gxmessage to create a user interface. I found that it seemed to have a number of options and seemed easy to use. So I jumped on to my laptop and did a search through the repositories for it. I found it in a package called "gmessage". To install it just do the following:
sudo aptitude install gmessage
You can use this one line code to produce a GUI dialog with buttons:
gxmessage -center \
-buttons "This is my button":1,"This is my other button":2 \
-title "This is my dialog BOX" 'Linux is great!!!'
One of the nice features that gxmessage has, that some others don't, is the ability to choose the size of the dialog box using the "-geometry" switch.
gxmessage -center \
-buttons "This is my button":1,"This is my other button":2 \
-geometry 190x80 \
-title "This is my dialog BOX" 'Linux is great!!!'
Gxmessage will restrict you from making your dialog to0 small for the componets you have placed in it. For example, if you set the geometry to 10x10 and the dialog needs at lest 100x50 to display all your buttons and messages it will override your 10x10 and default to 100x50.
For each button you create you can asign it a numeric value which is indicated by placeing a colon after the buttons message followed by the numeric value you wish to asign to it. You can then grab the value of the button being pressed and use it to continue your script. Here is a short example:
#!/bin/bash
gxmessage -center \
-buttons "Yes":1,"Of Course":2 \
-geometry 290x80 \
-title "Linux Journal Question" 'Does Shawn Powers ROCK?'
answer=$?
case "$answer" in
1)
gxmessage -center "You said 'YES'"
;;
*)
gxmessage -center "I agree, Of Course."
;;
esac
I've only touched the surface here of what you can do with gxmessage, look through the man pages for more.
| Attachment | Size |
|---|---|
| gxmessage-1.png | 10.44 KB |
| gxmessage-2.png | 10.05 KB |
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
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Speed Up Your Web Site with Varnish | Jun 19, 2013 |
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
- Speed Up Your Web Site with Varnish
- Containers—Not Virtual Machines—Are the Future Cloud
- Linux Systems Administrator
- Non-Linux FOSS: libnotify, OS X Style
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- RSS Feeds
- Reply to comment | Linux Journal
3 hours 40 min ago - Yeah, user namespaces are
4 hours 56 min ago - Cari Uang
8 hours 28 min ago - user namespaces
11 hours 21 min ago - yea
11 hours 47 min ago - One advantage with VMs
14 hours 16 min ago - about info
14 hours 49 min ago - info
14 hours 50 min ago - info
14 hours 51 min ago - info
14 hours 53 min ago
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
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
@Csaba
Can't you just ssh into the user's box and export the DISPLAY variable to the user's current desktop and then run whatever X app you want and displaying it to the user? for example,
csaba@localhost:$ ssh user@remote.com
user@remotehost.com:$ export DISPLAY=:0
user@remotehost.com:$ /usr/bin/xapptobedisplayed
That should result in whatever /usr/bin/xapptobedisplayed program showing up on the user's desktop. Obviously the applications can be something like this gxmessage or whatever you want. Hope that helps.
gxmessage to just one person
I am running an LTSP setup in a high school with ubuntu. What I would like is to display a message like "you are running out of space, delete some.." after the user logged in. Right now there is a grace period but the user will not know about it. So basically what I am looking into is a way sending a message to a user. If I understand it correctly I need to figure out what user using what display then send a message regarding that. Hm, isn't there something easier?
gxmessage to just one person
I have been looking at using xmessage gxmessage to send a note to just one person on the local network.
But haven't found the howto.
Does anyone know how to do it?
thx, Csaba
Notify can be useful too
I've found myself adding notify-send to a lot of my scripts recently. This adds notification windows that appear for a certain amount of time and then disappear without user interaction - good for those "This just happened" messages that don't need a button pressed.
I actually wrote a tech tip
I actually wrote a tech tip about that a few months back:
http://www.linuxjournal.com/content/tech-tip-get-notifications-your-scri...
http://filmsbykris.com/
Everything you ever need to know about Open-Source Software.
gxmessage web site?
No link to the gxmessage web site? Where's the love? Here's what I found.
http://homepages.ihug.co.nz/~trmusson/programs.html#gxmessage