From c5f3f18838eb699a5f0436e4779fc2fbf71f1454 Mon Sep 17 00:00:00 2001 From: debianpepper Date: Fri, 31 May 2024 15:34:10 +0900 Subject: [PATCH] Updated took out older xDaily.py exmaple Signed-off-by: debianpepper --- iso_configs/pmostools/peptools/xDaily.py | 136 ----------------------- 1 file changed, 136 deletions(-) delete mode 100644 iso_configs/pmostools/peptools/xDaily.py diff --git a/iso_configs/pmostools/peptools/xDaily.py b/iso_configs/pmostools/peptools/xDaily.py deleted file mode 100644 index 152c1426..00000000 --- a/iso_configs/pmostools/peptools/xDaily.py +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env python3 - -import subprocess -import os -import tkinter as tk -from tkinter import ttk -from tkinter.scrolledtext import ScrolledText -from ttkbootstrap import Style - -PROGNAME = "xDaily" - -class XDailyApp: - def __init__(self, root): - self.root = root - self.root.title("xDaily - Automated System Maintenance") - self.root.geometry("800x600") - self.root.grid_rowconfigure(0, weight=1) - self.root.grid_columnconfigure(0, weight=1) - - self.style = Style(theme="peppermint") - self.main_frame = ttk.Frame(self.root) - self.main_frame.grid(row=0, column=0, sticky="nsew", padx=10, pady=10) - - self.output_text = ScrolledText(self.main_frame, wrap=tk.WORD) - self.output_text.grid(row=0, column=1, sticky="nsew", padx=10, pady=10) - - self.execute_button = ttk.Button(self.main_frame, text="Execute All Tasks", command=self.execute_all_tasks, style="Danger.TButton") - self.execute_button.grid(row=1, column=1, pady=5, padx=(0, 10), sticky="e") - - self.task_buttons_frame = ttk.Frame(self.main_frame, borderwidth=2, relief="solid") - self.task_buttons_frame.grid(row=0, column=0, rowspan=2, sticky="nsw", padx=10, pady=5) - - self.create_task_buttons() - - self.main_frame.grid_rowconfigure(0, weight=1) - self.main_frame.grid_columnconfigure(1, weight=1) - self.output_text.grid_rowconfigure(0, weight=1) - self.output_text.grid_columnconfigure(0, weight=1) - - self.show_welcome_message() - - def create_task_buttons(self): - tasks = [ - "Check apt repositories for Updates", - "See upgradable packages", - "Install available updated packages", - "Remove unnecessary packages from APT cache", - "Remove unavailable entries from APT cache", - "Remove old dependencies not required by the system", - "Clear browser thumbnail caches", - "Clear the \"Recently Used\" list in FireFox", - "Reconfirm Peppermint Branding in os-release", - "For SSDs: trim eligible ext2/3/4 filesystems", - "Caching icons at /usr/share/icons/" - ] - - self.task_buttons = [] - - for task in tasks: - button = ttk.Button(self.task_buttons_frame, text=task, command=lambda t=task: self.execute_task(t), style="Danger.TButton", compound=tk.RIGHT) - button.pack(fill="x", padx=5, pady=5) - self.task_buttons.append(button) - - def execute_all_tasks(self): - self.clear_output() - - for button in self.task_buttons: - button.state(["disabled"]) - - for task_button in self.task_buttons: - task = task_button.cget("text") - result = self.execute_task(task) - if result is not None: - self.show_output(result) - - for button in self.task_buttons: - button.state(["!disabled"]) - - def execute_task(self, task): - self.clear_output() - self.show_output(f"Running task: {task}\n") - - try: - if task == "Check apt repositories for Updates": - output = subprocess.check_output(["apt", "update"], text=True) - elif task == "See upgradable packages": - output = subprocess.check_output(["apt", "list", "--upgradable"], text=True) - elif task == "Install available updated packages": - output = subprocess.check_output(["apt", "upgrade", "-y"], text=True) - elif task == "Remove unnecessary packages from APT cache": - output = subprocess.check_output(["apt", "clean"], text=True) - elif task == "Remove unavailable entries from APT cache": - output = subprocess.check_output(["apt", "autoclean"], text=True) - elif task == "Remove old dependencies not required by the system": - output = subprocess.check_output(["apt", "autoremove", "-y"], text=True) - elif task == "Clear browser thumbnail caches": - output = subprocess.check_output(["rm", "-v", "/home/" + os.getlogin() + "/.thumbnails/*/*.png"], text=True, stderr=subprocess.DEVNULL) - output += subprocess.check_output(["rm", "-v", "/home/" + os.getlogin() + "/.cache/thumbnails/*/*.png"], text=True, stderr=subprocess.DEVNULL) - elif task == "Clear the \"Recently Used\" list in FireFox": - output = subprocess.check_output(["dd", "bs=1", "count=1", "status=none", "if=/dev/null", "of=/home/" + os.getlogin() + "/.local/share/recently-used.xbel"], text=True, stderr=subprocess.DEVNULL) - output += subprocess.check_output(["chown", os.getlogin(), "/home/" + os.getlogin() + "/.local/share/recently-used.xbel"], text=True) - elif task == "Reconfirm Peppermint Branding in os-release": - output = subprocess.check_output(["diff", "-q", "/opt/pepconf/os-release", "/usr/lib/os-release"], text=True, stderr=subprocess.DEVNULL) - output += subprocess.check_output(["diff", "-q", "/opt/pepconf/os-release", "/etc/os-release"], text=True, stderr=subprocess.DEVNULL) - elif task == "For SSDs: trim eligible ext2/3/4 filesystems": - mounts = subprocess.check_output(["grep", "-E", "(ext2|ext3|ext4)", "/etc/mtab"], text=True) - mounts_list = mounts.splitlines() - for mount in mounts_list: - mount_path = mount.split()[1] - output = subprocess.check_output(["sudo", "fstrim", mount_path], text=True) - elif task == "Caching icons at /usr/share/icons/": - output = subprocess.check_output(["sudo", "update-icon-caches", "/usr/share/icons/*"], text=True) - self.show_output(output) - return output - except subprocess.CalledProcessError as e: - self.show_output(f"Error executing task: {e.output}\n") - - def clear_output(self): - self.output_text.delete(1.0, tk.END) - - def show_output(self, text): - self.output_text.insert(tk.END, text) - self.output_text.see(tk.END) - - def show_welcome_message(self): - welcome_message = "Welcome to xDaily!\n\nThis application allows you to perform automated system maintenance tasks.\nYou can either execute all tasks at once or choose individual tasks to execute.\n\nSelect individual tasks from the list below or click 'Execute All Tasks' to start.\n" - self.show_output(welcome_message) - -def main(): - root = tk.Tk() - app = XDailyApp(root) - app.root.configure(bg="#c0c0c0") # Set background color to grey - root.mainloop() - -if __name__ == "__main__": - main()