summaryrefslogtreecommitdiff
path: root/external/plyer/platforms/linux/email.py
diff options
context:
space:
mode:
Diffstat (limited to 'external/plyer/platforms/linux/email.py')
-rw-r--r--external/plyer/platforms/linux/email.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/external/plyer/platforms/linux/email.py b/external/plyer/platforms/linux/email.py
new file mode 100644
index 0000000..ceb5497
--- /dev/null
+++ b/external/plyer/platforms/linux/email.py
@@ -0,0 +1,36 @@
+import subprocess
+from urllib import quote
+try:
+ from urllib.parse import quote
+except ImportError:
+ from urllib import quote
+from plyer.utils import whereis_exe
+
+
+class LinuxEmail(Email):
+ def _send(self, **kwargs):
+ recipient = kwargs.get('recipient')
+ subject = kwargs.get('subject')
+ text = kwargs.get('text')
+
+ uri = "mailto:"
+ if recipient:
+ uri += str(recipient)
+ if subject:
+ uri += "?" if not "?" in uri else "&"
+ uri += "subject="
+ uri += quote(str(subject))
+ if text:
+ uri += "?" if not "?" in uri else "&"
+ uri += "body="
+ uri += quote(str(text))
+
+ subprocess.Popen(["xdg-open", uri])
+
+
+def instance():
+ import sys
+ if whereis_exe('xdg-open'):
+ return LinuxEmail()
+ sys.stderr.write("xdg-open not found.")
+ return Email()