Easy change between light and dark themes

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
User avatar
richb
Administrator
Posts: 10322
Joined: Wed Jul 12, 2006 2:17 pm

Easy change between light and dark themes

#1 Post by richb »

I was having difficulty with some applications and a dark theme, particularly with Libreoffice Calc. The colors i applied to charts and other element render in black and gray. Trying to adjust colors with Calc Preferences had no effect and some "fixes" offered on the Net did not work well.
So I created two launchers and put them in the panel for a quick theme change to light when I run Libreoffice. The commands change to light or dark themes and can be executed before or after opening Libreoffice.

For the light theme the command is:

Code: Select all

xfconf-query -c xsettings -p /Net/ThemeName -s "Greybird-mx17"
And for the Dark Theme:

Code: Select all

xfconf-query -c xsettings -p /Net/ThemeName -s "Arc-Dark"
Of course you can change the theme name to any of the installed themes on your system.

I can now toggle between light and dark themes easily with one click rather than going through the XFCE settings dialog requiring several actions to open the Appearance dialog, scrolling to the theme, choosing it and reversing the choice when done with the troublesome application.
Forum Rules
Guide - How to Ask for Help

richb Administrator
System: MX 23 KDE
AMD A8 7600 FM2+ CPU R7 Graphics, 16 GIG Mem. Three Samsung EVO SSD's 250 GB

User avatar
mrfebruary
Posts: 4
Joined: Wed Apr 04, 2007 9:03 pm

Re: Easy change between light and dark themes

#2 Post by mrfebruary »

Wow. Cool!
1 HP Probook 6550b, Intel Core i5 M 540 3747.6MB, 4.10.5-antix.3-amd64-smp x86_64, MX-17_x64 Horizon
2 Latitude 1300, Pentium M 2048MB DDR, Intel Mobile 915G, BCM4401-B0, 2.6.32-1-mepis-smp i686, Trinity DE 3.5.12 MEPIS 8.5 Lenny

bwhawk
Posts: 57
Joined: Mon Mar 19, 2018 8:26 am

Re: Easy change between light and dark themes

#3 Post by bwhawk »

Thank you for posting this. This is an elegant solution that never would have occurred to me.

User avatar
richb
Administrator
Posts: 10322
Joined: Wed Jul 12, 2006 2:17 pm

Re: Easy change between light and dark themes

#4 Post by richb »

Glad you find it useful.
Forum Rules
Guide - How to Ask for Help

richb Administrator
System: MX 23 KDE
AMD A8 7600 FM2+ CPU R7 Graphics, 16 GIG Mem. Three Samsung EVO SSD's 250 GB

User avatar
fehlix
Developer
Posts: 10309
Joined: Wed Apr 11, 2018 5:09 pm

Re: Easy change between light and dark themes

#5 Post by fehlix »

Thanks @richb. Indeed very usefull!
Here is little “Switch Theme Button” which I do now have placed on my pannel.
It’s a bit bash-hash magic to do switch. Here it goes…

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=Switch Theme
Comment=Switch between dark and light themes
# by fehlix:
# based on the idea by richb
# https://forum.mxlinux.org/viewtopic.php?f=23&t=44584#
# Light
# Exec=xfconf-query -c xsettings -p /Net/ThemeName -s "Greybird-mx17"
# Dark
# Exec=xfconf-query -c xsettings -p /Net/ThemeName -s "Arc-Dark"
Exec=bash -c 'A=Arc-Dark;B=Greybird-mx17;declare -A T;T=([$A]=$B [$B]=$A);tn() { xfconf-query -c xsettings -p /Net/ThemeName "$@";};tn -s ${T[$(tn)]}'
Icon=view-private
Path=
Terminal=false
StartupNotify=false
Categories=XFCE;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-PersonalSettings;
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
richb
Administrator
Posts: 10322
Joined: Wed Jul 12, 2006 2:17 pm

Re: Easy change between light and dark themes

#6 Post by richb »

Thanks. I have two buttons on the panel one for dark and one for light. Your solution is a nice refinement.
Forum Rules
Guide - How to Ask for Help

richb Administrator
System: MX 23 KDE
AMD A8 7600 FM2+ CPU R7 Graphics, 16 GIG Mem. Three Samsung EVO SSD's 250 GB

balarm
Posts: 147
Joined: Thu Dec 07, 2017 3:15 pm

Re: Easy change between light and dark themes

#7 Post by balarm »

@richb fantastic work, thank you.
@fehlix could you explein step by step how to insert your code in the Switch Button?? Thanks a lot.
mx Kernel: 4.19.0-6-amd64 x86_64 bits: 64 Desktop: Xfce 4.14.2
Distro: MX-19.3x64 patito feo October 21 2019
Machine: Type: Laptop System: LENOVO product: 1951A47 v: ThinkPad T60

User avatar
oops
Posts: 1602
Joined: Tue Apr 10, 2018 5:07 pm

Re: Easy change between light and dark themes

#8 Post by oops »

Thanks this .desktop file completes my customization with redshift-gtk.
Pour les nouveaux utilisateurs: Alt+F1 pour le manuel, ou FAQS, MX MANUEL, et Conseils Debian - Info. système “quick-system-info-mx” (QSI) ... Ici: System: MX-19_x64 & antiX19_x32

User avatar
fehlix
Developer
Posts: 10309
Joined: Wed Apr 11, 2018 5:09 pm

Re: Easy change between light and dark themes

#9 Post by fehlix »

balarm wrote:@richb fantastic work, thank you.
@fehlix could you explein step by step how to insert your code in the Switch Button?? Thanks a lot.
All are right - I should have been more explicit in spelling this out.

OK. here it goes - one way of doing this.
Create a empty file on the Desktop by right-click'ng
on an empty space on the Desktop - let's call it "switch-theme.desktop".
So your empty file has the name "switch-theme.desktop".

Right click and open that empty file within FeatherPad.
Now Copy'n'Paste the code above into FeatherPad.
Save the file and exit FeatherPad.
You can click (or double click resp.) onto the file
and get ask for mark the file executable which you should confirm.
Now - one (quick) way of placing the icon-button onto the panel
would be by Drag'n'Drop the icon onto the panel.

Another more permanent way would be to copy the desktop-file
"switch-theme.desktop" into you private application folder
( which is unter you home-folder the "hidden" folder .local/share/applications)
To see the "hidden" folder within the file-manager press CTRl-h
to hide/unhide the "hidden" folders)
By placing the "switch-theme.desktop" into the
~/.local/share/applications the menu-magic happens:
You'll find a new "Switch Theme" button with the
Menu under Settings.
So now whenever you want to place that button on the panel
you right-click with the Settings-Menu in the button and
"Add to Panel".

Happy switching ;=)
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
Richard
Posts: 1577
Joined: Fri Dec 12, 2008 10:31 am

Re: Easy change between light and dark themes

#10 Post by Richard »

Ahh, that's cool.
I've been doing it the hard way for years!
Thinkpad T430 & Dell Latitude E7450, both with MX-21.3.1
kernal 5.10.0-26-amd64 x86_64; Xfce-4.18.0; 8 GB RAM
Intel Core i5-3380M, Graphics, Audio, Video; & SSDs.

Post Reply

Return to “Tips & Tricks by users”