|
@@ -1,141 +1,120 @@
|
|
|
-#!/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 gi
|
|
|
+gi.require_version("Gtk", "3.0")
|
|
|
+from gi.repository import Gtk
|
|
|
+gi.require_version('Gdk', '3.0')
|
|
|
+from gi.repository import Gdk
|
|
|
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()
|
|
|
+import os
|
|
|
+class MessageBox:
|
|
|
+ def __init__(self,message_title,message_content):
|
|
|
+ self.__load_css()
|
|
|
+ self.__load_glade("messagebox.glade")
|
|
|
+ self.__extract_widget()
|
|
|
+ self.set_content(message_content)
|
|
|
+ self.set_title(message_title)
|
|
|
+ def set_title(self,title):
|
|
|
+ self.title_label.set_text(title)
|
|
|
+ def set_content(self,content):
|
|
|
+ self.content_label.set_text(content)
|
|
|
+ pass
|
|
|
+ def __load_glade(self,glade_file):
|
|
|
+ self.builder = Gtk.Builder()
|
|
|
+ self.builder.add_from_file(glade_file)
|
|
|
+ self.builder.connect_signals(self)
|
|
|
+ def __extract_widget(self):
|
|
|
+ self.window = self.builder.get_object("TopWindow")
|
|
|
+ self.title_label = self.builder.get_object("TitleLabel")
|
|
|
+ self.content_label = self.builder.get_object("MessageLabel")
|
|
|
+ def show(self):
|
|
|
+ self.window.show()
|
|
|
+ def __load_css(self):
|
|
|
+ screen = Gdk.Screen.get_default()
|
|
|
+ provider = Gtk.CssProvider()
|
|
|
+ provider.load_from_path("messagebox.css")
|
|
|
+ Gtk.StyleContext.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
|
|
+ def ok_btn_click(self, *args):
|
|
|
+ self.window.close()
|
|
|
+class Cleaner:
|
|
|
+ def __init__(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 clean_apt_cache(self):
|
|
|
+ self.dbus_interface.clean_apt_cache()
|
|
|
+ def clean_logs(self):
|
|
|
+ self.dbus_interface.clean_logs()
|
|
|
+ def remove_unused_pkgs(self):
|
|
|
+ self.dbus_interface.auto_remove_pkgs()
|
|
|
+ def remove_thumbnails(self):
|
|
|
+ os.system("rm -rf ~/.cache/thumbnails/*")
|
|
|
+ def clean_firefox_cache(self):
|
|
|
+ os.system("rm ~/.mozilla/firefox/*.default*/*.sqlite ~/.mozilla/firefox/*default*/sessionstore.js")
|
|
|
+ os.system("rm -r ~/.cache/mozilla/firefox/*.default*/*")
|
|
|
+
|
|
|
+class GUI:
|
|
|
+ IsWindowMaximized=False
|
|
|
+ def __init__(self):
|
|
|
+ self.cleaner=Cleaner()
|
|
|
+ self.__load_glade("cleaner.glade")
|
|
|
+ self.__load_css()
|
|
|
+ self.__extract_widget()
|
|
|
+ def __load_glade(self,glade_file):
|
|
|
+ self.builder = Gtk.Builder()
|
|
|
+ self.builder.add_from_file(glade_file)
|
|
|
+ self.builder.connect_signals(self)
|
|
|
+ def __extract_widget(self):
|
|
|
+ self.window = self.builder.get_object("TopWindow")
|
|
|
+ def show(self):
|
|
|
+ self.window.show()
|
|
|
+ def __load_css(self):
|
|
|
+ screen = Gdk.Screen.get_default()
|
|
|
+ provider = Gtk.CssProvider()
|
|
|
+ provider.load_from_path("cleaner.css")
|
|
|
+ Gtk.StyleContext.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
|
|
+ def maximize(self, button):
|
|
|
+ if IsWindowMaximized:
|
|
|
+ Gtk.Window.normlize(self.window)
|
|
|
+ IsWindowMaximized=False
|
|
|
+ return
|
|
|
+ Gtk.Window.maximize(self.window)
|
|
|
+ def minimize(self, button):
|
|
|
+ Gtk.Window.minimize(self.window)
|
|
|
+ def close(self, *args):
|
|
|
+ Gtk.main_quit()
|
|
|
+ exit(0)
|
|
|
+ def Clean(self, button):
|
|
|
+ status=False
|
|
|
+ if self.builder.get_object("AptCacheChk").get_active():
|
|
|
+ status=True
|
|
|
+ self.cleaner.clean_apt_cache()
|
|
|
+ if self.builder.get_object("LogsChk").get_active():
|
|
|
+ status=True
|
|
|
+ self.cleaner.clean_logs()
|
|
|
+ if self.builder.get_object("UnUsedPkgsChk").get_active():
|
|
|
+ status=True
|
|
|
+ self.cleaner.remove_unused_pkgs()
|
|
|
+ if self.builder.get_object("ThumbnailsChk").get_active():
|
|
|
+ status=True
|
|
|
+ self.cleaner.remove_thumbnails()
|
|
|
+ if self.builder.get_object("FireFoxChk").get_active():
|
|
|
+ status=True
|
|
|
+ self.cleaner.clean_firefox_cache()
|
|
|
+ if status:
|
|
|
+ MessageBox("Result","Cleaning Completed").show()
|
|
|
+ return
|
|
|
+ MessageBox("Error","Select At Least one Task").show()
|
|
|
+if __name__ == "__main__":
|
|
|
+ main = GUI()
|
|
|
+ main.show()
|
|
|
+ Gtk.main()
|