You are not logged in.

#1 2024-12-05 23:50:52

omarhanykasban
Member
Registered: 2023-11-26
Posts: 20

solved i cant seem to be able to set XDG_SESSION_DESKTOP=sway for sway

so when i login into sway using sway in tty
XDG_SESSION_DESKTOP is not set to anything and i need it to be set to sway

i tried bash scripts like this

#!/bin/bash
export XDG_SESSION_DESKTOP=sway
exec sway

#!/bin/bash
export XDG_SESSION_DESKTOP=sway
XDG_SESSION_DESKTOP=sway sway

#!/bin/bash
export XDG_SESSION_DESKTOP=sway
env XDG_SESSION_DESKTOP=sway sway

after running one of this scripts and openning terminal and running echo $XDG_SESSION_DESKTOP
it seems to be empty / not set still

how can i set it?

Online

Last edited by omarhanykasban (2024-12-06 19:27:17)

Offline

#2 2024-12-06 01:24:14

twelveeighty
Member
From: Alberta, Canada
Registered: 2011-09-04
Posts: 1,213

Re: solved i cant seem to be able to set XDG_SESSION_DESKTOP=sway for sway

Are you sure you're not confusing XDG_SESSION_DESKTOP with XDG_CURRENT_DESKTOP?

If you're positive, then perhaps add it to your /etc/sway/config.d/50-systemd-user.conf. Based on the comments in the file, it sounds like sway makes it difficult:

# sway does not set DISPLAY/WAYLAND_DISPLAY in the systemd user environment
# See FS#63021
# Adapted from xorg's 50-systemd-user.sh, which achieves a similar goal.

# Upstream refuses to set XDG_CURRENT_DESKTOP so we have to.
<snip>

Offline

#3 2024-12-06 01:26:58

omarhanykasban
Member
Registered: 2023-11-26
Posts: 20

Re: solved i cant seem to be able to set XDG_SESSION_DESKTOP=sway for sway

i know that this file has
exec systemctl --user set-environment XDG_CURRENT_DESKTOP=sway


i also tried echo $XDG_CURRENT_DESKTOP
and it said nothing


i just want this from .profile to work


if [ "$XDG_SESSION_DESKTOP" = "i3" ] || [ "$XDG_SESSION_DESKTOP" = "sway" ] || [ "$XDG_SESSION_DESKTOP" = "Hyprland" ]; then
  # Set the platform theme for QT applications
  export QT_QPA_PLATFORMTHEME=qt5ct

  # Override the default style for QT applications
  export QT_STYLE_OVERRIDE=kvantum-dark

  # Set Kvantum theme
  export KVANTUM_THEME=Nordic

  # Set the icon theme for the desktop environment
  export ICON_THEME=Papirus-Dark
  export QT_QPA_ICONTHEME=Papirus-Dark

  # Set the GTK theme to use for applications
  export GTK_THEME=Nordic

  # Set the cursor theme across various environments
  export CURSOR_THEME=WhiteSur-cursors
  export QT_QT_CURSORTHEME=WhiteSur-cursors
  export QT_QT5_CURSORTHEME=WhiteSur-cursors
  export QT_QT6_CURSORTHEME=WhiteSur-cursors
  export XCURSOR_THEME=WhiteSur-cursors

  # Define the cursor size for different environments
  export CURSOR_SIZE=24
  export XCURSOR_SIZE=24
fi

Offline

#4 2024-12-06 01:46:59

omarhanykasban
Member
Registered: 2023-11-26
Posts: 20

Re: solved i cant seem to be able to set XDG_SESSION_DESKTOP=sway for sway

i just tried to put

export XDG_SESSION_DESKTOP=sway
export XDG_CURRENT_DESKTOP=sway

in .profile and it doesnt even work
how do i set this 2 envs please i need them

Last edited by omarhanykasban (2024-12-06 01:47:13)

Offline

#5 2024-12-06 08:43:31

seth
Member
Registered: 2012-09-03
Posts: 60,776

Re: solved i cant seem to be able to set XDG_SESSION_DESKTOP=sway for sway

You don't at all.

First and foremost and as twelveeighty hinted, that's not a formal variable.
Second, setting it before starting the session will be simply too late for your ~/.profile which is parsed by the login shell - so if that's your "does nots works" metric, that's not surprising at all.
[Edit: third, those are to be set by the session/WM/compositor, so you can expect them to change whenever the session actually starts]

Instead set the other variables right before starting the WM, depending on which WM you start.

Last edited by seth (2024-12-06 08:44:16)

Offline

#6 2024-12-06 13:34:35

omarhanykasban
Member
Registered: 2023-11-26
Posts: 20

Re: solved i cant seem to be able to set XDG_SESSION_DESKTOP=sway for sway

```sh
#!/bin/bash

# Set environment variables
export XDG_SESSION_DESKTOP=sway
export XDG_CURRENT_DESKTOP=sway

# Source the user's .profile
if [ -f "$HOME/.profile" ]; then
    . "$HOME/.profile"
fi

# Start the Sway session
dbus-run-session /usr/bin/sway --unsupported-gpu "$@"
```
works i only had to use `dbus-run-session`

Offline

#7 2024-12-06 14:56:30

seth
Member
Registered: 2012-09-03
Posts: 60,776

Re: solved i cant seem to be able to set XDG_SESSION_DESKTOP=sway for sway

Please use [code][/code] tags, the bbs predates markdown by your age. Edit your post in this regard.

What is that file?
Why does it source ~/.profile?
Why do you insist of condition the environment in ~/.profile instead of fixing this file?
Again: do not export those variables, they're for the session to set - not you.

Generally don't use dbus-run-session, you probably need to "systemctl --user import-environment [VARIABLES]" and "dbus-update-activation-environment [VARIABLES]" (see /etc/X11/xinit/xinitrc.d/50-systemd-user.sh) but again: your entire approach to this is convoluted tbw.

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

Board footer

Powered by FluxBB