Compare commits

...
1 Commits
Author SHA1 Message Date
Casey Connolly be4ef96662 main/postmarketos-base-ui-gnome: add gnome-software stub for Duranium
Phosh allows uninstalling apps by tap-holding the icon, in the
background this spawns gnome-software with --uninstall ID.

Since system apps can't be uninstalled, but the user may still want to
hide them, introduce a stub which installs a copy of the apps desktop
file into the users local applications directory and marks it as Hidden,
effectively disabling the app.

Use Zenity to offer a prompt and explain how apps can be re-enabled
later (unfortunately there's no nice UI for this).

Additionally let's just plumb this in to flatpak and invoke flatpak
uninstall in the background, this provides a nicer interface than simply
doing nothing.
2026-06-17 17:49:30 +02:00
3 changed files with 111 additions and 2 deletions

No files matched your search

+12 -2
View File
@@ -3,7 +3,7 @@
maintainer="Stefan Hansson <newbyte@postmarketos.org>"
pkgname=postmarketos-base-ui-gnome
pkgver=11
pkgrel=2
pkgrel=3
pkgdesc="Meta package for shared configuration for GNOME-based UIs"
url="https://postmarketos.org"
arch="noarch"
@@ -33,6 +33,8 @@ source="
00_postmarketos-base-ui-gnome.gschema.override
10_postmarketos-green-accent.gschema.override
50-duranium.conf
duranium-gnome-software-stub.sh
duranium-gnome-software-stub.desktop
"
options="!check"
subpackages="
@@ -98,10 +100,16 @@ openrc() {
duranium() {
pkgdesc="$pkgdesc (Duranium)"
install_if="$pkgname=$pkgver-r$pkgrel postmarketos-duranium"
depends="gnome-app-provider-bazaar"
# Bash and zenity for the gnome-software stub
depends="gnome-app-provider-bazaar bash zenity"
install -Dm644 "$srcdir"/50-duranium.conf \
-t "$subpkgdir"/usr/lib/kernel-cmdline.d
install -Dm755 "$srcdir"/duranium-gnome-software-stub.sh \
"$subpkgdir"/usr/bin/gnome-software
install -Dm644 "$srcdir"/duranium-gnome-software-stub.desktop \
"$subpkgdir"/usr/share/applications/org.gnome.Software.desktop
}
gnome_software() {
@@ -126,4 +134,6 @@ sha512sums="
39b5bb5e669756e2a308ab61b7901e76a9eff9e37c82d50bd9ff77800e72c19b580256f617a2ad0949c1746ab4e163e5ce009c134ab77f8a32f758b1b963862e 00_postmarketos-base-ui-gnome.gschema.override
c255b0914043f09ef5cc56d50c26e9c8885af128abc3ed5494606bd304eefdeb761ed3bc2d5f86f7c3bfb16f7fc21ca1a6d954c8d21e73e7a5e7612a84a78b7c 10_postmarketos-green-accent.gschema.override
d48775a344d221309fc4f6ab96ec9cd5e871290f940deb967369b8c65dcef570cc44f7c4e7980153390f9da2518fdcc4c0e0687e9e32a984f712bdb62ab65e3d 50-duranium.conf
aeb9d58b4c944879dea6852c2d03a53d8fb83351b3181a7249681c4aa5508f9f7874459ae33c041320f14e16d9c05fe41803c5b718749bb233e30f5fc908fbab duranium-gnome-software-stub.sh
9c7a7f89bcc042e7f8aaab4b2572c371c4b729666d939280ce7db705d1ea300ebfa9fea9074af0c915a3e88d338969b3b133eca50f63b2f64a29cd1d8cf07ea9 duranium-gnome-software-stub.desktop
"
@@ -0,0 +1,14 @@
# Duranium: this is a stub so that the Phosh
# app "uninstall" button works. We don't actually
# ship GNOME Software and this desktop entry
# has NoDisplay=true
[Desktop Entry]
Name=Software
Comment=Add, remove or update software on this computer
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Exec=gnome-software %U
Terminal=false
Type=Application
Categories=GNOME;GTK;System;PackageManager;
NoDisplay=true
@@ -0,0 +1,85 @@
#!/bin/bash
#
# This wrapper provides a mechanism for users to "uninstall"
# system apps in Phosh/GNOME UIs. Since we can't actually
# uninstall them we make a copy of the desktop file and add
# the Hidden property to disable them.
#
prompt="Are you sure you want to disable this system app?
It can be re-enabled by manually deleting the file
"
appid=""
pargs=()
while [ "$#" -gt 0 ]; do
case "$1" in
--uninstall)
# Phosh passes an app ID like 'system/flatpak/flatpak/org.gnome.Calculator/*'
appid="$(echo "$2" | rev | cut -d'/' -f2 | rev)"
newpath="$HOME"/.local/share/applications/"$appid".desktop
if grep -q "X-Duranium-Hidden=true" "$newpath" 2>/dev/null; then
echo "App $appid already hidden."
exit 0
fi
if [ -f /usr/share/applications/"$appid".desktop ]; then
# Make sure the user didn't click by mistake and explain how to
# re-enable the app
if ! zenity --title="Disable system app" --question --text="$prompt <tt>$newpath</tt>"; then
exit 1
fi
mkdir -p $HOME/.local/share/applications
cp /usr/share/applications/"$appid".desktop $HOME/.local/share/applications/
echo "Hidden=true" >> $newpath
echo "X-Duranium-Hidden=true" >> $newpath
echo "System app $appid has been hidden for user"
exit 0
fi
pargs+=("$1", "$2"); shift 2
;;
-h|--help)
echo "GNOME Software stub. This program can be used to hide"
echo "system apps or uninstall flatpak apps, intended to be used"
echo "by Phosh and other interfaces that use GNOME Software to"
echo "uninstall apps."
echo
echo "Usage:"
echo "gnome-software --uninstall APPID"
exit 1
;;
*) pargs+=("$1"); shift;;
esac
done
# If uninstalling a flatpak app do it directly
if [ -z "$appid" ]; then
echo "GNOME Software is not installed, this is a compatibility wrapper"
echo "for uninstalling apps, it only supports the --uninstall flag."
fi
if ! flatpak list --user --app | grep "$appid"; then
zenity --title="Unknown application" --info --text="The app <tt>$appid</tt> can't be uninstalled."
exit 1
fi
# Get the actual name of the app
app="$(flatpak info --user $appid | head -n2 | tail -1 | cut -d'-' -f1)"
[[ -n "$app" ]] || app="$appid"
# Ask the user to confirm
if ! zenity --question --title="Remove $app?" --text="Are you sure you want to uninstall $app?"; then
exit 1;
fi
# Do the uninstall, logging to a temp file. If it fails show an error with the log
log=$(mktemp)
(
flatpak uninstall --user --app --noninteractive --assumeyes $appid \
|| zenity --title="Error uninstalling $app" --error --text="$(cat $log)"
) > $log
rm $log