chamesle-nvidia-flatpak (1171B)
1 #!/bin/sh 2 # flatpak apps (steam...) need flathub's GL.nvidia-X-Y-Z that matches the installed driver to the digit, or they 3 # can't draw and quit. flatpak only adds it itself when the driver is loaded: here it follows the package. 4 # run as root by the driver manager and by chamesle-refresh, after driver updates too 5 command -v flatpak >/dev/null || exit 0 6 flatpak remotes --system 2>/dev/null | grep -q '^flathub' || exit 0 7 v=$(apk info -e nvidia nvidia580 nvidia470 nvidia390 2>/dev/null | head -n1) 8 [ -n "$v" ] || exit 0 9 v=$(apk list -I "$v" 2>/dev/null | sed -n 's/^[a-z0-9]*-\([0-9.]*\)-r[0-9]*.*/\1/p' | tr . -) 10 [ -n "$v" ] || exit 0 11 want="org.freedesktop.Platform.GL.nvidia-$v org.freedesktop.Platform.GL32.nvidia-$v" 12 have=$(flatpak list --system --runtime --columns=application 2>/dev/null) 13 for r in $want; do 14 echo "$have" | grep -qx "$r" || flatpak install --system -y --noninteractive flathub "$r//1.4" || exit 1 15 done 16 # the ones for the driver that was there before 17 for r in $(echo "$have" | grep -E '^org\.freedesktop\.Platform\.GL(32)?\.nvidia-' | grep -v -- "-$v\$"); do 18 flatpak uninstall --system -y --noninteractive "$r" >/dev/null 2>&1 19 done 20 exit 0