Skip to main content

Custom Gnome Notification for your apps

When you run a command that would take long time to finish, you would rather do something else beside staring at the terminal to wait until it finished to do the next procedure. In my case, if I write the SD cards for my ts-7260, I would leave it and do other stuff.

Since it is easy to get distracted with so many stuff on the internet, I sometimes forget to get back to check the dd terminal. This could waste my time because the process have stopped for quite long time where I should write another card instead just right after the first card finished.

Therefore, I use notify-send from libnotify-bin package to notify me about my process while I'm free to check my mail, reading, surfing and so on. Here is the screenshot of my gnome notification when it is ready.

It can be done with one line of command like this:

notify-send -i /usr/share/icons/Human/scalable/devices/media-flash.svg \
-h int:x:$(xrandr -q|grep '*' | sed -e 's/x.*//' -e 's/\ //g') \
-h int:y:10 -u normal -t 10000 "Copy SD card from dd Image" \
"dd image to /dev/sdd finished"'!' ; mplayer /usr/share/sounds/purple/receive.wav

However, the above command is long and I wouldn't dare to type this command every time I will write new SD card. As usual, the lazy programmer would make a bash script for this repetitive task:

# default device name

# the icon

# check my command arguments
if [ $# -gt 0 ]; then

# create the message
mymsg="dd image to $mydev finished"
mytitle="Copying SD card image"

# get my resolution
myres=$(xrandr -q|grep '*' | sed -e 's/x.*//' -e 's/\ //g')

# the sound

# and the notify command
notify-send -i $sd_icon -h int:x:$myres -h int:y:10 -u normal -t 10000 "$mytitle" "$mymsg"'!' & mplayer $mysound

After copying to /usr/bin and change the mode to +x like this:

apogee-ubuntubox:$ sudo cp /usr/bin/
apogee-ubuntubox:$ sudo chmod +x /usr/bin/

Now, we can run the script like this:

apogee-ubuntubox:$ sudo dd if=myddimage.dd of=/dev/sdc ; /dev/sdc

Therefore, when the dd process finished, the notification will pop and the sound will play. You can also download the code here:

That's all for today... see you later!


Popular posts from this blog

How to Create Hyperlink on Blogger Post

Well, this time I make a basic simple tutorial. For all advanced geek who read this blog, please ignore this post... I just wanna help myself not to teach the same basic thing on every newbies friends that really need help.

OK guys, back to the howto...

There are two ways to create a hyperlink on your blog post. One is the simple GUI way and the other is coders way. I prefer the coder way as I can have more control on it.

I like to teach by example. So, let say you wanna create a hyperlink on this line of words...

You can go here to see my art blog

where you wanna link the word "here" to the other page on your blog or on the internet. In this example, I wanna link it to my Art Of Apogee Blog post with the address:

And here is how to do it using both ways...

The simple GUI way

If you rollover every button on your Compose toolbar, you can see one button called "Link" where the word Link will pop up when yo…

How to Show and Hide Text in Blog Post

I would like to share on how to make a Show/Hide text in your blog post. I'm sorry if I didn't explain detail enough because I want to keep my post short as I'm in a hurry. However, you can read the detail explanation on Blogger Help.

In this example, I assume you have sub topics that you want to make it hidden until reader clicks on the headline. Without the show/hide trick, it would look like this...

Title OneThis is the example text for title one.
Title TwoThis is the example text for title two.
Title ThreeThis is the example text for title three.
Here's my step to do this... Firstly, edit your template and add the following code in the CSS area.

.posthidden {display:none}
.postshown {display:inline}
Then add the following javascript code on your blog template between the <head></head> tag.

<script type="text/Javascript"> function expandcollapse (postid) { whichpost = document.getElementById(postid); if (whichpost.className==&q…

VBScript Get File Extension

Before anything else, you may love to read this book too!...

Actually, I got this question from the reader of my previous blog post about VBScript to Replace Underscores in Filename with Spaces for All Files in a Folder, and I decided to answer it here.

Question from Justin:
I tried something simular..but modified your VBS..
'======================================================== ' VBScript to replace underscore in file name with space ' for each files in a folder ' Written by ApOgEE of '======================================================== Dim sName Dim fso Dim fol ' create the filesystem object Set fso = WScript.CreateObject("Scripting.FileSystemObject") ' get current folder Set fol = fso.GetFolder(".") ' go thru each files in the folder For Each fil In fol.Files ' check if the file name contains underscore If InStr(1, fil.Name, "The ") <> 0 Then ' replace underscore with…