PCMan / gtk3-nocsd

A hack to disable gtk+ 3 client side decoration
GNU Lesser General Public License v2.1
320 stars 41 forks source link

Fluxbox + Evince GTK still no decorations #6

Closed ironchicken closed 9 years ago

ironchicken commented 9 years ago

I use Fluxbox (1.3.5-2) and Evince-GTK (3.14.1-1) with libgtk (3.14.5-1) on Debian unstable, all three installed from debs in the Debian archive. I've compiled gtk-nocsd and put the .so in /usr/local/lib, added the GTK_CSD=0 and LD_PRELOAD=/usr/local/lib/gtk3-nocsd.so environment variables, but Evince still has no decorations.

Any ideas why this isn't working for Evince? Or whether it should?

I haven't tested any other GTK applications; I've actually not come across any others that I use that suffer from this CSD problem.

cassiodoroVicinetti commented 9 years ago

For some reason, LD_PRELOAD doesn't appear to be listed under:

export -p

I solved by manually prepending those variables, e.g. for Evince:

GTK_CSD=0 LD_PRELOAD=/usr/local/lib/gtk3-nocsd.so evince

chris-se commented 9 years ago

Note that if you set environment variables in your .xsessionrc or some other POSIX shell sourced file (like .profile), you need to prepend export: export GTK_CSD=0 LD_PRELOAD=... Otherwise it's only going to be a shell variable, but not an environment variable. (This is not true for direct calls where doing VAR=value program will temporarily set the environment variable for just that program.)

Since this doesn't appear to be a bug in gtk3-nocsd, closing this issue.

cassiodoroVicinetti commented 9 years ago

I made further attempts, but still no luck.

Into my "~/.profile" I put:

export LD_PRELOAD="/usr/lib/gtk3-nocsd/gtk3-nocsd.so"
export GTK_CSD=0

but oddly only GTK_CSD was actually exported, while LD_PRELOAD disappeared.

Putting the exports into my "~/.bashrc" solves the issue, but only if I start Evince from the bash shell.

$ export -p | grep 'PRELOAD\|CSD'
declare -x GTK_CSD="0"

$ apt-cache policy gtk3-nocsd
gtk3-nocsd:
  Installed: 1.0.0-1~webupd8~vivid1
  Candidate: 1.0.0-1~webupd8~vivid1
  Version table:
 *** 1.0.0-1~webupd8~vivid1 0
        500 http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu/ vivid/main amd64 Packages
        100 /var/lib/dpkg/status

$ apt-cache policy libgtk-3-0
libgtk-3-0:
  Installed: 3.16.6-1
  Candidate: 3.16.6-1
  Version table:
 *** 3.16.6-1 0
        990 http://ftp.it.debian.org/debian/ testing/main amd64 Packages
        100 /var/lib/dpkg/status

$ apt-cache policy evince
evince:
  Installed: 3.18.0-1
  Candidate: 3.18.0-1
  Version table:
 *** 3.18.0-1 0
        990 http://ftp.it.debian.org/debian/ testing/main amd64 Packages
        100 /var/lib/dpkg/status

$ uname -a
Linux debian-luca 4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) x86_64 GNU/Linux
chris-se commented 9 years ago

Ok, so you are relying on the fact that .profile is sourced by the Xsession logic and that environment variables are imported from there.

The problem is that some things that are started by the Xsession logic get rid of the LD_PRELOAD environment variable, ssh-agent for example (but maybe also others).

To avoid this problem, create a file /etc/X11/Xsession.d/70propagate-LD_PRELOAD with the following contents (this works on Debian/Ubuntu, don't know about other distros and how they integrate this sort of thing, YMMV there):

# This file is sourced by Xsession(5), not executed.

# Some other startup programs may drop LD_PRELOAD as environment
# variable (ssh-agent is known for this), so make sure it's set
# explicitly again AFTER ssh-agent has been called.
if [ -n "$LD_PRELOAD" ] ; then
    STARTUP="env LD_PRELOAD=$LD_PRELOAD $STARTUP"
fi

The name of the file is not important, other than it should start with 70 (so that it's late enough that logic that tries to detect which desktop environment is going to be started is not going to be confused by the new STARTUP value - but also that it's early enough that the env call is prepended as one of the first things so that when ssh-agent and other programs are prepended later, they will still call env to set LD_PRELOAD again).

Hope that helps.

cassiodoroVicinetti commented 9 years ago

Thank you very much, it works like a charm! Indeed I was running ssh-agent, so this may be the reason variable LD_PRELOAD was cleared out.

cassiodoroVicinetti commented 9 years ago

Unfortunately I had to remove this configuration because it has severe side effects on other GTK applications, see this bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801350 so sadly my alternative remains to put LD_PRELOAD directly into the command to launch Evince.