Skip to content

How can I load env variable from /etc/profile.d for my graphic session? #62

@Gigas002

Description

@Gigas002

I'm using hyprland as compositor, here're my configs:

/etc/greetd/config.toml

[terminal]
# The VT to run the greeter on. Can be "next", "current" or a number
# designating the VT.
vt = 1

# The default session, also known as the greeter.
[default_session]

# `agreety` is the bundled agetty/login-lookalike. You can replace `/bin/sh`
# with whatever you want started, such as `sway`.
command = "Hyprland --config /etc/greetd/hyprland.conf"

# The user to run the command as. The privileges this user must have depends
# on the greeter. A graphical greeter may for example require the user to be
# in the `video` group.
user = "greeter"

/etc/greeetd/hyprland.conf

# env = XDG_SESSION_TYPE,wayland

exec-once = regreet; hyprctl dispatch exit
# exec-once = /etc/profile.d/wayland-env.sh

input {
    kb_layout = us
    numlock_by_default = true
}

misc {
    vrr = 0
    disable_hyprland_logo = true
    disable_splash_rendering = true
    force_default_wallpaper = 0
}

/etc/greetd/regreet.toml

# SPDX-FileCopyrightText: 2022 Harish Rajagopal <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

[background]
# Path to the background image
path = "/usr/share/backgrounds/greet.png"

# 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 = "Fill"

# The entries defined in this section will be passed to the session as environment variables when it is started
[env]

[GTK]
# Whether to use the dark theme
application_prefer_dark_theme = true

# Cursor theme name
cursor_theme_name = "Sweet-cursors"

# Font name and size
font_name = "CaskaydiaCove Nerd Font Mono 16"

# Icon theme name
icon_theme_name = "Sweet-Rainbow"

# GTK theme name
theme_name = "Sweet"

[commands]
# The command used to reboot the system
reboot = [ "systemctl", "reboot" ]

# The command used to shut down the system
poweroff = [ "systemctl", "poweroff" ]

And the script I want to run:

/etc/profile.d/wayland-env.sh

if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
  # GTK wayland backend: https://wiki.archlinux.org/title/Wayland#GTK
  export GDK_BACKEND=wayland

  # Qt HidhDPI settings: https://doc.qt.io/qt-6/highdpi.html
  # export QT_AUTO_SCREEN_SCALE_FACTOR=1
  # export QT_SCALE_FACTOR=1

  # Qt wayland backend: https://wiki.archlinux.org/title/Wayland#Qt
  export QT_QPA_PLATFORM="wayland;xcb"

  # KDE File Picker by default: https://bbs.archlinux.org/viewtopic.php?id=253132
  export GTK_USE_PORTAL=1

  # Firefox wayland backend: https://wiki.archlinux.org/title/Firefox#Wayland
  export MOZ_ENABLE_WAYLAND=1

  # Nvidia-specific settings: https://wiki.archlinux.org/title/Wayland#Requirements
  # export GBM_BACKEND=nvidia-drm
  # export __GLX_VENDOR_LIBRARY_NAME=nvidia

  # Force session to run on Nvidia GPU on laptops with
  # prime render offload, see: https://wiki.archlinux.org/title/PRIME#Configure_applications_to_render_using_GPU
  # export __NV_PRIME_RENDER_OFFLOAD=1
  # Additional prime settings: https://wiki.archlinux.org/title/PRIME#Wayland-specific_configuration
  # export __VK_LAYER_NV_optimus=NVIDIA_only
  
  # SDL2 wayland backend: https://wiki.archlinux.org/title/Wayland#SDL2
  export SDL_VIDEODRIVER="wayland,x11"

  # Try to set electron backend: https://wiki.archlinux.org/title/Wayland#Electron
  export ELECTRON_OZONE_PLATFORM_HINT="wayland"
fi

When I log in graphic session, I try to check any of these variables in terminal, e.g. echo $ELECTRON_OZONE_PLATFORM_HINT and get nothing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions