rharish101 / ReGreet

Clean and customizable greeter for greetd
GNU General Public License v3.0
390 stars 16 forks source link

XDG_RUNTIME_DIR environment variable problem #28

Closed semka95 closed 6 months ago

semka95 commented 1 year ago

I'm setting all environment variables in regreet.toml in [env] section. Variables that use XDG_RUNTIME_DIR variable end up being not calculated, e.g if I set: WOBSOCK="$XDG_RUNTIME_DIR/wob.sock", it does not calculate XDG_RUNTIME_DIR variable and in my system WOBSOCK variable is $XDG_RUNTIME_DIR/wob.sock, but it should be /run/user/1000/wob.sock. Before regreet I was using custom binary, where I set all variables before running sway, everything worked fine. How can I resolve this issue?

OS: Archlinux WM: sway

regreet.toml ```toml # SPDX-FileCopyrightText: 2022 Harish Rajagopal # # SPDX-License-Identifier: GPL-3.0-or-later [background] # Path to the background image path = "/usr/share/backgrounds/login-background.jpg" # How the background image covers the screen if the aspect ratio doesn't match # Available values: "Fill", "Contain", "Cover", "ScaleDown" # Refer to: https://docs.gtk.org/gtk4/enum.ContentFit.html # NOTE: This is ignored if ReGreet isn't compiled with GTK v4.8 support. fit = "Cover" # The entries defined in this section will be passed to the session as environment variables when it is started [env] _JAVA_AWT_WM_NONREPARENTING="1" QT_QPA_PLATFORM="wayland;xcb" QT_WAYLAND_DISABLE_WINDOWDECORATION="1" QT_QPA_PLATFORMTHEME="gnome" SDL_VIDEODRIVER="wayland" CLUTTER_BACKEND="wayland" MOZ_ENABLE_WAYLAND="1" MOZ_DBUS_REMOTE="1" XDG_CURRENT_DESKTOP="sway" XDG_SESSION_TYPE="wayland" TERMINAL="kitty" XDG_CONFIG_HOME="$HOME/.config" XDG_CACHE_HOME="$HOME/.cache" XDG_DATA_HOME="$HOME/.local/share" XDG_STATE_HOME="$HOME/.local/state" XDG_DATA_DIRS="/etc/xdg:/usr/local/share:/usr/share" ZDOTDIR="$HOME/.config/zsh" XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" RUSTUP_HOME="$XDG_DATA_HOME/rustup" PYTHONSTARTUP="/etc/python/pythonrc" PSQL_HISTORY="$XDG_DATA_HOME/psql_history" PLATFORMIO_CORE_DIR="$XDG_DATA_HOME/platformio" CARGO_HOME="$XDG_DATA_HOME/cargo" DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" GNUPGHOME="$XDG_DATA_HOME/gnupg" GRADLE_USER_HOME="$XDG_DATA_HOME/gradle" GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" GOPATH="$XDG_DATA_HOME/go" DVDCSS_CACHE="$XDG_DATA_HOME/dvdcss" LESSHISTFILE="$XDG_CACHE_HOME/less/history" WOBSOCK="$XDG_RUNTIME_DIR/wob.sock" PARALLEL_HOME="$XDG_CONFIG_HOME/parallel" _JAVA_OPTIONS="-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java' -Dswing.aatext=TRUE -Dawt.useSystemAAFontSettings=on'" NODE_REPL_HISTORY="$XDG_DATA_HOME/node_repl_history" NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" WINEPREFIX="$XDG_DATA_HOME/wine" REDISCLI_HISTFILE="$XDG_DATA_HOME/redis/rediscli_history" XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" [GTK] # Whether to use the dark theme application_prefer_dark_theme = true # Cursor theme name cursor_theme_name = "Adwaita" # Font name and size font_name = "Roboto 16" # Icon theme name icon_theme_name = "Adwaita" # GTK theme name theme_name = "Adwaita" [commands] # The command used to reboot the system reboot = [ "systemctl", "reboot" ] # The command used to shut down the system poweroff = [ "systemctl", "poweroff" ] ```
rharish101 commented 1 year ago

This is because ReGreet doesn't evaluate environment variables in the [env] section. Try entering the full path (WOBSOCK = "/run/user/1000/wob.sock") in the config.

semka95 commented 1 year ago

But it evaluates $HOME, for example.

rharish101 commented 1 year ago

Ah, interesting, that must be on greetd's side, since ReGreet has no code (as of commit f8022a0) to evaluate the values. Try asking on greetd's issue tracker.

kennylevinsen commented 7 months ago

greetd does not expand any environment variables passed in the session start command. They are set verbatim, passed to PAM and then to execve.

The reason for adding env back was primarily to allow controlling environment variables that can affect PAM modules, e.g. XDG_SESSION_CLASS.

If one want shell expansion of environment variables, wrap the session in a shell script or prepend them to the command line (which gets passed to /bin/sh).

rharish101 commented 6 months ago

@semka95 I'm going to close the issue, since there's a workaround available.