When installing software using GNOME Software and the Flatpak repo, I’m asked for administrative privileges (sudo) to install, but I would like to choose between installing for the entire system or only for the current user. To solve this, I need to run flatpak remote-add --user flathub https://flathub.org/repo/flathub.flatpakrepo for every user, while already having sudo flatpak remote-add flathub https://flathub.org/repo/flathub.flatpakrepo configured system-wide. This works, but it feels cumbersome. Is there no way to allow users to choose between system-wide and user-specific installations without running the command for every user account?
Core Question: Can I enable users to choose between system-wide and user-specific Flatpak installations without requiring manual configuration for each user account?"
Oh, that’s a bummer.
Thanks for the fast response!
Well, for now, I’ll just run the following script when I create a new user. Hope it’s useful for someone :)"
add_flatpak_remote.sh
#!/bin/bash
# Define the group to check for (change as needed)
target_group="users"
# Loop through all system users listed in /etc/passwd
while IFS=: read -r username _ uid _ _ _ home_dir shell; do
# Skip system users (UID < 1000) and users with invalid shells
if [ "$uid" -ge 1000 ] && [ -d "$home_dir" ] && [ "$shell" != "/usr/sbin/nologin" ] && [ "$shell" != "/bin/false" ]; then
# Check if the user belongs to the target group
if groups "$username" | grep -qw "$target_group"; then
# Add the Flatpak remote for the user
echo "Adding Flatpak remote for user: $username with home dir: $home_dir"
sudo -u "$username" flatpak remote-add --user flathub https://flathub.org/repo/flathub.flatpakrepo
else
echo "User $username does not belong to the '$target_group' group. Skipping."
fi
fi
done < /etc/passwd