Commit 21bda95a authored by putro's avatar putro

added check_if_X_is_running and editMessage functions

parent 921c7dc9
......@@ -159,3 +159,30 @@ def isGpg(message):
def isAscii(text):
return all(ord(c) < 128 for c in text)
def editMessage():
import sys, tempfile, os
from subprocess import call
EDITOR = os.environ.get('EDITOR','vim')
initial_message = "" # if you want to set up the file somehow
with tempfile.NamedTemporaryFile(suffix=".tmp") as tempfile:
tempfile.write(initial_message)
tempfile.flush()
call([EDITOR, tempfile.name])
f = open(tempfile.name, "r")
data=f.read()
f.close()
return data
def X_is_running():
from subprocess import Popen, PIPE
p = Popen(["xset", "-q"], stdout=PIPE, stderr=PIPE)
p.communicate()
return p.returncode == 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment