From 5dd15d255b2abaf22610a0c796dd80d0ff9549e8 Mon Sep 17 00:00:00 2001 From: Adrian Malacoda Date: Mon, 15 Mar 2021 02:17:29 -0500 Subject: [PATCH] add scripts for managing sms on pinephone --- sms/clear_sms | 8 ++++++++ sms/dump_sms | 10 ++++++++++ sms/list_sms | 4 ++++ sms/sms.py | 11 +++++++++++ 4 files changed, 33 insertions(+) create mode 100644 sms/clear_sms create mode 100644 sms/dump_sms create mode 100644 sms/list_sms create mode 100644 sms/sms.py diff --git a/sms/clear_sms b/sms/clear_sms new file mode 100644 index 0000000..d347307 --- /dev/null +++ b/sms/clear_sms @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +from sms import get_sms +from subprocess import call +from os.path import basename + +for sms in get_sms(): + print(sms) + call(["mmcli", "-m", "any", "--messaging-delete-sms", sms[0]]) diff --git a/sms/dump_sms b/sms/dump_sms new file mode 100644 index 0000000..7a991be --- /dev/null +++ b/sms/dump_sms @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +from sms import get_sms +from subprocess import call +from os.path import basename + +for sms in get_sms(): + print(sms) + out_file = "{}.{}.sms".format(basename(sms[0]), sms[1]) + print(">> dump to {}".format(out_file)) + call(["mmcli", "-m", "any", "--create-file-with-data", out_file, "--sms", sms[0]]) diff --git a/sms/list_sms b/sms/list_sms new file mode 100644 index 0000000..021bded --- /dev/null +++ b/sms/list_sms @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +from sms import get_sms +for sms in get_sms(): + print(sms) diff --git a/sms/sms.py b/sms/sms.py new file mode 100644 index 0000000..9dd531d --- /dev/null +++ b/sms/sms.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +from subprocess import call, check_output +from os.path import basename + +def parse_list_item(item): + item = item.strip().split(" ", 2) + item[1] = item[1][1:-1] + return tuple(item) + +def get_sms(): + return [parse_list_item(sms) for sms in check_output(["mmcli", "-m", "any", "--messaging-list-sms"]).decode().strip().split("\n")]