This repository was archived by the owner on Dec 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflatpakmanager.py
More file actions
107 lines (87 loc) · 3.78 KB
/
Copy pathflatpakmanager.py
File metadata and controls
107 lines (87 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
### Program to manage uninstalled flatpaks ###
print("Import functions...")
import tkinter as gui
from tkinter import messagebox
import subprocess
import os
#get version
print("Get version of the application...")
run_path = os.path.abspath(os.path.dirname(__file__))
version = open(run_path + "/version.txt", "r")
version = version.readline()
print("flatpakmanager version", version)
print("Load definitons...")
#what happens after yes/no button
def runcommand(command):
print("Process confirmed.")
print(command)
successfulchecker = subprocess.run((command), shell=True)
if successfulchecker.returncode == 0:
messagebox.showinfo("Successful", "Everything cleaned.")
else:
messagebox.showerror("Error", "An error occurred")
def cancelcom():
print("Operation canceled.")
#button definitons
def uninstalled_config():
suremessage = ("Do you want to continue?", "", "All data of uninstalled flatpaks will be deleted!")
sure = messagebox.askyesno("Sure?", "\n".join(suremessage))
if sure == False:
cancelcom()
else:
runcommand('''flatpak remove --delete-data -y''')
def unused_depend():
suremessage = ("Do you want to continue?", "", "All unused dependencies will be uninstalled!")
sure = messagebox.askyesno("Sure?", "\n".join(suremessage))
if sure == False:
cancelcom()
else:
runcommand('''flatpak remove --unused -y''')
def remove_config_depend():
suremessage = ("Do you want to continue?", "", "All data of uninstalled flatpaks and all unused dependencies will be deleted!")
sure = messagebox.askyesno("Sure?", "\n".join(suremessage))
if sure == False:
cancelcom()
else:
runcommand('''flatpak remove --unused --delete-data -y''')
def remove_all():
suremessage = ("Do you want to continue?", "", "All flatpaks will be uninstalled. The config-data of them will not be touched.")
sure = messagebox.askyesno("Sure?", "\n".join(suremessage))
if sure == False:
cancelcom()
else:
runcommand('''flatpak remove --all -y''')
def aboutprogram():
showversion = ("Version: " + version)
showinfolines = ("Flatpak manager", "Developed by Palace4Software", "", showversion, "", "", "This software is distributed under the MIT License.")
messagebox.showinfo("About", "\n".join(showinfolines))
def exitprogram():
GUI.destroy()
#GUI
print("Setup graphical user interface...")
GUI = gui.Tk()
GUI.title("Flatpakmanager")
GUI.geometry("400x350")
GUI.resizable(width=False, height=False)
space1 = gui.Label(GUI).pack(expand=True, fill="x")
headline = gui.Label(text="Flatpak Manager for unused flatpaks", font=("Liberation Serif", 13))
headline.pack(expand=True, fill="x")
space2 = gui.Label(GUI).pack(expand=True, fill="both")
oldconfigbutton = gui.Button(GUI, text="Remove old config", bg="#008000", fg="#ffffff", command=uninstalled_config)
oldconfigbutton.pack() #button1
unuseddepenbutton = gui.Button(GUI, text="Remove unused flatpaks (e.g. runtimes)", bg="#005ce6", fg="#ffffff", command=unused_depend)
unuseddepenbutton.pack() #button2
configdependbutton = gui.Button(GUI, text="Remove the unused flatpaks and old config", bg="#3333cc", fg="#ffffff", command=remove_config_depend)
configdependbutton.pack() #button3
removeall = gui.Button(GUI, text="Remove all installed flatpaks (without config)", bg="#990000", fg="#ffffff", command=remove_all)
removeall.pack() #button4
space3 = gui.Label(GUI).pack(expand=True, fill="both")
aboutbutton = gui.Button(GUI, text="About", command=aboutprogram)
aboutbutton.pack(side="left") #about button
exitbutton = gui.Button(GUI, text="Exit", command=exitprogram)
exitbutton.pack(side="right") #exit button
space4 = gui.Label(GUI).pack(expand=True, fill="x")
print("Application ready.")
GUI.mainloop()
print("Exit program...")