-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-flatpak.sh
More file actions
executable file
·141 lines (122 loc) · 3.38 KB
/
Copy pathinstall-flatpak.sh
File metadata and controls
executable file
·141 lines (122 loc) · 3.38 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
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# --- External Functions ---
source lib/notify_lib.sh
# --- Constants ---
FLATHUB_APPS=(
studio.kx.carla
org.torproject.torbrowser-launcher
org.pipewire.Helvum
org.nickvision.tubeconverter
org.kde.kdenlive
org.gnome.gitlab.dqpb.GMetronome
org.gnome.SimpleScan
io.github.hrkfdn.ncspot
io.github.giantpinkrobots.flatsweep
fr.handbrake.ghb
com.spotify.Client
com.sigil_ebook.Sigil
com.polyphone_soundfonts.polyphone
com.github.tchx84.Flatseal
com.github.johnfactotum.Foliate
)
# --- Functions ---
install_flatpak() {
notify "Installing Flatpak"
sudo apt install flatpak -y
}
install_flatpak_plugin() {
local de=$(echo "$XDG_CURRENT_DESKTOP" | tr '[:upper:]' '[:lower:]')
notify "Detected desktop environment: $de"
case "$de" in
kde*)
notify "Installing KDE Flatpak plugin"
sudo apt install plasma-discover-backend-flatpak -y
;;
gnome*)
notify "Installing GNOME Flatpak plugin"
sudo apt install gnome-software-plugin-flatpak -y
;;
*)
notify "Other desktop detected, skipping DE-specific plugin"
;;
esac
}
add_flathub() {
notify "Add the Flathub repository"
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
}
check_flatpak_ready() {
if ! command -v flatpak &>/dev/null; then
notify "Flatpak is not installed. Operation aborted."
return 1
fi
if ! flatpak remotes | grep -q '^flathub'; then
notify "The Flathub repository does not exist. Operation aborted."
return 1
fi
return 0
}
install_flatpak_apps() {
if ! check_flatpak_ready; then
return 1
fi
notify "Installing Flatpak software from Flathub.org"
sudo flatpak install -y flathub "${FLATHUB_APPS[@]}"
}
remove_flatpak_apps() {
if ! check_flatpak_ready; then
return 1
fi
notify "Removing Flatpak applications installed by this script"
for app in "${FLATHUB_APPS[@]}"; do
if flatpak list --app | grep -q "^$app"; then
sudo flatpak uninstall -y "$app"
fi
done
read -p "Do you want to remove unused Flatpak runtimes and dependencies? [y/N]: " response
case "$response" in
[Yy]* )
notify "Removing unused Flatpak runtimes and dependencies"
sudo flatpak uninstall --unused -y
;;
* )
notify "Skipped removing unused Flatpak runtimes"
;;
esac
}
show_help() {
echo "Usage: $0 [OPTION]"
echo
echo "Options:"
echo " -i Install Flatpak, plugins, add Flathub, and install apps"
echo " -f Install only Flatpak applications from Flathub"
echo " -u Remove Flatpak applications installed by this script"
echo " -h Show this help message"
echo
}
main() {
case "$1" in
-i)
notify "Enable Flatpak & Flathub.org" "heading"
install_flatpak
install_flatpak_plugin
add_flathub
install_flatpak_apps
;;
-f)
install_flatpak_apps
;;
-u)
remove_flatpak_apps
;;
-h|"")
show_help
;;
*)
echo "Unknown option: $1"
show_help
;;
esac
}
# --- Execute ---
main "$1"