You are not logged in.

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

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

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,356
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: 63

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,452

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: 63

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,452

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: 63

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,452

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: 63

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,452

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: 63

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,452

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: 63

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,452

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: 63

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,452

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,356
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: 63

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: 117

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

#20 2021-06-14 13:16:03

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

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

So I edited my .bash_profile and it now looks like this:

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc

export LD_PRELOAD=/usr/lib/libMangoHud.so:/usr/lib32/libMangoHud.so:/usr/lib/libgtk3-nocsd.so.0
export MANGOHUD_DLSYM=1
export MANGOHUD=1
export CLUTTER_BACKEND=wayland
export GTK_USE_PORTAL=1
export GTK_CSD=0

I tested it,mangohud works with Vulkan applications,but it still doesn't work with OpenGL applications.
I also tried another LD_PRELOAD Env Var (/usr/lib/libgtk3-nocsd.so.0),but that also doesn't work.

Offline

#21 2021-06-14 19:03:33

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

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

I think the problem here isn't mangohud itself,but LD_PRELOAD.

Offline

#22 2021-06-14 19:17:11

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

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

Toadfield wrote:

I think the problem here isn't mangohud itself,but LD_PRELOAD.

How did you reach that conclusion?  Have you read through the ld.so man page,  which includes how to trace the loaded libraries?

LD_TRACE_LOADED_OBJECTS="" stat
	linux-vdso.so.1 (0x00007ffe789d7000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f84d5cac000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f84d5e9a000)
LD_TRACE_LOADED_OBJECTS="" LD_PRELOAD=/usr/lib/libm.so.6 stat
	linux-vdso.so.1 (0x00007fff43d3c000)
	/usr/lib/libm.so.6 (0x00007f75d4802000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f75d4616000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f75d4949000)
LD_TRACE_LOADED_OBJECTS="" LD_PRELOAD=/usr/lib/liblib.so stat
ERROR: ld.so: object '/usr/lib/liblib.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
	linux-vdso.so.1 (0x00007ffd11bb4000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f849edb5000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f849efa3000)

Last edited by loqs (2021-06-14 19:18:17)

Offline

#23 2021-06-14 23:43:10

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

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

loqs wrote:
Toadfield wrote:

I think the problem here isn't mangohud itself,but LD_PRELOAD.

How did you reach that conclusion?  Have you read through the ld.so man page,  which includes how to trace the loaded libraries?

LD_TRACE_LOADED_OBJECTS="" stat
	linux-vdso.so.1 (0x00007ffe789d7000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f84d5cac000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f84d5e9a000)
LD_TRACE_LOADED_OBJECTS="" LD_PRELOAD=/usr/lib/libm.so.6 stat
	linux-vdso.so.1 (0x00007fff43d3c000)
	/usr/lib/libm.so.6 (0x00007f75d4802000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f75d4616000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f75d4949000)
LD_TRACE_LOADED_OBJECTS="" LD_PRELOAD=/usr/lib/liblib.so stat
ERROR: ld.so: object '/usr/lib/liblib.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
	linux-vdso.so.1 (0x00007ffd11bb4000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f849edb5000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f849efa3000)

I did

LD_TRACE_LOADED_OBJECTS="" LD_PRELOAD=/usr/lib/libMangoHud.so

and I got nothing as an output,did I get it wrong?
I also tested it by running some gui applications (not from the terminal) and neither mangohud nor libstrangle nor gtk3-nocsd LD_PRELOAD commands worked.
This is my system info if this helps:

 OS: Arch Linux x86_64 
Kernel: 5.12.10-arch1-1 
Uptime: 5 hours, 48 mins 
Packages: 1704 (pacman), 4 (flatpak) 
Shell: bash 5.1.8 
Resolution: 1920x1080 
DE: Plasma 5.22.0 
WM: kwin 
WM Theme: WhiteSur-Sharp-dark 
Theme: WhiteSurDark [Plasma], Breeze-gtk [GTK2], Breeze [GTK3] 
Icons: [Plasma], WhiteSur-dark [GTK2/3] 
Terminal: konsole 
Terminal Font: Monospace 14 
CPU: AMD Ryzen 5 3600 (12) @ 3.600GHz 
GPU: AMD ATI Radeon RX 470/480/570/570X/580/580X/590 
GPU: AMD ATI Radeon R7 240/340 
Memory: 3418MiB / 15995MiB
Desktop Protocol: Wayland

Offline

#24 Yesterday 00:07:52

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

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

LD_TRACE_LOADED_OBJECTS="" LD_PRELOAD=/usr/lib/libMangoHud.so

What command is the above supposed to be preloading /usr/lib/libMangoHud.so into?  As posted the above sets two variables and does nothing else.

Last edited by loqs (Yesterday 00:13:55)

Offline

#25 Yesterday 00:34:15

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

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

How can I check it then?

Offline

Board footer

Powered by FluxBB