Register
It is currently Fri Dec 19, 2014 10:02 pm

My Bash Phone Book - Version 2 - using kdialog


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Thu Oct 05, 2006 1:36 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
:lol: :lol: :lol: :lol: Ok, so it's really NOT that impressive, or complicated for that matter... but it does work pretty well, and i use it ;) I'm sure that you could make improvements to it ---- feel free.... post your changes here for everyone to benefit from if you want too. Below is a screenshot (contians several screenshots actually). I made liberal use of the yast_answeringmachine icon (the red phone icon). It's nothing spectacular, but it is much faster than many of the huge applications they have for phone numbers. Tell me what ya think ;)

Image

Make note of my "suggestions" in the code:
Quote:

# Suggestions:
# Copy file into /home/$USER/bin/bpb
# chmod /home/$USER/bin/bpb a+x # To make it executable
# Create an icon on the KDE desktop by right clicking and "create new" "link to application"
# Browse to /home/$USER/bin/bpb and then you can also customize the icon and link name of the icon.

Here is the code for the program......
Code:
#!/bin/bash
#
##########################
# USA Linux Users Group  #
# http://www.usalug.org  #
# http://bashscripts.org #
# http://opensuse.us     #
##########################

#--------------------------------------------#
#    FILE: bpb - Bash Phone Book
#    VERSION: 2.0
#    DATE: Modified October 5, 2006
#    AUTHOR: Dave Crouse
#    License: GPL
#--------------------------------------------#

# Suggestions:
# Copy file into /home/$USER/bin/bpb
# chmod /home/$USER/bin/bpb a+x # To make it executable
# Create an icon on the KDE desktop by right clicking and "create new" "link to application"
# Browse to /home/$USER/bin/bpb and then you can also customize the icon and link name of the icon.

mkdir -p ~/.baps
rm -f /tmp/checkchoice.*
touch ~/.baps/phone.data
cat /dev/null > ~/.baps/temp.data
cat /dev/null > ~/.baps/list.data
declare TEMPFILE="/tmp/checkchoice.$$"

mainmenu ()
{
kdialog --radiolist "Bash Phone Book: Select an option." \
         s "Search Records" on \
         a "Add Record" off \
         r "Remove Record" off \
         l "List all Records" off \
         > "$TEMPFILE"
option=`cat $TEMPFILE`
   case $option in
      s)   searchrecords; ;;
      a)   addrecord; ;;
      r)   removerecord; ;;
      l)   listallrecords; ;;
   esac
}

addrecord ()
{
kdialog --title "ADD RECORD" --inputbox "Enter Name" > "$TEMPFILE"
name=`cat $TEMPFILE`
kdialog --title "ADD RECORD" --inputbox "Enter Phone Number" > "$TEMPFILE"
number=`cat $TEMPFILE`
entry="$name $number"
echo $entry >> ~/.baps/phone.data
kdialog --msgbox "Record Added \n\n $name \n $number"
mainmenu
}

searchrecords ()
{
cat /dev/null > ~/.baps/temp.data
kdialog --title "SEARCH RECORDS" --inputbox "Search For:" > "$TEMPFILE"
searchforthis=`cat $TEMPFILE`
grep -i "$searchforthis" ~/.baps/phone.data > ~/.baps/temp.data
sort -d ~/.baps/temp.data | nl -ba > ~/.baps/list.data
kdialog --textbox ~/.baps/list.data 440 100
mainmenu
}

removerecord ()
{
touch ~/.baps/temp2.data; cat /dev/null > ~/.baps/temp2.data;
sort -d ~/.baps/phone.data > ~/.baps/temp2.data
mv ~/.baps/temp2.data  ~/.baps/phone.data
nl -ba ~/.baps/phone.data >  ~/.baps/list.data
kdialog --title "LINE NUMBER TO DELETE ?" --textbox ~/.baps/list.data 440 440
kdialog --title "LINE NUMBER TO DELETE ?" --inputbox "Enter the Line number you wanted to delete." > "$TEMPFILE"
removeline=`cat $TEMPFILE`
if [ "$removeline" -gt "0" ] 2>/dev/null; then
cat /dev/null > ~/.baps/temp2.data;
cat ~/.baps/phone.data | sed ''$removeline'd' > ~/.baps/temp2.data
mv ~/.baps/temp2.data ~/.baps/phone.data
kdialog --msgbox "Record REMOVED !!"
else
kdialog --msgbox "Sorry, wanted a number. Try again."
fi
mainmenu
}

listallrecords ()
{
cat /dev/null > ~/.baps/temp.data
sort -d ~/.baps/phone.data > ~/.baps/temp.data
kdialog --textbox ~/.baps/temp.data 440 440
mainmenu
}

mainmenu
exit 0


Top
 Profile WWW  
 PostPosted: Thu Oct 05, 2006 4:07 pm   
User avatar

Joined: Tue May 17, 2005 12:55 am
Posts: 86
Location: Big Easy, Louisiana
It looks good crouse :!:


Top
 Profile YIM  
 PostPosted: Thu Oct 05, 2006 9:45 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
Thanks. :)

My first full script using kdialog.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP