How to enable hax11 for all apps by default
d9k opened this issue · 26 comments
Hi!
To try this library, build this library as above, then in the same directory, run the following in a shell:
$ export LD_PRELOAD=`pwd`/\$LIB/hax11.so
Then, from the same shell session, start the desired game or application.
How to preload hax11.so
for ALL apps automatically?
I tried to add
export LD_PRELOAD=/path/to/hax11.so
to ~/.xsessionrc
, ~/.bashrc
, ~/profile
and even to /etc/environment
but nothing works: library is used only when I start GUI app from terminal emulator.
In theory, sudo make install
and reboot:
Line 27 in d9fa924
@CyberShadow, thanks, but no luck
> cat /etc/profile.d/hax11.sh
export LD_PRELOAD=/usr/local/lib64/hax11.so
> ll /usr/local/lib64/hax11.so
-rw-r--r-- 1 root root 89K Dec 28 00:34 /usr/local/lib64/hax11.so
> cat ~/.config/hax11/profiles/default
Enable=1
NoPrimarySelection=1
> cat /etc/lsb-release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=19
DISTRIB_CODENAME=tara
DISTRIB_DESCRIPTION="Linux Mint 19 Tara"
> cat /etc/upstream-release/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"
> uname -r
4.15.0-163-generic
How do you know it's not working?
Is it in LD_PRELOAD
?
If it is, do you get log output with Debug=1
in the default
config file?
How do you know it's not working?
When I start app from terminal emulator select-to-copy is disabled (as I want).
When I start app from Alt+F2
launcher select-to-copy isn't disabled.
Got it.
Can you try putting LD_PRELOAD=/usr/local/$LIB/hax11.so
in /etc/environment
and see if that helps.
@CyberShadow, It's already there:
> cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
QT_QPA_PLATFORMTHEME=gtk2
QT_STYLE_OVERRIDE=gtk2
export LD_PRELOAD=/home/d9k/soft/hax11/lib64/hax11.so
Upd: I'll try to set another path and reboot.
No export
, it is not a shell script.
Also $LIB
must be there verbatim, it is not a shell variable.
Got alert window on startup:
ERROR: ld.so: object '/usr/local/$LIB/hax11.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file)
> cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
QT_QPA_PLATFORMTHEME=gtk2
QT_STYLE_OVERRIDE=gtk2
LD_PRELOAD=/usr/local/$LIB/hax11.so
> cat /etc/profile.d/hax11.sh
export LD_PRELOAD=/usr/local/\$LIB/hax11.so
There is slash in cat /etc/profile.d/hax11.sh
(created by sudo make install
). Is it an error?
There is slash in
cat /etc/profile.d/hax11.sh
(created bysudo make install
). Is it an error?
No, it prevents the shell from interpreting the $
as the variable name prefix.
Could you please try the following:
- Post the output from
env | grep LD_PRELOAD
when you run it in a terminal. - Run the program via Alt-F2, and then run
cat /proc/$(pgrep ProgramNameHere | head -1)/environ | xargs -0 -n 1 echo | grep LD_PRELOAD
and post the output here. ReplaceProgramNameHere
with the program name of the program you're running.
Post the output from
env | grep LD_PRELOAD
when you run it in a terminal.
env | grep LD_PRELOAD
LD_PRELOAD=/usr/local/lib64/hax11.so
Run the program via Alt-F2, and then run...
> pgrep textadept | head -1
17585
> cat /proc/$(pgrep textadept | head -1)/environ | xargs -0 -n 1 echo | grep LD_PRELOAD
— nothing
So I guess the launcher program (that runs on Alt-F2) is either unaffected by both /etc/environment
and /etc/profile
, or for whatever reason it intentionally unsets LD_PRELOAD
. I'm not sure what that is without more information; I think the program's authors would be more helpful in figuring it out.
If your desktop environment supports .xinitrc
or .xinitrc.d
, you could try adding source /etc/profile.d/hax11.sh
there.
On a more practical note, you could make a script around the target program which sets LD_PRELOAD
:
#!/bin/sh
source /etc/profile.d/hax11.sh
exec /path/to/real-program "$@"
If I put
export LD_PRELOAD=/usr/local/\$LIB/hax11.so
into /etc/profile.d/hax11.sh
there is alert window on cinnamon startup:
ERROR: ld.so: object '/usr/local/$LIB/hax11.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file)
For
export LD_PRELOAD=/usr/local/$LIB/hax11.so
alert says:
ERROR: ld.so: object '/usr/local//hax11.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file)
And when
export LD_PRELOAD=/usr/local/lib64/hax11.so
it just silently doesn't work for run dialog apps.
BTW, I commented out export LD_PRELOAD...
in ~/.profile
and echo $LD_PRELOAD
became empty in terminal emulator after the reboot too!
So user apps ignore env variables exported from /etc/profile.d
somehow...
there is alert window on cinnamon startup:
You should have these files:
/usr/local/lib32/hax11.so
/usr/local/lib64/hax11.so
/usr/local/lib/hax11.so
(actually 2 files, lib64
should be a symlink to lib
or the other way around)
Please check that the files are there.
> ll /usr/local/lib32/hax11.so
-rw-r--r-- 1 root root 80K Dec 28 01:24 /usr/local/lib32/hax11.so
> ll /usr/local/lib64/hax11.so
-rw-r--r-- 1 root root 89K Dec 28 01:24 /usr/local/lib64/hax11.so
> ll /usr/local/lib/hax11.so
/bin/ls: cannot access '/usr/local/lib/hax11.so': No such file or directory
If I export another variable from hax11.sh
it's visible in terminal after reboot
> cat /etc/profile.d/hax11.sh
export LD_PRELOAD=/usr/local/lib64/hax11.so
export ETC_PROFILE_HAX11_LOADED=1
> echo $ETC_PROFILE_HAX11_LOADED
1
echo $LD_PRELOAD
# empty
Try sudo mv /usr/local/lib64/hax11.so /usr/local/lib/ && sudo rmdir /usr/local/lib64 && sudo ln -s lib /usr/local/lib64
thanks, tried, there is the same alert window on cinnamon startup:
ERROR: ld.so: object '/usr/local/$LIB/hax11.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file)
> ll /usr/local/lib32/hax11.so
-rw-r--r-- 1 root root 80K Dec 28 01:24 /usr/local/lib32/hax11.so
> ll /usr/local/lib64/hax11.so
-rw-r--r-- 1 root root 89K Dec 28 01:24 /usr/local/lib64/hax11.so
> ll /usr/local/lib/hax11.so
-rw-r--r-- 1 root root 89K Dec 28 01:24 /usr/local/lib/hax11.so
> cat /etc/profile.d/hax11.sh
export LD_PRELOAD=/usr/local/\$LIB/hax11.so
export ETC_PROFILE_HAX11_LOADED=1
> echo $ETC_PROFILE_HAX11_LOADED
1
> echo $LD_PRELOAD
# empty
Strange. I don't know why.
What about other apps?
What about other apps?
The log is not created at all
> cat ~/.config/hax11/profiles/default
Enable=1
NoPrimarySelection=1
Debug=1
> ll /tmp/hax11.log
/bin/ls: cannot access '/tmp/hax11.log': No such file or directory
I'll try to grep LD_PRELOAD=
in system files
> cat /etc/profile.d/hax11.sh export LD_PRELOAD=/usr/local/\$LIB/hax11.so export ETC_PROFILE_HAX11_LOADED=1 > echo $ETC_PROFILE_HAX11_LOADED 1 > echo $LD_PRELOAD # empty
That is interesting - I guess it's blacklisted by something.
I found this: linuxmint/cinnamon-session#15
There is a suggestion to use .xsessionrc
.
I tried ~/.xsessionrc
(see the opening message #6 (comment)).
And now I also tried ~/.xinitrc
as linuxmint/cinnamon-session#15 (comment) advices and there is some luck, thanks! Looks like hax11.so
was loaded for some apps on boot:
> tail /tmp/hax11.log
[4398] Server connection setup reply: 1
[15632] Found X connection!
[15632] Intercepting X connection!
[15632] Server connection setup reply: 1
[15632] Selection atom: 359
[15632] Selection atom: 322
[15632] Found X connection!
[15632] Intercepting X connection!
[15632] Server connection setup reply: 1
[15632] Exiting work thread.
But not for apps when I start them from the run dialog (alt+F2
)....
Terminal emulator doesn't see LD_PRELOAD
variable either.
OK. I suggest seeking support from your distribution. Unfortunately I don't know Linux Mint, and LD_PRELOAD being unset by other software is not really a bug in hax11.
Let's keep this issue open to continue the discussion for a better way to install hax11 system-wide.
Added debug exports LOADED_*
variables to most known configs
Terminal emulator:
> env | grep LOADED
LOADED_ZSHRC=1
LOADED_ETC_PROFILE_HAX11=1
LOADED_PROFILE=1
LOADED_XSESSIONRC=1
LD_PRELOAD
is being set only from ~/.zshrc
textadept app (started from alt+F2
):
> cat /proc/$(pgrep textadept | head -1)/environ | xargs -0 -n 1 echo | grep LOADED
LOADED_PROFILE=1
LOADED_ETC_PROFILE_HAX11=1
LOADED_XSESSIONRC=1
LD_PRELOAD
is never set.
~/.xinitrc
is not loaded at all, that was my mistake.
Created thread on Linux Mint forum
I'll close this as it can't be fixed by a change to this repository. Hopefully someone can figure out how to set environment variables in Linux Mint / Cinnamon.