|
@@ -1,141 +1,145 @@
|
|
|
-#!/usr/bin/env python3
|
|
|
-
|
|
|
-# uruk cleaner
|
|
|
-# to clean your system
|
|
|
-
|
|
|
-# Copyright (c) 2016, 2022 ali abdul ghani <blade.vp2020@gmail.com>
|
|
|
-# This Program is free software: you can redistribute it and/or modify
|
|
|
-# it under the terms of the GNU General Public License as published by
|
|
|
-# the Free Software Foundation, either version 3 of the License, or
|
|
|
-# (at your option) any later version.
|
|
|
-# This Program is distributed in the hope that it will be useful,
|
|
|
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-# GNU General Public License for more details.
|
|
|
- # You should have received a copy of the GNU General Public License
|
|
|
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
-
|
|
|
-from tkinter import *
|
|
|
-import tkinter as tk
|
|
|
-from tkinter import messagebox
|
|
|
-from tkinter import ttk
|
|
|
-import os
|
|
|
-import dbus
|
|
|
-from _dbus_bindings import BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH
|
|
|
-# dbus vars
|
|
|
-
|
|
|
-timeout = 60
|
|
|
-flags = 0
|
|
|
-bus_name = "org.dbus.ucleaner"
|
|
|
-opath = "/org/ucleaner"
|
|
|
-#get the system bus
|
|
|
-bus = dbus.SystemBus()
|
|
|
-bus.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE, 'StartServiceByName', 'su', (bus_name, flags), timeout=timeout)
|
|
|
-#get the object
|
|
|
-the_object = bus.get_object(bus_name, opath)
|
|
|
-#get the interface
|
|
|
-the_interface = dbus.Interface(the_object, "org.ucleaner")
|
|
|
-
|
|
|
-gui=tk.Tk()
|
|
|
-gui.configure(background='#ffffff')
|
|
|
-gui.title("Uruk System Cleaner")
|
|
|
-gui.iconphoto(False, tk.PhotoImage(file='ucleaner.png'))
|
|
|
-gui.tk.call('wm', 'iconphoto', gui._w, tk.PhotoImage(file='ucleaner.png'))
|
|
|
-style = ttk.Style(gui)
|
|
|
-style.theme_use('clam')
|
|
|
-var1 = IntVar()
|
|
|
-var2 = IntVar()
|
|
|
-var3 = IntVar()
|
|
|
-var4 = IntVar()
|
|
|
-var5 = IntVar()
|
|
|
-gui.geometry("830x650")
|
|
|
-gui.resizable(False,False)
|
|
|
-
|
|
|
-def apply_conf():
|
|
|
- values = int(var1.get()) + int(var2.get()) + int(var3.get()) + int(var4.get()) + int(var5.get())
|
|
|
- if (values == 0):
|
|
|
- messageBox("error")
|
|
|
- else:
|
|
|
- if int(var1.get()) == 1:
|
|
|
- the_interface.Clene_logs()
|
|
|
-
|
|
|
- messageBox("done")
|
|
|
- if int(var2.get()) == 1:
|
|
|
- the_interface.Clene_cach()
|
|
|
-
|
|
|
- messageBox("done")
|
|
|
- if int(var3.get()) == 1:
|
|
|
- the_interface.Autoremove_pkgs()
|
|
|
- messageBox("done")
|
|
|
- if int(var4.get()) == 1:
|
|
|
- os.system("rm -rf ~/.cache/thumbnails/*")
|
|
|
- messageBox("done")
|
|
|
- if int(var5.get()) == 1:
|
|
|
- os.system("rm ~/.mozilla/firefox/*.default*/*.sqlite ~/.mozilla/firefox/*default*/sessionstore.js")
|
|
|
- os.system("rm -r ~/.cache/mozilla/firefox/*.default*/*")
|
|
|
- messageBox("done")
|
|
|
-def messageBox(text):
|
|
|
- msgs = Toplevel(gui)
|
|
|
- msgs.title("Uruk System Cleaner")
|
|
|
- msgs.configure(bg='#ffffff')
|
|
|
- frame = Frame(msgs,bg='#ffffff')
|
|
|
- frame.grid()
|
|
|
- msgbody1 = Label(frame, text="Uruk System Cleaner \n", fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
- msgbody1.grid(row=1, column=1,padx=10, pady=10, sticky=N)
|
|
|
- if text=="error":
|
|
|
- msgbody2 = Label(frame, text="You most choose one option at less", fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
- msgbody2.grid(row=2, column=1,padx=10, pady=10, sticky=N)
|
|
|
- elif text == "about":
|
|
|
- msgbody2 = Label(frame, text="Free and Open Source System Cleaner \nto clean and remove unnecessary files on\n your system \n \nby ali miracle <alimiracle@riseup.net>\n 2022", fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
- msgbody2.grid(row=2, column=1,padx=10, pady=10, sticky=N)
|
|
|
- # elif text == "complete1":
|
|
|
- # msgbody2 = Label(frame, text="All cash files was cleaning.", fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
- # msgbody2.grid(row=2, column=1,padx=10, pady=10, sticky=N)
|
|
|
- # elif text == "complete2":
|
|
|
- # msgbody2 = Label(frame, text="All unused packages was removed.", fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
- # msgbody2.grid(row=2, column=1,padx=10, pady=10, sticky=N)
|
|
|
- # elif text == "complete3":
|
|
|
- # msgbody2 = Label(frame, text="All unused packages was removed.", fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
- # msgbody2.grid(row=2, column=1,padx=10, pady=10, sticky=N)
|
|
|
- elif text == "done":
|
|
|
- msgbody2 = Label(frame, text="Cleaning Complete!", fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
- msgbody2.grid(row=2, column=1,padx=10, pady=10, sticky=N)
|
|
|
- okbttn = Button(frame, text="OK",height=0, width=5, fg='white', bg='#ff7675', font=('noto', 12, "bold"), borderwidth=0, command=msgs.destroy)
|
|
|
- okbttn.grid(row=4, column=1,pady=10)
|
|
|
-
|
|
|
-lableapp = Label(gui, text="Uruk System Cleaner", fg = "#70D2F9", bg='#ffffff',font=("noto", 26, "bold")).pack(pady=60, padx=10)
|
|
|
-
|
|
|
-frame = LabelFrame(gui, text="Choose what to clean:",borderwidth=0,font=('noto', 15, "bold"), fg = "#FFB27A", bg='#ffffff', padx=20, pady=20)
|
|
|
-frame.pack(pady=10, padx=10)
|
|
|
-
|
|
|
-B1 = Checkbutton(frame, text="Cleanning Logss",variable = var1, onvalue=1, offvalue=0, borderwidth=0,font=('noto', 12, "bold"), fg = "#6FD3F7", bg='#ffffff', width=25,height=2, anchor="w",highlightthickness=0,bd=0).grid(row=1, column=0, padx=10, pady=15)
|
|
|
-
|
|
|
-B2 = Checkbutton(frame, text = "Cleanning apt Cash", variable = var2, onvalue=1, offvalue=0,font=('noto', 12, "bold"), fg = "#6FD3F7", bg='#ffffff', width=25,height=2, anchor="w",highlightthickness=0,bd=0).grid(row=1, column=1, padx=10, pady=15)
|
|
|
-
|
|
|
-B3 = Checkbutton(frame, text = "Remove unused packages",variable = var3, onvalue=1, offvalue=0, borderwidth=0,font=('noto', 12, "bold"), fg = "#6FD3F7", bg='#ffffff', width=25,height=2, anchor="w",highlightthickness=0,bd=0).grid(row=2, column=0, padx=10, pady=15)
|
|
|
-
|
|
|
-B4 = Checkbutton(frame, text = "Remove thumbinals",variable = var4, onvalue=1, offvalue=0, borderwidth=0,font=('noto', 12, "bold"), fg = "#6FD3F7", bg='#ffffff', width=25,height=2, anchor="w",highlightthickness=0,bd=0).grid(row=2, column=1, padx=10, pady=15)
|
|
|
-
|
|
|
-B5 = Checkbutton(frame, text = "Remove firefox cash",variable = var5, onvalue=1, offvalue=0, borderwidth=0,font=('noto', 12, "bold"), fg = "#6FD3F7", bg='#ffffff', width=25,height=2, anchor="w",highlightthickness=0,bd=0).grid(row=3, column=0, padx=10, pady=15)
|
|
|
-
|
|
|
-
|
|
|
-buttonDll=Button(gui, height=2, width=16, text="Clean", fg='white', bg='#5599ff', font=('noto', 13, "bold"), borderwidth=0, command=lambda: apply_conf())
|
|
|
-buttonDll.pack(pady=3, padx=10)
|
|
|
-
|
|
|
-buttonEx=Button(gui, height=2, width=8, text="Exit", fg='white', bg='#F1BB8F', font=('noto', 13, "bold"), borderwidth=0, command=gui.destroy)
|
|
|
-buttonEx.pack(pady=13, padx=80, side=tk.LEFT)
|
|
|
-
|
|
|
-buttonEx=Button(gui, height=2, width=8, text="About", fg='white', bg='#ff7675', font=('noto', 12, "bold"), borderwidth=0, command=lambda: messageBox("about"))
|
|
|
-buttonEx.pack(pady=10, padx=10, side=tk.RIGHT)
|
|
|
-
|
|
|
-# menubar = Menu(gui)
|
|
|
-# filemenu = Menu(menubar, tearoff=0)
|
|
|
-# filemenu.add_command(label="Exit", command=gui.destroy)
|
|
|
-# menubar.add_cascade(label="File", menu=filemenu)
|
|
|
-
|
|
|
-# helpmenu = Menu(menubar, tearoff=0)
|
|
|
-# helpmenu.add_command(label="About", command=lambda: messageBox("about"))
|
|
|
-# menubar.add_cascade(label="Help", menu=helpmenu)
|
|
|
-# gui.config(menu=menubar)
|
|
|
-
|
|
|
-gui.mainloop()
|
|
|
+#!/usr/bin/env python3
|
|
|
+
|
|
|
+# uruk cleaner
|
|
|
+# to clean your system
|
|
|
+
|
|
|
+# Copyright (c) 2016, 2022 ali abdul ghani <blade.vp2020@gmail.com>
|
|
|
+# This Program is free software: you can redistribute it and/or modify
|
|
|
+# it under the terms of the GNU General Public License as published by
|
|
|
+# the Free Software Foundation, either version 3 of the License, or
|
|
|
+# (at your option) any later version.
|
|
|
+# This Program is distributed in the hope that it will be useful,
|
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+# GNU General Public License for more details.
|
|
|
+ # You should have received a copy of the GNU General Public License
|
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
+
|
|
|
+from ast import Lambda
|
|
|
+from tkinter import *
|
|
|
+import tkinter as tk
|
|
|
+from tkinter import messagebox
|
|
|
+from tkinter import ttk
|
|
|
+import os
|
|
|
+import tkinter
|
|
|
+from bleach import clean
|
|
|
+import dbus
|
|
|
+from _dbus_bindings import BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH
|
|
|
+class Gui:
|
|
|
+ def __init__(self):
|
|
|
+ self.__init_dbus()
|
|
|
+ self.__create_gui()
|
|
|
+
|
|
|
+ def __create_check_box(self,name:str,var:IntVar)->Checkbutton:
|
|
|
+ return Checkbutton(self.frame, text=name,variable = var, onvalue=1, offvalue=0, borderwidth=0,font=('noto', 12, "bold"), fg = "#6FD3F7", bg='#ffffff', width=25,height=2, anchor="w",highlightthickness=0,bd=0)
|
|
|
+
|
|
|
+ def __create_checkboxes(self)->None:
|
|
|
+ self.var_clean_log = IntVar()
|
|
|
+ self.btn_log_clean=self.__create_check_box("Clean logs",self.var_clean_log)
|
|
|
+ self.btn_log_clean.grid(row=1, column=0, padx=10, pady=15)
|
|
|
+
|
|
|
+ self.var_apt_clean = IntVar()
|
|
|
+ self.btn_apt_clean=self.__create_check_box("Clean Apt caches",self.var_apt_clean)
|
|
|
+ self.btn_apt_clean.grid(row=1, column=1, padx=10, pady=15)
|
|
|
+
|
|
|
+ self.var_remove_unused_packages = IntVar()
|
|
|
+ self.btn_remove_unused_packages=self.__create_check_box("Remove unused packages",self.var_remove_unused_packages)
|
|
|
+ self.btn_remove_unused_packages.grid(row=2, column=0, padx=10, pady=15)
|
|
|
+
|
|
|
+ self.var_remove_thumbnails = IntVar()
|
|
|
+ self.btn_remove_thumbnails=self.__create_check_box("Remove thumbnails",self.var_remove_thumbnails)
|
|
|
+ self.btn_remove_thumbnails.grid(row=2, column=1, padx=10, pady=15)
|
|
|
+
|
|
|
+ self.var_remove_firefox_cache = IntVar()
|
|
|
+ self.btn_remove_firefox_cache=self.__create_check_box("Remove firefox cache",self.var_remove_firefox_cache)
|
|
|
+ self.btn_remove_firefox_cache.grid(row=3, column=0, padx=10, pady=15)
|
|
|
+ def __create_button(self,name:str,command:Lambda,bg_color:str)->Button:
|
|
|
+ return Button(self.tk_top_widget, height=2, width=8, text=name, fg='white', bg=bg_color, font=('noto', 12, "bold"), borderwidth=0, command=command)
|
|
|
+
|
|
|
+ def __create_buttons(self)->None:
|
|
|
+ self.clean_btn=self.__create_button("Clean",lambda: self.__clean(),'#5599ff')
|
|
|
+ self.clean_btn.pack(pady=3, padx=10)
|
|
|
+ self.exit_btn=self.__create_button("Exit",lambda:self.tk_top_widget.destroy(),'#F1BB8F')
|
|
|
+ self.exit_btn.pack(pady=13, padx=80, side=tk.LEFT)
|
|
|
+ self.about_btn=self.__create_button("About",lambda: self.__about_message_box(),'#ff7675')
|
|
|
+ self.about_btn.pack(pady=10, padx=10, side=tk.RIGHT)
|
|
|
+
|
|
|
+ def __create_widgets(self):
|
|
|
+ app_label = Label(self.tk_top_widget, text="Uruk System Cleaner", fg = "#70D2F9", bg='#ffffff',font=("noto", 26, "bold")).pack(pady=60, padx=10)
|
|
|
+ self.frame = LabelFrame(self.tk_top_widget, text="Choose what to clean:",borderwidth=0,font=('noto', 15, "bold"), fg = "#FFB27A", bg='#ffffff', padx=20, pady=20)
|
|
|
+ self.frame.pack(pady=10, padx=10)
|
|
|
+ self.__create_checkboxes()
|
|
|
+ self.__create_buttons()
|
|
|
+
|
|
|
+ def __set_window_attributes(self):
|
|
|
+ self.tk_top_widget.configure(background='#ffffff')
|
|
|
+ self.tk_top_widget.geometry("830x650")
|
|
|
+ self.tk_top_widget.title("Uruk System Cleaner")
|
|
|
+ self.tk_top_widget.iconphoto(False, tk.PhotoImage(file='ucleaner.png'))
|
|
|
+ self.tk_top_widget.tk.call('wm', 'iconphoto', self.tk_top_widget._w, tk.PhotoImage(file='ucleaner.png'))
|
|
|
+ self.style = ttk.Style(self.tk_top_widget)
|
|
|
+ self.style.theme_use('clam')
|
|
|
+ self.tk_top_widget.resizable(False,False)
|
|
|
+ pass
|
|
|
+ def __about_message_box(self)->None:
|
|
|
+ self.__message_box("Free and Open Source System Cleaner \nto clean and remove unnecessary files on\n your system \n \nby ali miracle <alimiracle@riseup.net>\n 2022")
|
|
|
+ def __done_message_box(self)->None:
|
|
|
+ self.__message_box("Cleaning Complete!")
|
|
|
+ def __error_message_box(self)->None:
|
|
|
+ self.__message_box("You most choose one option at less")
|
|
|
+ def __message_box(self,body_content):
|
|
|
+ message_box = Toplevel(self.tk_top_widget)
|
|
|
+ message_box.title("Uruk System Cleaner")
|
|
|
+ message_box.configure(bg='#ffffff')
|
|
|
+ frame = Frame(message_box,bg='#ffffff')
|
|
|
+ frame.grid()
|
|
|
+ title_label = Label(frame, text="Uruk System Cleaner \n", fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
+ title_label.grid(row=1, column=1,padx=10, pady=10, sticky=N)
|
|
|
+ message_body = Label(frame, text=body_content, fg = "#006680", bg='#ffffff',font=("noto", 11, "bold"))
|
|
|
+ message_body.grid(row=2, column=1,padx=10, pady=10, sticky=N)
|
|
|
+ ok_btn = Button(frame, text="OK",height=0, width=5, fg='white', bg='#ff7675', font=('noto', 12, "bold"), borderwidth=0, command=message_box.destroy)
|
|
|
+ ok_btn.grid(row=4, column=1,pady=10)
|
|
|
+ def __var_to_int(self,var)->int:
|
|
|
+ return int(var.get())
|
|
|
+
|
|
|
+ def __is_selected(self,var)->bool:
|
|
|
+ return self.__var_to_int(var)==1
|
|
|
+
|
|
|
+ def __selected_option_count(self)->int:
|
|
|
+ return self.__var_to_int(self.var_apt_clean) + self.__var_to_int(self.var_clean_log) + self.__var_to_int(self.var_remove_firefox_cache) + self.__var_to_int(self.var_remove_thumbnails) + self.__var_to_int(self.var_remove_unused_packages)
|
|
|
+
|
|
|
+ def __clean(self):
|
|
|
+ if self.__selected_option_count()<1:
|
|
|
+ self.__error_message_box()
|
|
|
+ return
|
|
|
+ if self.__is_selected(self.var_apt_clean):
|
|
|
+ self.dbus_interface.clean_apt_cache()
|
|
|
+ if self.__is_selected(self.var_clean_log):
|
|
|
+ self.dbus_interface.clean_logs()
|
|
|
+ if self.__is_selected(self.var_remove_firefox_cache):
|
|
|
+ os.system("rm ~/.mozilla/firefox/*.default*/*.sqlite ~/.mozilla/firefox/*default*/sessionstore.js")
|
|
|
+ os.system("rm -r ~/.cache/mozilla/firefox/*.default*/*")
|
|
|
+ self.__done_message_box()
|
|
|
+ if self.__is_selected(self.var_remove_thumbnails):
|
|
|
+ os.system("rm -rf ~/.cache/thumbnails/*")
|
|
|
+ self.__done_message_box()
|
|
|
+ if self.__is_selected(self.var_remove_unused_packages):
|
|
|
+ self.dbus_interface.remove_unused_packages()
|
|
|
+ def __init_dbus(self):
|
|
|
+ timeout = 60
|
|
|
+ flags = 0
|
|
|
+ bus_name = "org.dbus.ucleaner"
|
|
|
+ opath = "/org/ucleaner"
|
|
|
+ #get the system bus
|
|
|
+ bus = dbus.SystemBus()
|
|
|
+ bus.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_DAEMON_IFACE,'StartServiceByName', 'su', (bus_name, flags), timeout=timeout)
|
|
|
+ #get the object
|
|
|
+ dbus_object = bus.get_object(bus_name, opath)
|
|
|
+ #get the interface
|
|
|
+ self.dbus_interface = dbus.Interface(dbus_object, "org.ucleaner")
|
|
|
+ def __create_gui(self):
|
|
|
+ self.tk_top_widget = tkinter.Tk()
|
|
|
+ self.__set_window_attributes()
|
|
|
+ self.__create_widgets()
|
|
|
+ self.tk_top_widget.mainloop()
|
|
|
+Gui()
|