parent
22d974f22f
commit
e5877059ff
16 changed files with 285 additions and 160 deletions
@ -1,6 +1,6 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
pidof svkbd-sxmo >&2 || svkbd-sxmo & |
||||
OUTPUT="$(cat | dmenu -t $@)" |
||||
OUTPUT="$(cat | dmenu $@)" |
||||
pkill svkbd-sxmo >&2 |
||||
echo "$OUTPUT" |
||||
|
@ -0,0 +1,2 @@ |
||||
#!/usr/bin/env sh |
||||
st -fn "Terminus-14" -e tail -f ~/.sxmo/modemlog.tsv |
@ -1,58 +0,0 @@ |
||||
#!/usr/bin/env sh |
||||
EDITOR=vis |
||||
|
||||
err() { |
||||
echo $1 | dmenu -fn Terminus-20 -c -l 10 |
||||
exit 1 |
||||
} |
||||
|
||||
modem_n() { |
||||
mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 |
||||
} |
||||
|
||||
editmsg() { |
||||
TMP="$(mktemp --suffix $1_msg)" |
||||
echo "$2" > "$TMP" |
||||
TEXT="$(st -e $EDITOR $TMP)" |
||||
cat $TMP |
||||
} |
||||
|
||||
sendmsg() { |
||||
MODEM=$(modem_n) |
||||
SMSNO=$( |
||||
sudo mmcli -m $MODEM --messaging-create-sms="text='$2',number=$1" | |
||||
grep -o [0-9]*$ |
||||
) |
||||
sudo mmcli -s ${SMSNO} --send |
||||
for i in $(mmcli -m $MODEM --messaging-list-sms | grep " (sent)" | cut -f5 -d' ') ; do |
||||
sudo mmcli -m $MODEM --messaging-delete-sms=$i |
||||
done |
||||
} |
||||
|
||||
main() { |
||||
modem_n || err "Couldn't determine modem number - is modem online?" |
||||
|
||||
# Prompt for number |
||||
NUMBER=$( |
||||
echo -e "Enter Number: \nCancel" | |
||||
dmenu -p "Number" -fn "Terminus-20" -l 10 -c |
||||
) |
||||
echo "$NUMBER" | grep -E "^Cancel$" && exit 1 |
||||
|
||||
# Compose first version of msg |
||||
TEXT="$(editmsg $NUMBER 'Enter text message here')" |
||||
|
||||
while true |
||||
do |
||||
CHARS=$(echo "$TEXT" | wc -c) |
||||
CONFIRM=$( |
||||
echo -e "Message ($CHARS) to -> $NUMBER: ($TEXT)\nEdit\nSend\nCancel" | |
||||
dmenu -c -idx 1 -p "Confirm" -fn "Terminus-20" -l 10 |
||||
) |
||||
echo "$CONFIRM" | grep -E "^Send$" && sendmsg "$NUMBER" "$TEXT" && exit 0 |
||||
echo "$CONFIRM" | grep -E "^Cancel$" && exit 1 |
||||
echo "$CONFIRM" | grep -E "^Edit$" && TEXT="$(editmsg "$NUMBER" "$TEXT")" |
||||
done |
||||
} |
||||
|
||||
main |
@ -0,0 +1,90 @@ |
||||
#!/usr/bin/env sh |
||||
EDITOR=vis |
||||
LOGDIR=/home/$USER/.sxmo |
||||
|
||||
err() { |
||||
echo $1 | dmenu -fn Terminus-20 -c -l 10 |
||||
kill $$ |
||||
} |
||||
|
||||
modem_n() { |
||||
mmcli -L | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2 |
||||
} |
||||
|
||||
contacts() { |
||||
cat $LOGDIR/modemlog.tsv | cut -f3 | sort | uniq | awk NF |
||||
} |
||||
|
||||
editmsg() { |
||||
TMP="$(mktemp --suffix $1_msg)" |
||||
echo "$2" > "$TMP" |
||||
TEXT="$(st -e $EDITOR $TMP)" |
||||
cat $TMP |
||||
} |
||||
|
||||
sendmsg() { |
||||
MODEM=$(modem_n) |
||||
NUMBER="$1" |
||||
TEXT="$2" |
||||
TEXTSIZE="$(echo "$TEXT" | wc -c)" |
||||
|
||||
SMSNO=$( |
||||
sudo mmcli -m $MODEM --messaging-create-sms="text='$TEXT',number=$NUMBER" | |
||||
grep -o [0-9]*$ |
||||
) |
||||
sudo mmcli -s ${SMSNO} --send || err "Couldn't send text message" |
||||
for i in $(mmcli -m $MODEM --messaging-list-sms | grep " (sent)" | cut -f5 -d' ') ; do |
||||
sudo mmcli -m $MODEM --messaging-delete-sms=$i |
||||
done |
||||
|
||||
TIME="$(date --iso-8601=seconds)" |
||||
mkdir -p ~/.sxmo/$NUMBER |
||||
echo -ne "Sent to $NUMBER at $TIME:\n$TEXT\n\n" >> $LOGDIR/$NUMBER/sms.txt |
||||
echo -ne "$TIME\tsent_txt\t$NUMBER\t$TEXTSIZE chars\n" >> $LOGDIR/modemlog.tsv |
||||
|
||||
err "Sent text message ok" |
||||
} |
||||
|
||||
sendtextmenu() { |
||||
modem_n || err "Couldn't determine modem number - is modem online?" |
||||
|
||||
# Prompt for number |
||||
NUMBER=$( |
||||
echo -e "\nCancel\n$(contacts)" | |
||||
awk NF | |
||||
sxmo_dmenu_with_kb.sh -p "Number" -fn "Terminus-20" -l 10 -c |
||||
) |
||||
echo "$NUMBER" | grep -E "^Cancel$" && exit 1 |
||||
echo "$NUMBER" | grep -E '[0-9]+' || err "That doesn't seem like a valid number" |
||||
|
||||
# Compose first version of msg |
||||
TEXT="$(editmsg $NUMBER 'Enter text message here')" |
||||
|
||||
while true |
||||
do |
||||
CHARS=$(echo "$TEXT" | wc -c) |
||||
CONFIRM=$( |
||||
echo -e "Edit Message ($TEXT)\nSend to → $NUMBER\nCancel" | |
||||
dmenu -c -idx 1 -p "Confirm" -fn "Terminus-20" -l 10 |
||||
) |
||||
echo "$CONFIRM" | grep -E "^Send" && sendmsg "$NUMBER" "$TEXT" && exit 0 |
||||
echo "$CONFIRM" | grep -E "^Cancel$" && exit 1 |
||||
echo "$CONFIRM" | grep -E "^Edit Message" && TEXT="$(editmsg "$NUMBER" "$TEXT")" |
||||
done |
||||
} |
||||
|
||||
tailtextlog() { |
||||
st -e tail -f $LOGDIR/$1/sms.txt |
||||
} |
||||
|
||||
main() { |
||||
# Display |
||||
ENTRIES="$(echo -e "$(contacts)" | xargs -INUM echo NUM logfile)" |
||||
ENTRIES="$(echo -e "Close Menu\nSend a Text\n$ENTRIES")" |
||||
NUMBER="$(echo -e "$ENTRIES" | dmenu -p Texts -c -fn Terminus-20 -l 10)" |
||||
echo $NUMBER | grep "Close Menu" && exit 1 |
||||
echo $NUMBER | grep "Send a Text" && sendtextmenu && exit 1 |
||||
tailtextlog "$(echo $NUMBER | sed 's/ logfile//g')" |
||||
} |
||||
|
||||
main |
@ -1,8 +0,0 @@ |
||||
#!/usr/bin/env sh |
||||
DIR=/home/$USER/.sxmo |
||||
|
||||
# Warn for no texts |
||||
ls -1 $DIR | wc -l | grep -E '^0$' && echo "No texts!" | dmenu -fn Terminus-20 -l 10 -c && exit 1 |
||||
|
||||
# Display |
||||
ls -1 $DIR | dmenu -p Messages -c -fn Terminus-20 -l 10 | xargs -INUMBER st -e tail -f $DIR/NUMBER/sms.txt |
Loading…
Reference in new issue