How to correctly set QT_QPA_PLATFORMTHEME according to the WM I'm using? My script doesn't seem to work
I created this script at ~/.config/i3/scripts/qt6ct.sh to set QT_QPA_PLATFORMTHEME depending on whether I'm using Plasma or I3wm:
#!/bin/bash
CURRENT_DESKTOP=$(echo "$XDG_CURRENT_DESKTOP")
if [ "$CURRENT_DESKTOP" = "i3" ]; then
export QT_QPA_PLATFORMTHEME="qt5ct"
elif [ "$CURRENT_DESKTOP" = "KDE" ]; then
# Si estás usando Plasma (KDE), comentar la línea que exporta la variable
unset QT_QPA_PLATFORMTHEME
else
echo "Gestor de ventanas no es i3 ni kwin: $CURRENT_DESKTOP"
fi
echo $CURRENT_DESKTOP
echo $QT_QPA_PLATFORMTHEME
I created an autostart program and added this to my i3 config file
So this script doesn't really export anything at all.
I have searched on every file that I thought could be exporting it as a null value (~/.bashrc, ~/.profile, ~/.bash_profile, ~/.xinitrc, ~/.Xresources, /etc/environment, /root/.profile, /root/.bashrc), but everything looks fine (no QT_QPA_PLATFORMTHEME anywhere, or is commented).
Solution
The only thing we'll need in.xprofile is sourcing the script:
#!/bin/bash
CURRENT_DESKTOP=$(echo "$XDG_CURRENT_DESKTOP")
if [[ "$CURRENT_DESKTOP" = "i3" ]]; then
export QT_QPA_PLATFORMTHEME="qt5ct"
export QT_SCREEN_SCALE_FACTORS=1.5 # 1.5
export QT_AUTO_SCREEN_SCALE_FACTOR=0
elif [[ "$CURRENT_DESKTOP" = "KDE" ]]; then
unset QT_QPA_PLATFORMTHEME
export QT_AUTO_SCREEN_SCALE_FACTOR=1
else
echo "Gestor de ventanas no es i3 ni kwin: $CURRENT_DESKTOP"
fi
echo $CURRENT_DESKTOP
echo $QT_QPA_PLATFORMTHEME
echo $QT_SCREEN_SCALE_FACTORS
echo $QT_AUTO_SCREEN_SCALE_FACTOR
I added source ~/.config/i3/scripts/qt6ct.sh at .profile, and logout. When I logged in, nothing has changed. I don't know why, since when I manually run it, it apparently changes the value of QT_QPA_PLATFORMTHEME.
After doing all of that, Qt apps doesn't seem affected at all, when I open the qt5ct application from Rofi, it keeps showing me the same warning (something like: The QT_QPA_PLATFORMTHEME environment variable has not been set (required values: qt5ct or qt6ct)).
AFTER I do all of this, if I run qt5ct or run rofi --show -drun and then select the qt5ct app, then it works just fine. The same happens with dolphin: if I run it from rofi, then it looks awful, but if I run it from the terminal, it looks great. BUT if I close the terminal and open it again, everything goes back to normal (meaning: awful).
After including source ~/.config/i3/scripts/qt6ct.sh to /etc/environment and rebooting to see if anything changed: nope. No changes, the problem persists.
OK, I have neither qt apps, nor other desktops, so I'm kind of shooting in the dark. I seem to remember reading that .profile is sometimes not looked at and it's better to put in .bash_profile or even paste it into your .bashrc and see you still have the issue.