From f5390f91104ca5c531a1e778ecfafadc0a668075 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Tue, 24 Sep 2024 16:11:26 -0400 Subject: add verbose, advanced (control other users), docs --- fprintd_tk.py | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'fprintd_tk.py') diff --git a/fprintd_tk.py b/fprintd_tk.py index 492f2eb..f7442d8 100755 --- a/fprintd_tk.py +++ b/fprintd_tk.py @@ -1,11 +1,23 @@ #!/usr/bin/env python3 +# File: fprintd_tk.py +# Location: https://bgstack15.cgit/fprintd-tk +# Author: bgstack15 # Startdate: 2024-09-22-1 14:26 +# SPDX-License-Identifier: GPL-3.0-only +# Title: Gui for fprintd # Purpose: tkinter desktop gui app for management fingerprint enrollments -# Dependencies: -# python3-tkstackrpms, python3-tk, python3-pil -# References: +# Project: fprintd-tk +# History: +# Usage: +# Run from window manager application menu +# Reference: # stackrpms_tk.py # Improve: +# Dependencies: +# dep-devuan: python3-tkstackrpms, python3-tk, python3-pil +# fprintd_tk_lib.py +# Documentation: +# README.md import tkinter as tk, os, tkinter.simpledialog, sys, threading, time import tkstackrpms as stk @@ -19,7 +31,7 @@ SPDX-License-Identifier: GPL-3.0-only Icons adapted from Numix-Icon-Theme-Circle (GPL 3) """ -# configurable by admin +# configurable by admin or installation img_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"images") # These will be used a lot in the program. @@ -39,13 +51,15 @@ class App(tk.Frame): self.advanced.trace_add("write",self.load_data_into_form) self.current_username = os.getenv("USER") self.username = tk.StringVar(value=self.current_username) + self.verbose = tk.BooleanVar(value=False) self.master.title("Gui for fprintd") imgicon = stk.get_scaled_icon("fingerprint-gui",24,"default", "","apps") self.master.tk.call("wm","iconphoto",self.master._w,imgicon) menu = tk.Menu(self.master) menu_file = tk.Menu(menu,tearoff=0) - menu_file.add_checkbutton(label="Advanced features", variable=self.advanced, underline=0) + menu_file.add_checkbutton(label="Advanced features", variable=self.advanced, underline=0, state="disabled") + menu_file.add_checkbutton(label="Verbose", variable=self.verbose, underline=0) menu_file.add_command(label="Delete...", command=self.func_delete, underline=0) menu_file.add_separator() menu_file.add_command(label="Exit", command=self.func_exit, underline=1) @@ -106,6 +120,15 @@ class App(tk.Frame): # status bar stk.StatusBar(self.master,var=self.statustext) + # check if user has setusername polkit-1 permission, which lets him control fingerprint enrollments for other users. + temp1 = lib.check_setusername_permission(self.func_update_status) + if self.verbose.get(): + print(f"DEBUG (init): has set_username: {temp1}") + if temp1: + #self.chk_advanced.configure(state="enabled") + #menu_file.child[0].child[0].configure(state="enabled") + menu_file.entryconfigure(0,state="normal") + #print(menu_file.children) # and now, load data into form for the first time self.load_data_into_form() @@ -128,10 +151,12 @@ class App(tk.Frame): # show advanced toolbar used_user = self.get_used_user() if advanced: - print(f"DEBUG: showing advanced toolbar") + if self.verbose.get(): + print(f"DEBUG: showing advanced toolbar") self.frm_advanced.grid(row=0,column=0,columnspan=100) else: - print(f"DEBUG: hiding advanced toolbar") + if self.verbose.get(): + print(f"DEBUG: hiding advanced toolbar") self.frm_advanced.grid_forget() # update enrolled fingers icons try: @@ -143,9 +168,11 @@ class App(tk.Frame): if temp1: self.enrolled_fingers = temp1 else: - print(f"DEBUG (load_data_into_form): having to skip empty response from get_enrolled_fingers") + if self.verbose.get(): + print(f"DEBUG (load_data_into_form): having to skip empty response from get_enrolled_fingers") self.func_update_status(f"Unable to read enrolled fingers for user {used_user}.", reload = False) - print(f"DEBUG (load_data_into_form): got user {used_user} enrolled fingers {self.enrolled_fingers}") + if self.verbose.get(): + print(f"DEBUG (load_data_into_form): got user {used_user} enrolled fingers {self.enrolled_fingers}") for i in self.fingers: if str(i.cget('text')) in self.enrolled_fingers: i.config(image=self.img_enrolled) @@ -163,7 +190,8 @@ class App(tk.Frame): self.master.quit() def func_finger_button(self, finger): - print(f"DEBUG: func_finger_button finger {finger}, action {self.action.get()}") + if self.verbose.get(): + print(f"DEBUG: func_finger_button finger {finger}, action {self.action.get()}") action = self.action.get() used_user = self.get_used_user() # position in array is same as the value coming from radio button for actions. @@ -188,13 +216,15 @@ class App(tk.Frame): def func_update_status(self, msg, reload = True): msg = msg.strip() - print(f"DEBUG (func_update_status): msg {msg}",file=sys.stderr) + if self.verbose.get(): + print(f"DEBUG (func_update_status): msg {msg}",file=sys.stderr) self.statustext.set(msg) try: this_finger = [i for i in self.fingers if i.cget("text") == self.last_fingerbutton_used.get()][0] except Exception as e: this_finger = None - print(f"DEBUG (func_update_status): while evaluating last-used finger, got {e}") + if self.verbose.get(): + print(f"DEBUG (func_update_status): while evaluating last-used finger, got {e}") # flash these red failure_messages = [ "enroll-duplicate", -- cgit