aboutsummaryrefslogtreecommitdiff
path: root/src/usr/bin
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-04-03 15:38:21 +0000
committerB Stack <bgstack15@gmail.com>2020-04-03 15:38:21 +0000
commit25a302edc305fe9bf5cd5561c91769c659ea815f (patch)
treeaf3658a050028eb914180c8ddd83a33b0ba5a611 /src/usr/bin
parentMerge branch 'add-trayicon' into 'master' (diff)
parentMerge branch 'master' into 'dev' (diff)
downloadlogout-manager-25a302edc305fe9bf5cd5561c91769c659ea815f.tar.gz
logout-manager-25a302edc305fe9bf5cd5561c91769c659ea815f.tar.bz2
logout-manager-25a302edc305fe9bf5cd5561c91769c659ea815f.zip
Merge branch 'dev' into 'master'HEADmaster
minor refactor and add documentation Closes #1, #3, #2, #4, #5, and #6 See merge request bgstack15/logout-manager!3
Diffstat (limited to 'src/usr/bin')
-rwxr-xr-xsrc/usr/bin/logout-manager-cli (renamed from src/usr/bin/logout-manager-cli.py)19
-rwxr-xr-xsrc/usr/bin/logout-manager-gtk (renamed from src/usr/bin/logout-manager-gtk.py)8
-rwxr-xr-xsrc/usr/bin/logout-manager-ncurses (renamed from src/usr/bin/logout-manager-ncurses.py)12
-rwxr-xr-xsrc/usr/bin/logout-manager-tcl (renamed from src/usr/bin/logout-manager-tcl.py)11
-rwxr-xr-xsrc/usr/bin/logout-manager-trayicon17
5 files changed, 43 insertions, 24 deletions
diff --git a/src/usr/bin/logout-manager-cli.py b/src/usr/bin/logout-manager-cli
index 8fd78b4..974fd4b 100755
--- a/src/usr/bin/logout-manager-cli.py
+++ b/src/usr/bin/logout-manager-cli
@@ -1,28 +1,30 @@
#!/usr/bin/env python3
-# File: logout-manager-cli.py
+# File: logout-manager-cli
# License: CC-BY-SA 4.0
# Author: bgstack15
# Startdate: 2020-03-10 18:40
# Title: cli logout manager
# Purpose: Feature completeness in this package
# History:
+# 2020-04-03 fix #5 -n does nothing
# Usage:
-# logout-manager-cli.py
+# logout-manager-cli
# Reference:
# https://stackoverflow.com/questions/39092149/argparse-how-to-make-mutually-exclusive-arguments-optional/39092229#39092229
# https://stackoverflow.com/questions/3061/calling-a-function-of-a-module-by-using-its-name-a-string/12025554#12025554
# Improve:
# Dependencies:
-# Devuan: python3-dotenv python3
+# dep-devuan: python3-dotenv, python3
# Documentation:
-import os, platform, sys, argparse
+import os, sys, argparse
+from distro import linux_distribution
from dotenv import load_dotenv
# all this to load the libpath
try:
defaultdir="/etc/sysconfig"
- thisplatform = platform.platform().lower()
+ thisplatform = linux_distribution()[0].lower()
if 'debian' in thisplatform or 'devuan' in thisplatform:
defaultdir="/etc/default"
# load_dotenv keeps existing environment variables as higher precedent
@@ -32,12 +34,13 @@ except:
if 'LOGOUT_MANAGER_LIBPATH' in os.environ:
for i in os.environ['LOGOUT_MANAGER_LIBPATH'].split(":"):
sys.path.append(i)
+sys.path.append("/usr/share/logout-manager")
import lmlib
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
-logout_manager_cli_version="2020-03-10"
+logout_manager_cli_version="2020-04-03"
parser = argparse.ArgumentParser(description="run logout-manager commands using cli")
parser.add_argument('action', help='which action to take',nargs='?', choices=('lock','logout','hibernate','shutdown','reboot'))
@@ -47,6 +50,10 @@ parser.add_argument("-V","--version", action="version", version="%(prog)s " + lo
args = parser.parse_args()
+# handle -n
+if args.dryrun:
+ os.environ["DRYRUN"] = "from-parameters"
+
# load configs
# in cli, must happen after arparse to benefit from debug value
config = lmlib.Initialize_config(os.environ['LOGOUT_MANAGER_CONF'])
diff --git a/src/usr/bin/logout-manager-gtk.py b/src/usr/bin/logout-manager-gtk
index 553fc41..400594d 100755
--- a/src/usr/bin/logout-manager-gtk.py
+++ b/src/usr/bin/logout-manager-gtk
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# File: logout-manager-gtk.py
+# File: logout-manager-gtk
# License: CC-BY-SA 4.0
# Author: bgstack15
# Startdate: 2019-06-01
@@ -25,10 +25,11 @@
# support global conf file, and user conf file
# far future: provide graphical way to change commands run
# Dependencies:
-# Devuan: python3-dotenv
+# dep-devuan: python3-dotenv
# Documentation:
import gi, os, platform, sys
+from distro import linux_distribution
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from gi.repository import Gdk
@@ -39,7 +40,7 @@ from dotenv import load_dotenv
# all this to load the libpath
try:
defaultdir="/etc/sysconfig"
- thisplatform = platform.platform().lower()
+ thisplatform = linux_distribution()[0].lower()
if 'debian' in thisplatform or 'devuan' in thisplatform:
defaultdir="/etc/default"
# load_dotenv keeps existing environment variables as higher precedent
@@ -49,6 +50,7 @@ except:
if 'LOGOUT_MANAGER_LIBPATH' in os.environ:
for i in os.environ['LOGOUT_MANAGER_LIBPATH'].split(":"):
sys.path.append(i)
+sys.path.append("/usr/share/logout-manager")
import lmlib
# graphical classes and functions
diff --git a/src/usr/bin/logout-manager-ncurses.py b/src/usr/bin/logout-manager-ncurses
index 1500d85..67b18d7 100755
--- a/src/usr/bin/logout-manager-ncurses.py
+++ b/src/usr/bin/logout-manager-ncurses
@@ -1,11 +1,11 @@
#!/usr/bin/env python3
-# File: logout-manager-ncurses.py
+# File: logout-manager-ncurses
# License: MIT
# Author: adamlamers, bgstack15
# Startdate: 2020-03-09 17:06
# Title: ncurses based logout manager
# Usage:
-# logout-manager-ncurses.py
+# logout-manager-ncurses
# Reference:
# https://docs.python.org/3/howto/curses.html
# ripped straight from http://adamlamers.com/post/FTPD9KNRA8CT
@@ -13,20 +13,21 @@
# https://robinislam.me/blog/reading-environment-variables-in-python/
# Improve:
# Dependencies:
-# Devuan: python3-dotenv
+# dep-devuan: python3-dotenv
# Documentation:
# Improvements for CursesMenu class over origin:
# accepts number key inputs
# accepts enabled attribute
# add "zeroindex" bool
-import curses, os, platform, sys
+import curses, os, sys
+from distro import linux_distribution
from dotenv import load_dotenv
# all this to load the libpath
try:
defaultdir="/etc/sysconfig"
- thisplatform = platform.platform().lower()
+ thisplatform = linux_distribution()[0].lower()
if 'debian' in thisplatform or 'devuan' in thisplatform:
defaultdir="/etc/default"
# load_dotenv keeps existing environment variables as higher precedent
@@ -36,6 +37,7 @@ except:
if 'LOGOUT_MANAGER_LIBPATH' in os.environ:
for i in os.environ['LOGOUT_MANAGER_LIBPATH'].split(":"):
sys.path.append(i)
+sys.path.append("/usr/share/logout-manager")
import lmlib
class CursesMenu(object):
diff --git a/src/usr/bin/logout-manager-tcl.py b/src/usr/bin/logout-manager-tcl
index 127bd54..9cadc5c 100755
--- a/src/usr/bin/logout-manager-tcl.py
+++ b/src/usr/bin/logout-manager-tcl
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# File: logout-manager-tcl.py
+# File: logout-manager-tcl
# License: CC-BY-SA 4.0
# Author: bgstack15
# Startdate: 2019-06-12 20:05
@@ -7,7 +7,7 @@
# Purpose: A tcl/tk graphical program for selecting shutdown, logout, etc.
# History:
# Usage:
-# logout-manager-tcl.py
+# logout-manager-tcl
# References:
# http://effbot.org/tkinterbook/button.htm
# http://effbot.org/tkinterbook/tkinter-application-windows.htm
@@ -26,11 +26,11 @@
# Devuan: python3-tk python3-pil.imagetk python3-cairosvg
# el7: python36-tkinter python36-pillow-tk ( pip3 install cairosvg )
-import glob, os, platform, re, sys
+import glob, os, re, sys
import tkinter as tk
+from distro import linux_distribution
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
@@ -46,7 +46,7 @@ except:
# all this to load the libpath
try:
defaultdir="/etc/sysconfig"
- thisplatform = platform.platform().lower()
+ thisplatform = linux_distribution()[0].lower()
if 'debian' in thisplatform or 'devuan' in thisplatform:
defaultdir="/etc/default"
# load_dotenv keeps existing environment variables as higher precedent
@@ -56,6 +56,7 @@ except:
if 'LOGOUT_MANAGER_LIBPATH' in os.environ:
for i in os.environ['LOGOUT_MANAGER_LIBPATH'].split(":"):
sys.path.append(i)
+sys.path.append("/usr/share/logout-manager")
import lmlib
# graphical classes and functions
diff --git a/src/usr/bin/logout-manager-trayicon b/src/usr/bin/logout-manager-trayicon
index b6471f9..9eaaa32 100755
--- a/src/usr/bin/logout-manager-trayicon
+++ b/src/usr/bin/logout-manager-trayicon
@@ -2,12 +2,17 @@
# File: logout-manager-trayicon
# License: CC-BY-SA 4.0
# Author: bgstack15
+# Startdate: 2020-03-20
+# Title: Logout Manager tray icon
+# Purpose: An easy menu from the system tray in a panel for a window manager or desktop environment
+# History:
+# 2020-04-01 update for python 3.8
# Reference:
# icon work https://stackoverflow.com/questions/45162862/how-do-i-set-an-icon-for-the-whole-application-using-pygobject
# button right click must be from "button-press-event" and import Gdk https://python-gtk-3-tutorial.readthedocs.io/en/latest/menus.html
# useful reference https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Button.html#Gtk.Button
# systray info https://github.com/PiSupply/PiJuice/blob/master/Software/Source/src/pijuice_tray.py
-# logout-manager-gtk.py
+# logout-manager-gtk
# how to determine double click https://stackoverflow.com/questions/60009648/is-there-a-better-way-to-handle-double-click-in-pygobject
# interactive python3 shell and help(Gdk.EventType)
# https://developer.gnome.org/gtk3/unstable/GtkWidget.html#GtkWidget-button-press-event
@@ -15,10 +20,11 @@
# send signals https://stackoverflow.com/questions/15080500/how-can-i-send-a-signal-from-a-python-program
# https://docs.python.org/3.8/library/signal.html#module-signal
# Dependencies:
-# dep-pip: psutil
-# dep-devuan: python3-psutil
+# dep-pip: psutil, distro
+# dep-devuan: python3-psutil, python3-distro
-import gi, os, platform, re, sys, psutil, signal
+import gi, os, re, sys, psutil, signal
+from distro import linux_distribution
gi.require_version("Gtk","3.0")
from gi.repository import Gtk
from gi.repository import Gdk
@@ -27,7 +33,7 @@ from dotenv import load_dotenv
# all this to load the libpath
try:
defaultdir="/etc/sysconfig"
- thisplatform = platform.platform().lower()
+ thisplatform = linux_distribution()[0].lower()
if 'debian' in thisplatform or 'devuan' in thisplatform:
defaultdir="/etc/default"
# load_dotenv keeps existing environment variables as higher precedent
@@ -37,6 +43,7 @@ except:
if 'LOGOUT_MANAGER_LIBPATH' in os.environ:
for i in os.environ['LOGOUT_MANAGER_LIBPATH'].split(":"):
sys.path.append(i)
+sys.path.append("/usr/share/logout-manager")
import lmlib
def is_dryrun():
bgstack15