Skip to content

Simple bash script with address book bash completion to send SMS from the command line

License

Notifications You must be signed in to change notification settings

cyberang3l/kdeconnect-sms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

kdeconnect-sms

Simple bash script to send text messages from the command line with the kdeconnect-cli command. Read more about KDE connect here: https://play.google.com/store/apps/details?id=org.kde.kdeconnect_tp&hl=en.

The incentive behind the creation of this script is to provide simple address book functionality with bash autocompletion for sending text messages from the command line. Therefore, one does not have to lookup for a phone number manually and type it each time a message needs to be sent.

I did not bother about fancy integrations with Google contact lists or Akonadi stuff from the KDE community. This script intends to be simple as all I need is a simple name/phone address book that can be maintained in a simple text file. The most important feature that this script provides is the address book and the bash autocompletion functionality based on the address book. Other than that, it is a simple wrapper of the kdeconnect-cli command.

Installation

Download the script from github and create a symbolic link in a folder available in your $PATH environment variable:

cd /opt
sudo git clone https://github.com/cyberang3l/kdeconnect-sms.git
sudo ln -s /opt/kdeconnect-sms/kdeconnect-sms /usr/local/bin/kdeconnect-sms

TIP: If you think the kdeconnect-sms command name just feels too long to type, you can always rename the symlink to whatever you like. The bash completion code will still work, as it is based on the basename of the command. I personally rename it to the shorter sms by changing the ln -s command from the previous code box to:

sudo ln -s /opt/kdeconnect-sms/kdeconnect-sms /usr/local/bin/sms

Create a sample .addressBook file in you home directory and edit as needed:

cat << EOF > ~/.addressBook
# Add the unique hex ID of the mobile device that you want to use
# for sending text messages in the variable "phoneIdToUse" below.
#
# You can get a list of all kde connect paired phone ids with the
# command "kdeconnect-cli -l".
#
phoneIdToUse=0123456789abcdef

# Rules for the addressBook:
#  1. One Name/phone per line.
#  2. The Name and phone must be enclosed in double quotes.
#  3. The name/phone must be separated by one or more whitespace characters (tabs or spaces).
#  4. Do not use the '|' character in your names or phones.
#
addressBook=(
	"John Doe"	"+4712345678"
	"Jane Doe"	"+306971234567"
)
EOF

Enable bash-completion for the script:

sed -i -n -e '/^source.*kdeconnect-sms/!p' -e '$a source <(kdeconnect-sms --bash-completion)' ~/.bashrc

NOTE: If you have used a different name for the kdeconnect-sms command, you should replace the occurrences of the kdeconnect-sms in the previous sed command to whatever name you have used.

Usage

$ kdeconnect-sms --help
Usage: kdeconnect-sms [OPTIONS] --send-to <phoneNumber> "text-message"
Uses kdeconnect-cli to send an sms to a phone number
listed in a user-maintained address book.

 -a, --address-book           Prints the address book nicely formatted.
 -b, --bash-completion        Prints the code for bash-completion.
                               add this line at the end of your
                               .bashrc file:
                                       source <(kdeconnect-sms -b)
 -s, --send-to PHONE_NUMBER   The phone number to send the SMS to.
                               This is a mandatory option.
 -h, --help                   Prints this help message

Demo

demo-bash-completion

About

Simple bash script with address book bash completion to send SMS from the command line

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages