nixCraft Linux / UNIX / Shell Scripting Forum

nixCraft

Linux / UNIX Tech Support Forum

Utilize Popups In Your Shell Scripts

This is a discussion on Utilize Popups In Your Shell Scripts within the Getting started tutorials forums, part of the Linux Getting Started category; SOURCE= Linux Journal This was pretty cool. Wanted to share with you all. Notify-send is a great application for notifying ...


Register free or login to your account to remove all advertisements.

Go Back   nixCraft Linux / UNIX / Shell Scripting Forum > Linux Getting Started > Getting started tutorials

Linux answers from nixCraft.


Getting started tutorials So much to read, so little time! If that is your problem, we have solution. Read our FAQ and tutorials to help you cut through the clutter of information overload. Only members of "contributors" group can post new tutorials. Other members can just reply to thread.

Reply

 

Thread Tools Display Modes
  #1 (permalink)  
Old 5th September 2009, 02:14 AM
jaysunn's Avatar
Contributors
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Scripting language: bourne again shell
Posts: 767
Thanks: 108
Thanked 104 Times in 95 Posts
Rep Power: 14
jaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud of
Default Utilize Popups In Your Shell Scripts

SOURCE= Linux Journal

This was pretty cool. Wanted to share with you all.


Notify-send is a great application for notifying you when an event has occurred. An event such as a script running to completion.

If notify-send is not installed on your machine already, install the package "libnotify1" (or possibly just "libnotify") from your repositories.

I easily installed this via synaptic on Ubuntu 9.0.4

Once installed you can simply type the following, at the command line, to display a pop-up message near your system tray:

Code:
notify-send "hello"
By default the message will be displayed for 5 seconds. To change how long a message stays displayed use the "-t" switch. This will change, in milliseconds, how long the message is displayed. Enter "-t 0" to leave the message up until the user closes it.

Code:
notify-send "This message will be displayed for 3 seconds" -t 3000
notify-send "Click me to close me." -t 0
You can even add a title and an icon to the notification.

Code:
notify-send "This is the Title" \
            "Check out the cool icon" \
            -i /usr/share/pixmaps/gnome-terminal.png
When used in a script you could set it to notify you periodically by placing the command in a loop:

Code:
#!/bin/bash

while [ 1 ]; do
     notify-send "Up Time" "`uptime`"
     sleep 5m
done


__________________
Have a look at what I have been working on
http://www.shellasaurus.com

Last edited by jaysunn; 5th September 2009 at 02:17 AM.
Reply With Quote
  #2 (permalink)  
Old 7th September 2009, 10:00 PM
nixcraft's Avatar
Never say die
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash, Perl, Python
Posts: 3,195
Thanks: 13
Thanked 394 Times in 292 Posts
Rep Power: 10
nixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond repute
Default

Excellent tip. For cronjob just add DISPLAY variable, otherwise it will not work. Did you tested it from a cron job?
__________________
Vivek Gite
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Do you run a Linux? Let's face it, you need help!
Cricket & IPL News Blog
Reply With Quote
  #3 (permalink)  
Old 7th September 2009, 10:10 PM
jaysunn's Avatar
Contributors
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Scripting language: bourne again shell
Posts: 767
Thanks: 108
Thanked 104 Times in 95 Posts
Rep Power: 14
jaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud of
Default

Thanks,

I have not personally ran it from a cron job. However very interested to try when I return to the office on Tuesday. I will be sure to add the display variable.

Jaysunn
__________________
Have a look at what I have been working on
http://www.shellasaurus.com
Reply With Quote
Reply

Tags
desktop notify-send script, gui notify send shell script, notify-send, notify-send shell script, shell scripting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
[Solved] Command with shell scripts different server vampire Shell scripting 2 20th July 2009 06:31 PM
[Solved] Argument for shell scripts vampire Shell scripting 2 13th July 2009 05:56 PM
How to authenticate users in shell scripts udayakumar Shell scripting 4 22nd May 2009 01:11 PM
shell scripts required for students roni Shell scripting 6 20th July 2007 06:21 PM
running command a root in shell scripts chiku Shell scripting 1 17th July 2006 06:39 PM


All times are GMT +5.5. The time now is 08:55 PM.


Powered by vBulletin® Version 3.8.6 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40