aboutsummaryrefslogtreecommitdiff
path: root/logout-manager-tcl.py
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-03-10 16:52:22 -0400
committerB Stack <bgstack15@gmail.com>2020-03-10 16:52:22 -0400
commit86d9bf400c78ad535adaf0da82a31a149d8795f7 (patch)
tree8c7352ad8b863b25b921fb72ff63cf6d6ab614be /logout-manager-tcl.py
parentadd zeroindex bool (diff)
downloadlogout-manager-86d9bf400c78ad535adaf0da82a31a149d8795f7.tar.gz
logout-manager-86d9bf400c78ad535adaf0da82a31a149d8795f7.tar.bz2
logout-manager-86d9bf400c78ad535adaf0da82a31a149d8795f7.zip
use /etc/default/logout-manager and conf files
Diffstat (limited to 'logout-manager-tcl.py')
-rwxr-xr-xlogout-manager-tcl.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/logout-manager-tcl.py b/logout-manager-tcl.py
index 8c4bc6a..127bd54 100755
--- a/logout-manager-tcl.py
+++ b/logout-manager-tcl.py
@@ -7,6 +7,7 @@
# Purpose: A tcl/tk graphical program for selecting shutdown, logout, etc.
# History:
# Usage:
+# logout-manager-tcl.py
# References:
# http://effbot.org/tkinterbook/button.htm
# http://effbot.org/tkinterbook/tkinter-application-windows.htm
@@ -22,18 +23,17 @@
# tooltips https://stackoverflow.com/questions/3221956/how-do-i-display-tooltips-in-tkinter/41381685#41381685
# Improve:
# Dependencies:
-# devuan: python3-tk python3-pil.imagetk python3-cairosvg
+# Devuan: python3-tk python3-pil.imagetk python3-cairosvg
# el7: python36-tkinter python36-pillow-tk ( pip3 install cairosvg )
-import glob, re
+import glob, os, platform, re, sys
import tkinter as tk
from functools import partial
from pathlib import Path
from sys import path
+from dotenv import load_dotenv
# loading PIL.ImageTk after tkinter makes ImageTk use the PIL version, which supports PNG. This is important on tcl < 8.6 (that is, el7)
from PIL import Image, ImageTk
-path.append("/home/bgirton/dev/logout-manager")
-import lmlib
LM_USE_SVG = 0
try:
@@ -43,8 +43,20 @@ except:
print("WARNING: Unable to import cairosvg. No svg images will be displayed.")
LM_USE_SVG = 0
-config = lmlib.Initialize_config()
-actions = lmlib.Actions
+# 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
print("Loading graphics...")
@@ -388,9 +400,12 @@ class App:
#def something(event=None):
# print("Got here!")
-root = tk.Tk()
+# load configs
+config = lmlib.Initialize_config(os.environ['LOGOUT_MANAGER_CONF'])
+actions = lmlib.Actions
# MAIN LOOP
+root = tk.Tk()
root.title("Log out options")
imgicon = get_scaled_icon(config.get_logout_icon(),24,config.get_icon_theme())
root.tk.call('wm','iconphoto', root._w, imgicon)
bgstack15