Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using zenity & gkrellm (attn: laptop owners)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
ka0ttic
Retired Dev
Retired Dev


Joined: 23 Oct 2003
Posts: 46
Location: Ormond Beach, FL

PostPosted: Sun Feb 22, 2004 11:19 pm    Post subject: Using zenity & gkrellm (attn: laptop owners) Reply with quote

Using zenity & gkrellm

Aaron Walker
ka0ttic at cfl dot rr dot com


This isn't solely a laptop-related tip, as I'm sure people could find other things to use it for, but I use this all the time on my laptop.

If you run GNOME, as I do, then you should have something called zenity installed (see the zenity(1) manual page, as there are a sleu of different options). Zenity allows you to show GTK+ dialogs by just typing a command.

In conjunction with the commonly-used gkrellm, zenity allows you to show prompts when certain conditions occur.

I use this all the time to alert me when my battery gets to 10% and then once again at 2%.

To enable this, right click on the monitor in gkrellm that you'd like to mess with, and somewhere in the properties for that monitor, you should see an "Alerts" button. Click on that, and you should be able to set commands.

For example, so that gkrellm will alert me when my battery is almost dead, I click on the "Alerts" button under the battery monitor. It allows you to set a "Low warn limit" and a "low alarm limit", which I set to 10 and 2, repectively (meaning 10% and 2%).

This is where zenity comes in. In my example, for the low warn limit command, I just type zenity --warning --text="10% battery remaining" and do the same thing for the low alarm limit.

It would also be possible to set the low alarm limit to say, 1% (you might want to test this to make sure 1% gives you enough time), then set the command to something like sudo halt, assuming you have sudo setup of course. This is a convienent way to automatically shut down when you're battery is almost dead. Of course, the low warn limit, could alert you before hand so you know that you either need to plug in the A/C adapter, a new battery, or save your stuff and get ready to shutdown.

Any comments/questions encouraged.

Hope you guys find this tip helpful.

Aaron
Back to top
View user's profile Send private message
vificunero
Apprentice
Apprentice


Joined: 25 Jul 2003
Posts: 244
Location: Milan Italy EU

PostPosted: Thu Mar 25, 2004 6:36 pm    Post subject: Reply with quote

Hi. Nice post: very useful to start to play with zenity and bash script.
Well I've written this little script for the second alert. It's my first script so I'd like to know what do you think about it:

Code:
#!/bin/bash
                                                                                                                   
FILE=`zenity --question --text=" 5 % battery. Do you want halt the system?"`
                                                                                                                   
if [ "$?" = 0 ] ; then
        halt
else
       zenity --warning --text="You don't want to halt the system.So it's up to you."
fi


Well it works but I'd like to know if I can write a better code.
Thank's.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum