Closed theofficialgman closed 2 years ago
The reason for making our own .desktop file is for cases when /var/lib/flatpak/exports/share/applications
is not yet in XDG_DATA_DIRS.
The other alternative is to first install flatpak and reboot, but rebooting for a mere environment variable seems a bit pointless to me. So Pi-Apps tries to delete the flatpak menu entry and create its own.
The reason for making our own .desktop file is for cases when
/var/lib/flatpak/exports/share/applications
is not yet in XDG_DATA_DIRS. The other alternative is to first install flatpak and reboot, but rebooting for a mere environment variable seems a bit pointless to me. So Pi-Apps tries to delete the flatpak menu entry and create its own.
yeah I'm aware of this, but even with that solution, whenever the flatpak updates it will probably add its .desktop file back, and then you get duplicates again
Perhaps the flatpak_install
function can check if XDG_DATA_DIRS contains /var/lib/flatpak/exports/share/applications
, and if not, temporarily mount --bind
the directory to /usr/share/applications.
This only leaves one edge-case left, where somehow rebooting fails to add flatpak paths to XDG_DATA_DIRS. I think some of our users have reported this - hence never seeing duplicate entries for Telegram.
Perhaps the
flatpak_install
function can check if XDG_DATA_DIRS contains/var/lib/flatpak/exports/share/applications
, and if not, temporarilymount --bind
the directory to /usr/share/applications.
it would probably just be better to notify the user that they should reboot if its not found (after finishing installation ofc)
This only leaves one edge-case left, where somehow rebooting fails to add flatpak paths to XDG_DATA_DIRS. I think some of our users have reported this - hence never seeing duplicate entries for Telegram.
hmm... this might be due to not using bash, sh, fish, or csh as the login shell. or even the user re-defining XDG_DATA_DIRS in which case thats an issue with their install, not pi-apps.
flatpak installation adds scripts to /etc/profile.d/
which gets run at boot for the login shell
https://github.com/flatpak/flatpak/tree/main/profile
you can see, since I had bash as the login shell, it made /etc/profile.d/flatpak.sh
This issue has been fixed. Telegram no longer makes its own menu button with commit https://github.com/Botspot/pi-apps/commit/5476ffa6e4e41c6a8c679a5c2771b0416fb1224c And flatpak_install does what I proposed in commit https://github.com/Botspot/pi-apps/commit/c85db51001da27c6e20dc1e0423797b7664b5650
@Botspot I wrote earlier that everything was fine on my Buster with labels. After the update, my shortcut does not appear on Telegram at all. Raspberry rebooted. What can be done? install-success-Telegram.log
@Rak1ta post the output from each of these commands:
cat ~/.bashrc
cat /etc/profile.d/flatpak.sh
echo $XDG_DATA_DIRS
@theofficialgman
pi@raspberrypi:~ $ echo $XDG_DATA_DIRS
/usr/share/fkms:/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg
@Rak1ta, do you happen to be using a different shell other than bash?
Try this to see if the flatpak script successfully changes XDG_DATA_DIRS:
echo $XDG_DATA_DIRS
source /etc/profile.d/flatpak.sh
echo $XDG_DATA_DIRS
@Botspot
pi@raspberrypi:~ $ echo $XDG_DATA_DIRS
/usr/share/fkms:/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg
pi@raspberrypi:~ $ echo $XDG_DATA_DIRS
/home/pi/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/share/fkms:/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg
the /etc/profile.d scripts are supposed to be run at user log by the /etc/profile script. every user login should trigger this
so either /etc/profile is not getting run, or something rogue is overwriting the XDG_DATA_DIRS..... my hunch is startlxde-pi is broken https://github.com/RPi-Distro/raspberrypi-ui-mods/blob/db55b29b738f829f3a9ddee70c4ecbb42e4564a5/usr/bin/startlxde-pi#L3-L6
what does /usr/bin/startlxde-pi
look like on your pi?
cat /usr/bin/startlxde-pi
@theofficialgman
pi@raspberrypi:~ $ cat /usr/bin/startlxde-pi
#!/bin/sh
if ! grep -q 'Raspberry Pi' /proc/device-tree/model || (grep -q okay /proc/device-tree/soc/v3d@7ec00000/status 2> /dev/null || grep -q okay /proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null || grep -q okay /proc/device-tree/v3dbus/v3d@7ec04000/status 2> /dev/null) ; then
export XDG_DATA_DIRS="/usr/share/fkms:/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg"
else
export XDG_DATA_DIRS="/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg"
fi
if [ -z "$XDG_CONFIG_HOME" ]; then
export XDG_CONFIG_HOME="$HOME/.config"
fi
# Ensure the existence of the 'Desktop' folder
if [ -e "$XDG_CONFIG_HOME/user-dirs.dirs" ]; then
. "$XDG_CONFIG_HOME/user-dirs.dirs"
else
XDG_DESKTOP_DIR="$HOME/Desktop"
fi
mkdir -p "$XDG_DESKTOP_DIR"
# Clean up after GDM (GDM sets the number of desktops to one)
xprop -root -remove _NET_NUMBER_OF_DESKTOPS -remove _NET_DESKTOP_NAMES -remove _NET_CURRENT_DESKTOP 2> /dev/null
# Enable GTK+3 integration for OpenOffice.org, if available.
export SAL_USE_VCLPLUGIN=gtk3
# Launch DBus if needed
if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
eval "$(dbus-launch --sh-syntax --exit-with-session)"
fi
export XDG_MENU_PREFIX="lxde-pi-"
sync
# Start the LXDE session
exec /usr/bin/lxsession -s LXDE-pi -e LXDE
@Botspot BINGO ^ see above. BAD BAD BAD startlxde-pi is deleting XDG_DATA_DIRS
what package provides that? it MUST be fixed by the pi devs ASAP. upstream from the github has it fixed 10 months ago https://github.com/RPi-Distro/raspberrypi-ui-mods/commit/920c8d4d5954b475956f492f99a307b02c078689
edit: raspberrypi-ui-mods
raspberrypi-ui-mods (1.20210730) UNRELEASED; urgency=medium
* Preserve XDG_DATA_DIRS
-- Simon Long <simon@raspberrypi.com> Fri, 30 Jul 2021 09:36:36 +0100
its released for bullseye, not for buster
alright I've left a bug report https://github.com/RPi-Distro/raspberrypi-ui-mods/issues/42 and pinged the maintainer
@Rak1ta thank you for your co-operation
@Botspot this is news to me: https://github.com/RPi-Distro/raspberrypi-ui-mods/issues/42#issuecomment-1134795398
the creator says buster is fully deprecated and will not receive any updates
@Botspot this is news to me: RPi-Distro/raspberrypi-ui-mods#42 (comment)
the creator says buster is fully deprecated and will not receive any updates
I was aware they weren't updating unnecessary stuff, but I was under the impression that they would continue to support as a sort of LTS release. Relevant blog post: https://www.raspberrypi.com/news/new-old-functionality-with-raspberry-pi-os-legacy/
I'm disappointed... https://github.com/RPi-Distro/raspberrypi-ui-mods/issues/42#issuecomment-1134842225 . this is not the kind of response I would expect from a true LTS of which we now know piOS legacy is not
given this, how should pi-apps proceed? this is an easy fix (we can do it with a sed command on the file) but there are other problems that we now know will never get fixed. buster is as good as abandoned by the devs
I'm disappointed... RPi-Distro/raspberrypi-ui-mods#42 (comment) . this is not the kind of response I would expect from a true LTS of which we now know piOS legacy is not
given this, how should pi-apps proceed? this is an easy fix (we can do it with a sed command on the file) but there are other problems that we now know will never get fixed. buster is as good as abandoned by the devs
Their response surprised me as well. Without a proper fix from maintainers, our only options are to follow their lead (drop buster support), or fix the problem ourselves. I think that in this case, the best option is to patch the file with sed.
I just checked my /usr/bin/startlxde-pi file on Raspberry Pi Os Bullseye, and it also seems to overwrite the value of XDG_DATA_DIRS.
if ! raspi-config nonint is_pi || raspi-config nonint is_kms ; then
export XDG_DATA_DIRS="/usr/share/fkms:/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
else
export XDG_DATA_DIRS="/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
fi
if [ -z "$XDG_CONFIG_HOME" ]; then
export XDG_CONFIG_HOME="$HOME/.config"
fi
# Ensure the existence of the 'Desktop' folder
if [ -e "$XDG_CONFIG_HOME/user-dirs.dirs" ]; then
. "$XDG_CONFIG_HOME/user-dirs.dirs"
else
XDG_DESKTOP_DIR="$HOME/Desktop"
fi
mkdir -p "$XDG_DESKTOP_DIR"
# Clean up after GDM (GDM sets the number of desktops to one)
xprop -root -remove _NET_NUMBER_OF_DESKTOPS -remove _NET_DESKTOP_NAMES -remove _NET_CURRENT_DESKTOP 2> /dev/null
# Enable GTK+3 integration for OpenOffice.org, if available.
export SAL_USE_VCLPLUGIN=gtk3
# Launch DBus if needed
if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
eval "$(dbus-launch --sh-syntax --exit-with-session)"
fi
export XDG_MENU_PREFIX="lxde-pi-"
TOTAL_MEM=$(vcgencmd get_config total_mem | cut -d= -f2)
VNC=$(systemctl status vncserver-x11-serviced | grep -w active)
if [ $TOTAL_MEM -ge 2048 ] && [ -f /usr/bin/mutter ] && [ -z "$VNC" ] ; then
if [ -f "$XDG_CONFIG_HOME/gtk-3.0/gtk.css" ] ; then
rm "$XDG_CONFIG_HOME/gtk-3.0/gtk.css"
fi
sync
export V3D_IGNORE_SCANOUT_USAGES=1
export CLUTTER_DRIVER="gles2"
export COGL_DRIVER="gles2"
exec /usr/bin/lxsession -s LXDE-pi -e LXDE
else
if [ ! -f "$XDG_CONFIG_HOME/gtk-3.0/gtk.css" ] || ! grep -s -q tooltip "$XDG_CONFIG_HOME/gtk-3.0/gtk.css" ; then
mkdir -p "$XDG_CONFIG_HOME/gtk-3.0"
cat > "$XDG_CONFIG_HOME/gtk-3.0/gtk.css" << EOF
tooltip, .tooltip { border-radius: 0px; }
EOF
fi
sync
exec /usr/bin/lxsession -s LXDE-pi -e LXDE -w openbox-lxde-pi
fi
I just checked my /usr/bin/startlxde-pi file on Raspberry Pi Os Bullseye, and it also seems to overwrite the value of XDG_DATA_DIRS.
if ! raspi-config nonint is_pi || raspi-config nonint is_kms ; then export XDG_DATA_DIRS="/usr/share/fkms:/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" else export XDG_DATA_DIRS="/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" fi
it doesn't overwrite. its adds. the key part is at the end where they add the original contents. thats the patch
this sed should be sufficient to fix it
sudo sed -i 's;/var/lib/menu-xdg";/var/lib/menu-xdg${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}";g' /usr/bin/startlxde-pi
That looks correct to me. @Rak1ta could you run that command above and then reboot to see if your flatpak shortcuts appear in the menu?
@Botspot works!
ok I'll leave this to you botspot where you want to add this sed. It would probably be good as a runonce.
ok I'll leave this to you botspot where you want to add this sed. It would probably be good as a runonce.
I want to add this runonce to the gui script, but either I can:
Maybe an api function could be used as a sudo/pkexec hybrid that will only show a dialog if necessary?
I want to add this runonce to the gui script, but either I can:
- Use sudo, which is passwordless on Raspbien buster, or
- Use pkexec, but that will open a pop-up window for all buster users
Maybe an api function could be used as a sudo/pkexec hybrid that will only show a dialog if necessary?
this might be of help
if sudo -n true; then
# sudo is available (within sudo timer) or passwordless
sudo sed -i 's;/var/lib/menu-xdg";/var/lib/menu-xdg${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}";g' /usr/bin/startlxde-pi
else
# sudo is not available (not within sudo timer)
pkexec sed -i 's;/var/lib/menu-xdg";/var/lib/menu-xdg${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}";g' /usr/bin/startlxde-pi
fi
This should be fixed with commit 0726919a75205c4a17d63faa49a68f18d2f7ffe5.
Confirmations
What happened?
Installed telegram flatpak and two .desktop files are made (one by pi-apps and one by flatpak)
Description
what is the reason for pi-apps to create its own .desktop file? both work but why even bother making our own and attempting to delete the official one (which the script fails at because it deletes at the wrong path)
What is your operating system?
L4T Ubuntu Bionic
(Optional) Error log? Terminal output? Debug messages?
No response