You are not logged in.

#1 2021-06-09 18:32:58

Toadfield
Member
Registered: 2021-06-08
Posts: 56

How can I use Mangohud for OpenGL applications globally?

I already asked this on r/linux4noobs and r/linuxquestions and r/archlinux,but the people couldn't help me,so I ask here.

I want to use Mangohud,cause I want to see my fps in game and limit the fps and use vsync options,it already works globally for vulkan programs by puttig "export MANGOHUD=1" in .profile,but that doesn't work with OpenGL programs.

I asked the mangohud dev and he replied that I needed to put this in .profile:
export LD_PRELOAD=/usr/lib/mangohud/libMangoHud.so:/usr/lib32/mangohud/libMangoHud.so
export MANGOHUD=1
export MANGOHUD_DLSYM=1

But when I do this and restart,then it still doesn't work with OpenGL apps globally,the dev said that he can't help me,so did anyone of you get it to work?

Offline

#2 2021-06-09 18:35:35

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,353
Website

Re: How can I use Mangohud for OpenGL applications globally?

Are you sure your ~/.profile is even read? https://wiki.archlinux.org/title/Bash#C … tion_files


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2021-06-09 22:46:53

Toadfield
Member
Registered: 2021-06-08
Posts: 56

Re: How can I use Mangohud for OpenGL applications globally?

When I put env vars that are not LD_PRELOAD,then they work,so they get read.

Offline

#4 2021-06-09 22:52:25

loqs
Member
Registered: 2014-03-06
Posts: 13,448

Re: How can I use Mangohud for OpenGL applications globally?

Does the output of env list

LD_PRELOAD=/usr/lib/mangohud/libMangoHud.so:/usr/lib32/mangohud/libMangoHud.so
MANGOHUD=1
MANGOHUD_DLSYM=1

How are you starting the applications?  If not from the console does it work from the console?

Offline

#5 2021-06-09 23:17:30

Toadfield
Member
Registered: 2021-06-08
Posts: 56

Re: How can I use Mangohud for OpenGL applications globally?

loqs wrote:

Does the output of env list

LD_PRELOAD=/usr/lib/mangohud/libMangoHud.so:/usr/lib32/mangohud/libMangoHud.so
MANGOHUD=1
MANGOHUD_DLSYM=1

How are you starting the applications?  If not from the console does it work from the console?

That's strange,none of the env vars get listed even though some that I put in .profile work.
So how can I make .profile properly readable?
I am starting the applications by .desktop files or executing the executable directly,starting them from terminal also doesn't make mangohud work.

Offline

#6 2021-06-09 23:20:38

loqs
Member
Registered: 2014-03-06
Posts: 13,448

Re: How can I use Mangohud for OpenGL applications globally?

Is the desktop started by a display manager or started on your user login.  If user login what is the login shell?

Offline

#7 2021-06-09 23:34:29

Toadfield
Member
Registered: 2021-06-08
Posts: 56

Re: How can I use Mangohud for OpenGL applications globally?

I start it by the sddm display manager.

Offline

#8 2021-06-09 23:48:29

loqs
Member
Registered: 2014-03-06
Posts: 13,448

Re: How can I use Mangohud for OpenGL applications globally?

/usr/share/sddm/scripts/Xsession for an X session and /usr/share/sddm/scripts/wayland-session source various files at startup.  The particular files depends on the users login shell.

Last edited by loqs (2021-06-09 23:48:41)

Offline

#9 2021-06-10 00:08:31

Toadfield
Member
Registered: 2021-06-08
Posts: 56

Re: How can I use Mangohud for OpenGL applications globally?

Can I somehow edit which files /usr/share/sddm/scripts/wayland-session sources at startup?

Offline

#10 2021-06-10 00:23:17

loqs
Member
Registered: 2014-03-06
Posts: 13,448

Re: How can I use Mangohud for OpenGL applications globally?

Yes you can edit it.  Is that needed?  The default contents is:

#!/bin/sh
# wayland-session - run as user
# Copyright (C) 2015-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>

# This file is extracted from kde-workspace (kdm/kfrontend/genkdmconf.c)
# Copyright (C) 2001-2005 Oswald Buddenhagen <ossi@kde.org>

# Note that the respective logout scripts are not sourced.
case $SHELL in
  */bash)
    [ -z "$BASH" ] && exec $SHELL $0 "$@"
    set +o posix
    [ -f /etc/profile ] && . /etc/profile
    if [ -f $HOME/.bash_profile ]; then
      . $HOME/.bash_profile
    elif [ -f $HOME/.bash_login ]; then
      . $HOME/.bash_login
    elif [ -f $HOME/.profile ]; then
      . $HOME/.profile
    fi
    ;;
*/zsh)
    [ -z "$ZSH_NAME" ] && exec $SHELL $0 "$@"
    [ -d /etc/zsh ] && zdir=/etc/zsh || zdir=/etc
    zhome=${ZDOTDIR:-$HOME}
    # zshenv is always sourced automatically.
    [ -f $zdir/zprofile ] && . $zdir/zprofile
    [ -f $zhome/.zprofile ] && . $zhome/.zprofile
    [ -f $zdir/zlogin ] && . $zdir/zlogin
    [ -f $zhome/.zlogin ] && . $zhome/.zlogin
    emulate -R sh
    ;;
  */csh|*/tcsh)
    # [t]cshrc is always sourced automatically.
    # Note that sourcing csh.login after .cshrc is non-standard.
    wlsess_tmp=`mktemp /tmp/wlsess-env-XXXXXX`
    $SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $wlsess_tmp"
    . $wlsess_tmp
    rm -f $wlsess_tmp
    ;;
  */fish)
    xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX`
    $SHELL --login -c "/bin/sh -c 'export -p' > $xsess_tmp"
    . $xsess_tmp
    rm -f $xsess_tmp
    ;;
  *) # Plain sh, ksh, and anything we do not know.
    [ -f /etc/profile ] && . /etc/profile
    [ -f $HOME/.profile ] && . $HOME/.profile
    ;;
esac

exec $@

So login shell is:
    bash sources /etc/profile directly,
    zsh sources /etc/zsh/zprofile which by default sources /etc/profile
    tsch not sure on this one
    fish again not sure
    anything else,  sources /etc/profile directly.

Offline

#11 2021-06-10 00:25:20

Toadfield
Member
Registered: 2021-06-08
Posts: 56

Re: How can I use Mangohud for OpenGL applications globally?

So if I understand it right,then I should try to put the env vars in /etc/profile?

Offline

#12 2021-06-10 00:31:57

loqs
Member
Registered: 2014-03-06
Posts: 13,448

Re: How can I use Mangohud for OpenGL applications globally?

I missed you were using .profile instead of profile.

login shell is:
    bash sources .profile directly,
    zsh sources .zprofile
    tsch not sure on this one
    fish again not sure
    anything else,  sources .profile directly

So if your login shell is zsh either add the vars to .zprofile or have .zprofile source .profile.

Offline

#13 2021-06-10 01:00:36

Toadfield
Member
Registered: 2021-06-08
Posts: 56

Re: How can I use Mangohud for OpenGL applications globally?

How can I check which login shell I use?
I have zsh and bash installed,but forgot what I set as login shell.

Offline

#14 2021-06-10 01:08:52

loqs
Member
Registered: 2014-03-06
Posts: 13,448

Re: How can I use Mangohud for OpenGL applications globally?

getent passwd $UID

login shell will be the seventh ( last ) of colon separated fields.

Offline

#15 2021-06-10 01:25:56

Toadfield
Member
Registered: 2021-06-08
Posts: 56

Re: How can I use Mangohud for OpenGL applications globally?

loqs wrote:
getent passwd $UID

login shell will be the seventh ( last ) of colon separated fields.

It's bash,that's strange,now the question is why .profile doesn't work.

Offline

#16 2021-06-10 01:33:33

loqs
Member
Registered: 2014-03-06
Posts: 13,448

Re: How can I use Mangohud for OpenGL applications globally?

  */bash)
    [ -z "$BASH" ] && exec $SHELL $0 "$@"
    set +o posix
    [ -f /etc/profile ] && . /etc/profile
    if [ -f $HOME/.bash_profile ]; then
      . $HOME/.bash_profile
    elif [ -f $HOME/.bash_login ]; then
      . $HOME/.bash_login
    elif [ -f $HOME/.profile ]; then
      . $HOME/.profile
    fi

I missed in order of preference .bash_profile .bash_login and then .profile will be used.
So I am guessing as per deafult you have .bash_profile.

Offline

#17 2021-06-10 01:52:15

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,353
Website

Re: How can I use Mangohud for OpenGL applications globally?

loqs wrote:

So I am guessing as per deafult you have .bash_profile.

That was the link in the second post that OP ignored.

Toadfield, you are going to have a hard time with Arch if you expect to be spoonfed.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#18 2021-06-10 02:01:17

Toadfield
Member
Registered: 2021-06-08
Posts: 56

Re: How can I use Mangohud for OpenGL applications globally?

loqs wrote:
  */bash)
    [ -z "$BASH" ] && exec $SHELL $0 "$@"
    set +o posix
    [ -f /etc/profile ] && . /etc/profile
    if [ -f $HOME/.bash_profile ]; then
      . $HOME/.bash_profile
    elif [ -f $HOME/.bash_login ]; then
      . $HOME/.bash_login
    elif [ -f $HOME/.profile ]; then
      . $HOME/.profile
    fi

I missed in order of preference .bash_profile .bash_login and then .profile will be used.
So I am guessing as per deafult you have .bash_profile.

But wouldn't that mean that all three,.bash_profile .bash_login and .profile will be used?
Or does only .bash_profile get used?

Offline

#19 2021-06-10 03:46:40

dakota
Member
Registered: 2016-05-20
Posts: 115

Re: How can I use Mangohud for OpenGL applications globally?

Toadfield wrote:

But wouldn't that mean that all three,.bash_profile .bash_login and .profile will be used?
Or does only .bash_profile get used?

You may be interested in... Bash Scripting Tutorial - If statements

Offline

Board footer

Powered by FluxBB