Main menu:

Sponsoring

Please consider a small donation:

 

Also appreciated: support me by clicking the ads (costs nothing) :-)

 

Or you can donate bitcoin:

 

Thanks to TekLinks in Birmingham, AL, for providing colocation and bandwidth.

Page Rank

Fame

FOSS Force Best Blog--2013 Award

Recent posts

Recent comments

About this blog

I am Eric Hameleers, and this is where I think out loud.
More about me.

Search

My Favourites

Slackware

Calendar

September 2014
M T W T F S S
« Aug    
1234567
891011121314
15161718192021
22232425262728
2930  

RSS Alien's Slackware packages

RSS Alien's unofficial KDE Slackware packages

RSS Alien's multilib packages

Meta

Running VLC in XFCE

As you may know I am using KDE for my daily work. However, I use XFCE from time to time – for example when I have to run a remote X session over XDMCP and want to keep a fluid feel to the desktop.

When I was working in XFCE yesterday I wanted to use VLC to check a video file on my computer, and I was in for a surprise when clicking “Media > Open file” made my VLC hang indefinitely!

I remembered a discussion about this phenomenon on LinuxQuestions.org and indeed the solution as pointed out in that thread works for me.

What happens here?

The core of the issue, is that Qt4 makes an incorrect assumption about which GTK+ theme engine to use. A GTK+ theme engine makes a Qt4 application blend in nicely with a GTK+ based desktop environment such as XFCE, by using GTK+ instead of Qt4 to render all graphical components.

There are a few GTK+ theme engines available – one of them is QGtkStyle which is part of Qt4 in Slackware. However, Qt4 libraries look at the environment variable “GTK2_RC_FILES” in order to find out how to configure the GTK theme engine.

If this environment variable is not (or incorrectly) set, then Qt4 assumes that GTK+ is using GTK-QT-Engine which is not part of Slackware (GTK-QT-Engine is used to give GTK appplications a Qt feel when they are running in KDE) and it will not correctly apply the QGtkStyle engine. It sets QGtkStyle to use the GTK style Clearlooks, and outputs an error message which you will sometimes be able to see if you started a Qt-based application from a terminal:

QGtkStyle cannot be used together with the GTK_Qt engine.

This can be solved by explicitly telling Qt4 where Slackware keeps its GTK+ configuration files, and then making sure a GTK+ theme is configured there.

  • Define the environment variable “GTK2_RC_FILES” in one of these files: ${HOME}/.xinitrc (applies to just you) or in /etc/profile.d/qt4.sh (applies system-wide) by adding the follwing two lines to that file (assuming you are using bash as your default shell):
    GTK2_RC_FILES="$HOME/.gtkrc-2.0:/etc/gtk-2.0/gtkrc"
    export GTK2_RC_FILES
  • Create a new file (or edit the existing) ${HOME}/.gtkrc-2.0 (so that the GTK theme applies to just you) or /etc/gtk-2.0/gtkrc (so that it applies system-wide) and add the following line to it:
    gtk-theme-name="GTK+"

That should fix VLC’s “Media > File Open” dialog which will now appear instantly.

Note: You can choose a GTK+ theme for all your QT4 based applications if you want by running “qtconfig” and in the tab “Appearance” set the “Select GUI Style” to “GTK+” instead of “Desktop Settings (default)“.

Eric

GTK2_RC_FILES

Comments

Comment from Lysender
Posted: August 27, 2010 at 11:14

Now you got it. I never make it work while following the LQ thread.

Comment from grissiom
Posted: August 27, 2010 at 12:13

s,/etc/profile.d/qt4/sh,/etc/profile.d/qt4.sh,

;)

Comment from alienbob
Posted: August 27, 2010 at 13:27

Oops… updated. Thanks grissiom.

Eric

Comment from escaflown
Posted: September 2, 2010 at 02:37

Hi Eric. I got this message while installing the i486 slackbuild of tigervnc: “install/doinst.sh: line 12: warning: here-document at line 7 delimited by end-of-file (wanted EOT’)”

Comment from alienbob
Posted: September 2, 2010 at 08:33

Hi escaflown, thanks for the report. I have fixed the install script and will upload new packages soon,

Eric

Pingback from TexMaker Qt problems in XFCE
Posted: September 3, 2010 at 12:16

[...] slackbuild. There is a problem with QT, but is the same error that eric solved for VLC. SO follow this to solve the [...]

Comment from Olaus
Posted: September 6, 2010 at 09:42

cat .xinitrc
GTK2_RC_FILES=”$HOME/.gtkrc-2.0:/etc/gtk-2.0/gtkrc”
export GTK2_RC_FILES

cat .gtkrc-2.0
gtk-theme-name=”GTK+”

Still doesn’t work (i. e., vlc hangs on open file in xfce). I also tried sh .xinitrc before running vlc (it is executable, but just in case…).

Comment from Olaus
Posted: September 9, 2010 at 06:42

It seems to work though, if I put the .xinitrc stuff in /etc/profile.d/qt4.sh (and I also chose GTK+ in vlc, that might have helped too). Thanks!

Comment from Robby Workman
Posted: September 24, 2010 at 02:32

Two thoughts here:
1) it’s /etc/gtk-2.0/$ARCH-slackware-linux/gtkrc
2) would gtk-engines addition (which includes ClearLooks) solve this without any other changes?

Comment from Robby Workman
Posted: September 24, 2010 at 05:10

I’ll answer #2 – no.
We definitely need to add the snippets to the gtk profile scripts, and perhaps ship a “default” gtkrc file in /etc/gtk-2.0/$ARCH-slackware-linux

Comment from Robby Workman
Posted: December 21, 2010 at 04:46

Okay, we’ve put things back in the “right” places now.
/etc/gtk-2.0/gtkrc is *the* location now, and we don’t set GTK2RC_FILES in the profile scripts, and everything should still work just fine now.

Comment from voltron
Posted: April 10, 2011 at 18:34

I’m running Slackware 13.1 with Openbox as WM (no KDE installed). Tried to setup QGtkStyle to use GTK themes but without success.
Adding export GTK2_RC_FILES=”$HOME/.gtkrc-2.0″ to ~/.profile don’t help, I always get “QGtkStyle was unable to detect the current GTK+ theme.”

Pingback from Problem with uniform look for Qt and GTK apps
Posted: April 12, 2011 at 19:57

[...] check AlienBob's blog: http://alien.slackbook.org/blog/running-vlc-in-xfce/ [...]

Pingback from xfce themes and other spices?
Posted: June 8, 2011 at 16:00

[...] Hi all, is there a way to make the kde apps look exactly like the gtk apps? This post will sort you [...]

Comment from Andre Lucas
Posted: June 25, 2011 at 05:58

Thanks! You’re the man!

Pingback from best xfce native library music player?
Posted: May 17, 2012 at 10:06

[...] and if you want your QT4 programs to inherit your GTK settings, check this post by alienbob: http://alien.slackbook.org/blog/running-vlc-in-xfce/ there you go. QT4 apps will look [...]

Pingback from QT4 apps and GTK2 « slackalaxy
Posted: June 8, 2012 at 15:19

[...] Read AlienBob’s blog regularly [...]

Comment from madPenguin
Posted: September 25, 2012 at 18:44

If you startx using .xinitrc, then you have to add the above fix before the startx:
cat .xinitrc
GTK2_RC_FILES=”/home/penguin/.gtkrc-2.0″
export GTK2_RC_FILES
exec ck-launch-session startxfce4

Write a comment