Update pytwmn to check in XDG config home for config file
This commit is contained in:
parent
5ffed58756
commit
e2d5b3316e
1 changed files with 9 additions and 2 deletions
|
@ -16,13 +16,20 @@ class TwmnError(Exception):
|
|||
|
||||
|
||||
def confExists():
|
||||
return os.path.exists(os.path.expanduser("~/.config/twmn/twmn.conf"))
|
||||
try:
|
||||
from xdg import BaseDirectory
|
||||
return os.path.join(BaseDirectory.xdg_config_home,"twmn/twmn.conf")
|
||||
except:
|
||||
return False
|
||||
|
||||
def init(host="127.0.0.1", port=None):
|
||||
if not port:
|
||||
port = 9797
|
||||
try:
|
||||
with open(os.path.expanduser("~/.config/twmn/twmn.conf")) as f:
|
||||
fn = confExists()
|
||||
if not fn:
|
||||
return False
|
||||
with open(fn) as f:
|
||||
for line in f.readlines():
|
||||
if line.startswith("port=") and \
|
||||
line[5:-1].isdigit():
|
||||
|
|
Loading…
Reference in a new issue