Page 1 of 1

Sending SMS via Mageia 6 kdeconnect

PostPosted: Aug 17th, '17, 11:02
by mackowiakp
Below is script, taken from (I dont remember the author - sorry) Internet and a little bit modify by me. It sends SMS from PC via Android phone.
Any suggestion how to connect it to Google or Thunderbird phone book?
Any improvements welcome!

Code: Select all
#!/bin/bash
kdeconnect-cli --refresh
urzadzenie=$(kdeconnect-cli -a --id-only 2>&1);

if [ "$urzadzenie" = "No devices found" ]; then
    kdialog --title "kconnect-cli" --msgbox "Nie wykryto urządzeń online!\nSparuj najpierw urządzenie w KDE Connect."
else

    if [ ${#urzadzenie} -gt 16 ]; then

        urzadzenie=$(kdialog --title "KDE Connect" --combobox "$(kdeconnect-cli -a) \n\nWybierz urządzenie:" $urzadzenie);
        case "$?" in
            0)
                if [ ${#urzadzenie} -eq 0 ]; then
                    kdialog --sorry "Nie wybrano żadnego urządzenia!";
                    exit 0;
                fi
            ;;

            1)
                exit 0;
            ;;
        esac;
    fi

    kto_tmp=$(kdialog --title "SMS" --inputbox "Wpisz numer telefonu:");
    ilosc=`echo -n $kto_tmp |sed 's/ //g' | wc -c`
    kto=`echo -n $kto_tmp |sed 's/ //g'`
    [ $ilosc -ne "9" ] && kdialog --error "Powinno być 9 cyfr - można używać spacji" && exit 1
    case ${kto#[-+]} in
        *[!0-9]* | '') kdialog --error "Powinno być 9 cyfr - bez liter i innych znaków"
               exit 1   ;;
        * ) ;;
        esac

    sms=$(kdialog --title "SMS" --textinputbox "Wpisz treść wiadomości do wysłania:");
        case "$?" in
            1)
                exit 0;
            ;;
        esac;

    kdialog --continue-label "Wyślij" --warningcontinuecancel "Wysłać SMS do $kto ("${tnumery[$kto]}") o treści:\n\n\"$sms\"";
        case "$?" in

            0)
                kdeconnect-cli -d $urzadzenie --destination $kto --send-sms "$sms" && notify-send -t 4000 -i kdeconnect-cli "Wysłano SMS'a!";
            ;;
            1)
                exit 0;
            ;;
        esac;
fi

Re: Sending SMS via Mageia 6 kdeconnect

PostPosted: Aug 17th, '17, 17:07
by doktor5000
For thunderbird, not in a way to query the adress book directly. You could take a look at related mork parsers like https://www.jwz.org/hacks/mork.pl (see https://developer.mozilla.org/en-US/doc ... /Structure for more current information on the fileformat ) and see whether you can adapt that to parse the two adress book files abook.mab and history.mab (the first one is your actual adress book, the latter are your collected adresses). You may be better off to regularly export the adress book to .csv via e.g. the export tools mentioned in https://groups.google.com/forum/#!topic ... VF4GgfVhPc and then use that .csv from your script.

For google address book you can take a look at e.g. https://gitlab.com/goobook/goobook or https://github.com/gedl/gc-csv or https://github.com/vinitkumar/googlecl
Alternatively import all your contacts regularly into something like abook.