# QT_QPA_PLATFORMTHEME cannot be set to qt5ct



## Deleted member 67862 (Mar 26, 2022)

Greetings,

For several months I've tried to get qt5ct to be configured correctly by having QT_QPA_PLATFORMTHEME set to qt5ct. It seems to not work through any of the methods:

Putting QT_QPA_PLATFORMTHEME (variable) in /etc/profile
Putting the variable in .tcshrc (I use tcshrc)
Putting the variable in csh, tcsh, and sh rc's (translated to what they use to set environment variables of course)
Putting the variable in ~/.profile
Adding `sh -c "QT_QPA_PLATFORMTHEME=qt5ct"` to Xfce startup

Some of the ones above only work for qt programs launched from the terminal. Other ones don't work at all. I've circumvented this issue entirely by using icewm because it has an "env" file where you can add this environment variable. However, I'm using Xfce and can't rely on that file anymore. So I'm either glued to using icewm or just not having qt5 programs adhere at all to my gtk theme. Does anyone happen to know a solution?


----------



## Alexander88207 (Mar 26, 2022)

In XFCE i do have put 
	
	



```
QT_QPA_PLATFORMTHEME=qt5ct;      export QT_QPA_PLATFORMTHEME
```
 in ~/.profile and it works for me.


----------



## Alexander88207 (Mar 26, 2022)

If everything seems to fail (Which is kind of weird) for you can do modify the xfce session file /usr/local/share/xsessions/xfce.desktop
which is a dirty way but this should work then.

Note that this file can be overwritten by updates or re-installation of the xfce4-session package.


----------



## Alexander88207 (Mar 26, 2022)

hunter0one said:


> I'm using Xfce and can't rely on that file anymore.



You can. The command that you should write in that file should be `startxfce4` then.


----------



## Deleted member 67862 (Mar 26, 2022)

Alexander88207 said:


> In XFCE i do have put
> 
> 
> 
> ...


Weird, I have this exact same thing but it's not working. Im using xdm to launch xfce if that matters.


```
....

EDITOR=ee;       export EDITOR
PAGER=less;      export PAGER

# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV

# Set qt5 to use qt5ct
QT_QPA_PLATFORMTHEME=qt5ct; export QT_QPA_PLATFORMTHEME
```


----------



## Deleted member 67862 (Mar 26, 2022)

Alexander88207 said:


> You can. The command that you should write in that file should be `startxfce4` then.


You must be thinking of .xsession / .xinitrc. Icewm has a special ~/.icewm/env file you can make which will set the environment variable for icewm itself.


----------



## Alexander88207 (Mar 26, 2022)

hunter0one said:


> Weird, I have this exact same thing but it's not working. Im using xdm to launch xfce if that matters.
> 
> 
> ```
> ...



Maybe its related to the display manager?

What happens if you try lightdm?


----------



## covacat (Mar 26, 2022)

export it in .xsession if you use xdm
check running process env with ps -ewww


----------



## Deleted member 67862 (Mar 26, 2022)

Alexander88207 said:


> Maybe its related to the display manager?
> 
> What happens if you try lightdm?


Lightdm gives me a black screen.



covacat said:


> export it in .xsession if you use xdm
> check running process env with ps -ewww


It's just showing tcsh really:


```
hunter@mybsdpc:~ % env ps -ewww
  PID TT  STAT    TIME COMMAND
50025 v1  I+   0:00.01  -tcsh (tcsh)
55939  0  Ss   0:00.05  -tcsh (tcsh)
56800  0  R+   0:00.00  ps -ewww
```

My .xsession is now:

```
QT_QPA_PLATFORMTHEME=qt5ct; export QT_QPA_PLATFORMTHEME
startxfce4
```
But no difference


----------



## Alexander88207 (Mar 26, 2022)

hunter0one said:


> Lightdm gives me a black screen.



When starting lightdm or when login to the xfce session?


----------



## Deleted member 67862 (Mar 26, 2022)

Alexander88207 said:


> When starting lightdm or when login to the xfce session?


When starting lightdm. It did not have an entry in /etc/ttys so I added lightdm_enable=YES in rc.conf and got a black screen when starting up.


----------



## Alexander88207 (Mar 26, 2022)

hunter0one said:


> When starting lightdm. It did not have an entry in /etc/ttys so I added lightdm_enable=YES in rc.conf and got a black screen when starting up.



Do you have lightdm-gtk-greeter installed?


----------



## covacat (Mar 26, 2022)

use ps -ewwwx to show background processes


----------



## Deleted member 67862 (Mar 26, 2022)

Alexander88207 said:


> Do you have lightdm-gtk-greeter installed?


Yes



covacat said:


> use ps -ewwwx to show background processes


I did:

```
hunter@mybsdpc:~ % env ps -ewww
  PID TT  STAT    TIME COMMAND
50025 v1  I+   0:00.01  -tcsh (tcsh)
55939  0  Ss   0:00.05  -tcsh (tcsh)
56800  0  R+   0:00.00  ps -ewww
```


----------



## covacat (Mar 26, 2022)

weird no env is shown

```
titus@hpbsd:~ % ps -ewww -p $$
  PID TT  STAT    TIME COMMAND
29413  1  Ss   0:00.02 USER=titus LOGNAME=titus HOME=/home/titus MAIL=/var/mail/titus PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/titus/bin TERM=xterm-256color BLOCKSIZE=K MM_CHARSET=UTF-8 LANG=C.UTF-8 SHELL=/bin/tcsh SSH_CLIENT=10.1.1.1 15844 22 SSH_CONNECTION=10.1.1.1 15844 10.1.1.177 22 SSH_TTY=/dev/pts/1 -tcsh (tcsh)
titus@hpbsd:~ %
```


----------



## Deleted member 67862 (Mar 26, 2022)

`env` shows a bunch of variables, but they just arent showing up in `ps`. Everything is normal in xfce terminal. Now I don't understand why I don't see all that in `ps`


----------



## covacat (Mar 26, 2022)

do you have any 'hardening' stuff in sysctl.conf ?


----------



## Deleted member 67862 (Mar 26, 2022)

covacat said:


> do you have any 'hardening' stuff in sysctl.conf ?


Actually I do, I picked all the hardening options as per Robonuggie suggested.

security.bsd.see_other_uids=0
security.bsd.see_other_gids=0
security.bsd.see_jail_proc=0
security.bsd.unprivileged_read_msgbuf=0
security.bsd.unprivileged_proc_debug=0
kern.randompid=1


----------



## covacat (Mar 26, 2022)

sysctl security.bsd.unprivileged_proc_debug=1
turn this to 1


----------



## Deleted member 67862 (Mar 26, 2022)

covacat said:


> sysctl security.bsd.unprivileged_proc_debug=1
> turn this to 1


`ps` now shows a lot but still nothing about QT_QPA_PLATFORMTHEME.


----------



## T-Daemon (Mar 27, 2022)

Try copy /usr/local/etc/xdg/xfce4/xinitrc to ~/.config/xfce4/ and export the environment variable there.


----------



## Deleted member 67862 (Mar 27, 2022)

T-Daemon said:


> Try copy /usr/local/etc/xdg/xfce4/xinitrc to ~/.config/xfce4/ and export the environment variable there.


Hey that did it. Thanks!


----------



## bsduck (Apr 1, 2022)

hunter0one said:


> Im using xdm to launch xfce if that matters.


It does. Some time ago I noticed XDM doesn't care about ~/.profile if you don't tell it to.

I recommend you to add `. ~/.profile` to your ~/.xsession, it may save you other issues.


----------

