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/binand change the mode to +x like this:
apogee-ubuntubox:$ sudo cp notifyme.sh /usr/bin/
apogee-ubuntubox:$ sudo chmod +x /usr/bin/notifyme.sh
Now, we can run the script like this:
apogee-ubuntubox:$ sudo dd if=myddimage.dd of=/dev/sdc ; notifyme.sh /dev/sdc
Therefore, when the dd process finished, the notification will pop and the sound will play. You can also download the code here: notifyme.sh
That's all for today... see you later!