Linux Mint Cinnamon System-wide dark mode switch (incl Flatpak)

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
random0
Level 1
Level 1
Posts: 24
Joined: Mon Feb 28, 2022 10:11 am

Linux Mint Cinnamon System-wide dark mode switch (incl Flatpak)

Post by random0 »

Now that I'm using Mint Cinnamon again, I've decided to upgrade the flatpak dark mode switch. Though in this case, this is specifically for Mint Cinnamon.

Save this to a file called "prep.sh" (wherever you want)

Code: Select all

#!/bin/bash
# DO NOT RUN AS SUDO !!!!!

# QT THEME

# QT5ct and Kvantum work together. Set qt5ct to Kvantum, and then you can easiely change Kvantum theme, which affects the all QT apps). This is for non-flatpak apps.
sudo apt update
sudo apt -yqq install qt5-style-kvantum
clear
printf "Change style (top left) to kvantum, click apply (wait to apply), click ok.\nScript will continue after that, so don't close the terminal.\n"
qt5ct > /dev/null 2>&1

clear
printf "\nInstall the one with the longest (not the latest) version - in my case it was 5.15-21-08\n\n"
# This installs the QT style Adwaita directly to flatpak (because syncing flatpak to kvantum would be a pain)
flatpak install org.kde.KStyle.Adwaita
clear

# GTK THEME

# When it comes to the gtk theme, flatpak can be easiely set to use the system one
mkdir -p ~/.themes
cp -r "/usr/share/themes/Adwaita-dark" "$HOME/.themes/Adwaita-dark"
cp -r "/usr/share/themes/Adwaita" "$HOME/.themes/Adwaita"
sudo flatpak override --filesystem=$HOME/.themes


# WINDOW DECORATIONS
wget -O "cblack.zip" "https://cinnamon-spices.linuxmint.com/files/themes/CBlack.zip"
mv "cblack.zip" "$HOME/.themes"
cd "$HOME/.themes"
unzip "cblack.zip"
rm "cblack.zip"

clear
echo "SCRIPT FINISHED"
To run it, open a terminal in the folder you saved it in and type:

Code: Select all

bash prep.sh
There will be instructions within the terminal (when qt5ct is opened etc.)



Then put this into a file called "system-wide-theme-switcher.desktop" and save it to ~/.local/share/applications

Code: Select all

[Desktop Entry]
Type=Application
Terminal=false
Name=System-wide Theme Switcher
Icon=preferences-desktop
Exec=gnome-terminal --title "System-wide Theme Switcher" -- sh -c 'while [ 1 -eq 1 ]; do echo "Press 1 for light theme, 2 for dark theme and hit enter"; read userInput; userInput=$(echo "$userInput" | xargs); if [ "$userInput" -eq "1" ]; then theme="Adwaita"; kvTheme="KvGnome"; winDecorTheme="Mint-Y"; elif [ "$userInput" -eq "2" ]; then theme="Adwaita-dark"; kvTheme="KvGnomeDark"; winDecorTheme="CBlack"; else clear; echo "Invalid input, try again"; continue; fi; gsettings set org.cinnamon.desktop.interface gtk-theme $theme; kvantummanager --set $kvTheme > /dev/null 2>&1; sudo flatpak override --env=GTK_THEME=$theme; sudo flatpak override --env=QT_STYLE_OVERRIDE=$theme; gsettings set org.cinnamon.desktop.wm.preferences theme $winDecorTheme; clear; printf "OPERATION COMPLETE\nQT-based apps need to restart for the change to take effect.\n"; done;'

Then when you search your applications, it should show up, and just follow the instructions.
Post Reply

Return to “Tutorials”