From 86d9bf400c78ad535adaf0da82a31a149d8795f7 Mon Sep 17 00:00:00 2001 From: B Stack Date: Tue, 10 Mar 2020 16:52:22 -0400 Subject: use /etc/default/logout-manager and conf files --- logout-manager-gtk.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'logout-manager-gtk.py') diff --git a/logout-manager-gtk.py b/logout-manager-gtk.py index c6f7a6b..553fc41 100755 --- a/logout-manager-gtk.py +++ b/logout-manager-gtk.py @@ -24,15 +24,31 @@ # only show debug info when DEBUG=1 or similar. # support global conf file, and user conf file # far future: provide graphical way to change commands run +# Dependencies: +# Devuan: python3-dotenv # Documentation: -import gi, sys +import gi, os, platform, sys gi.require_version("Gtk", "3.0") from gi.repository import Gtk from gi.repository import Gdk from gi.repository.GdkPixbuf import Pixbuf from pathlib import Path -sys.path.append("/home/bgirton/dev/logout-manager") +from dotenv import load_dotenv + +# all this to load the libpath +try: + defaultdir="/etc/sysconfig" + thisplatform = platform.platform().lower() + if 'debian' in thisplatform or 'devuan' in thisplatform: + defaultdir="/etc/default" + # load_dotenv keeps existing environment variables as higher precedent + load_dotenv(os.path.join(defaultdir,"logout-manager")) +except: + pass +if 'LOGOUT_MANAGER_LIBPATH' in os.environ: + for i in os.environ['LOGOUT_MANAGER_LIBPATH'].split(":"): + sys.path.append(i) import lmlib # graphical classes and functions @@ -225,7 +241,8 @@ class MainWindow(Gtk.Window): print("Cancel any logout action.") Gtk.main_quit() -config = lmlib.Initialize_config() +# load configs +config = lmlib.Initialize_config(os.environ['LOGOUT_MANAGER_CONF']) actions = lmlib.Actions # MAIN LOOP -- cgit