this post was submitted on 05 Mar 2024
8 points (100.0% liked)

techsupport

2477 readers
119 users here now

The Lemmy community will help you with your tech problems and questions about anything here. Do not be shy, we will try to help you.

If something works or if you find a solution to your problem let us know it will be greatly apreciated.

Rules: instance rules + stay on topic

Partnered communities:

You Should Know

Reddit

Software gore

Recommendations

founded 1 year ago
MODERATORS
 

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

exec ~/.config/i3/scripts/qt6ct.sh
exec source ~/.config/i3/scripts/qt6ct.sh

I don't know what's wrong with it, but if I run it on a terminal, I get this (screenshot):

➤ ~/.config/i3/scripts/qt6ct.sh 
i3
qt5ct
➤ echo "$QT_QPA_PLATFORMTHEME"
                    
➤

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 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 9 months ago (4 children)

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.

[–] Moshpirit 2 points 9 months ago (3 children)

Ok, something happened: adding it to .bash_profile did change QT_QPA_PLATFORMTHEME on i3 (whoohooo \o/), BUT it also did on plasma (ouch 😢), so the script for some reason is not returning what is supposed to.

[–] [email protected] 2 points 9 months ago (2 children)

Paste what you've got so far and I'll look at it some more.

[–] Moshpirit 2 points 9 months ago* (last edited 9 months ago) (1 children)

I think I figured it out, I created a .xprofile file and moved all the env stuff there:

➤ cat .xprofile
source ~/.config/i3/scripts/qt6ct.sh
export QT_SCREEN_SCALE_FACTORS=1.45 # 1.5
export QT_AUTO_SCREEN_SCALE_FACTOR=0 # 0

Now dolphin uses breeze themes, thunar uses its gtk version and also found out about how to fix the zoom issue (it was supposed to be another different battle but seems like they have more in common than what I thought!)

Thank you so much for helping me all the way here!! :)

Correction: I didn't entirely fix it!

There's a couple of stuff to be fixed: screenshot

  • calendar widget looks huge
  • dolphin space/zoom status are not blue, but black.
  • probably other stuff to be discovered

Which means that in Plasma QT_QPA_PLATFORMTHEME is still read as qt5ct :(

Correction 2: I FIXED IT!!

remove everything from .xprofile except 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_AUTO_SCREEN_SCALE_FACTOR 
[–] [email protected] 2 points 9 months ago

Haha, that's great! That post was like a rollercoaster.