-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfk.py
More file actions
executable file
·129 lines (110 loc) · 3.85 KB
/
fk.py
File metadata and controls
executable file
·129 lines (110 loc) · 3.85 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/python
# SPDX-License-Identifier: GPL-2.0
# Copyright 2022-2023 - Fábio Rodrigues Ribeiro and contributors
import os
import subprocess as sp
import sys
class Fk:
def n_runtimes(self):
self.__n_runtimes = int(
sp.getoutput(
"flatpak list --app --columns=runtime | sort | uniq -c | sort -n | wc -l"
)
)
def n_apps(self):
self.__n_apps = int(
sp.getoutput(
"flatpak list --app --columns=name | sort | uniq -c | sort -n | wc -l"
)
)
def n_sdks(self):
self.__n_sdks = int(
sp.getoutput(
'flatpak list | sort | uniq -c | grep -E "[Ss][Dd][Kk]" | sort -n | wc -l'
)
)
def show_napps(self):
self.n_apps()
print("Numbers of applications: ", self.__n_apps)
def show_nruntimes(self):
self.n_runtimes()
print("Numbers of runtimes: ", self.__n_runtimes)
def show_nsdks(self):
self.n_sdks()
print("Numbers of Sdks: ", self.__n_sdks)
def list_runtime(self):
return sp.getoutput(
"flatpak list --app --columns=runtime | sort | uniq -c | sort -n"
)
def list_apps(self):
return sp.getoutput(
'flatpak list --app --columns=name | sort | uniq -c | sort -n | sed "s/1/-/"'
)
def list_sdk(self):
return sp.getoutput(
'flatpak list | sort | uniq -c | grep -E "[Ss][Dd][Kk]" | sort -n'
) # | sed \"s/\d\d?/-/\"")
def size_runtimes(self):
return sp.getoutput(
"cd /var/lib/flatpak/runtime; flatpak list --app --columns=runtime | sort | uniq | xargs du -sh --total"
)
def export(self):
os.system("flatpak list --app --columns=application > ~/flatpak-list-bk.txt")
def remove_fedora(self):
self.export()
self.exp_list = sp.getoutput("cat ~/flatpak-list-bk.txt | xargs")
c = "flatpak remove -y " + list
os.system(c)
def n_things(self):
self.n_runtimes()
self.n_apps()
self.n_sdks()
self.show_napps()
self.show_nruntimes()
self.show_nsdks()
def __init__(self):
match sys.argv[1]:
case "exp":
self.export()
case "remove-fedora":
self.remove_fedora()
case "repair":
os.system("flatpak repair --user && sudo flatpak repair")
case "cleanall":
os.system("flatpak remove --unused --delete-data")
case "up":
os.system("flatpak update")
case "fup":
os.system("flatpak update --no-static-deltas")
case "n-things":
self.n_things()
case "list-runtimes":
self.show_nruntimes()
print("Runtimes installed:\n")
print(self.size_runtimes())
case "list-apps":
self.show_napps()
print("Apps installed:\n")
print(self.list_apps())
case "b":
c = (
"flatpak run org.flatpak.Builder --install --user --force-clean build-dir "
+ sys.argv[2]
)
os.system(c)
case "in":
os.system("standalone-fk-gum.lua")
case "pg":
c = "flatpak remove --delete-data " + sys.argv[2]
os.system(c)
case "convert-flathub":
self.remove_fedora()
c = "flatpak install flathub --system -y " + self.exp_list
os.system(c)
case "info":
c = "flatpak info " + self.getfqdn(sys.argv[2])
os.system(c)
case "run":
c = "flatpak run " + self.getfqdn(sys.argv[2])
os.system(c)
f = Fk()