2

I'm using Kubuntu v20.04, which I launch using SDDM. The issue I'm facing is setting some environment variables for my Xsession. I use ~/.config/plasma-workspace/env/env.sh to export my environment variables, however, I'm observing that a few variables aren't getting set such as LD_PRELOAD. I can confirm this because echo $LD_PRELOAD returns nothing.

What should be a proper way of doing this?

These are my dotfiles: https://github.com/utkarshverma/dotfiles

2
  • 1
    exporting variables in .sh (executable?) files in ~/.config/plasma-workspace/env/ is the officially supported way, it should work (and I can confirm it works on Arch Linux with KDE + SDDM). Where are you executing echo $LD_PRELOAD? (E.g. Bash in Konsole?) Did you check if LD_PRELOAD is unset/changed somewhere in your shell startup scripts?
    – fra-san
    Jul 24, 2020 at 9:24
  • I'm executing echo $LD_PRELOAD in my terminal. Also, I'm only using env.sh as a startup script so something else is off. And my env.sh is getting executed since other variables in it have been exported. I read ~/.xsession_errors and it does show $LD_PRELOAD as being exported, however I can't find anything which might be unsetting it. Jul 24, 2020 at 9:57

1 Answer 1

1

After a long time, I finally came back to analysing this issue and embarrassingly found out that the exports were working, but I had two conflicting exports, through .zprofile and .xsessionrc for the same variable.

Also, I've noticed that for some reason, probably security related?, you can't simply inspect the LD_PRELOAD variable. It will always return empty.

Though the answer isn't much, I do feel it would be worthwhile to share how I tracked down the issue.

  • My first clue was .xsession-errors which properly logs all stuff related to X. In that file, I could see that LD_PRELOAD was being set twice on logon.
  • After that, I just searched the exact line of code in all my files using grep -rnw ~/* -e "export LD_PRELOAD". It clearly indicated the respective files which had the lines, .zprofile and .xsessionrc and I was able to fix the issue.

Update: It seems that LD_PRELOAD was being unset by KDE after sourcing ~/.xsessionrc that's why export wasn't reporting anything. I've moved the export statement to ~/.zshrc for now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .