Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

Easy change between light and dark themes

Just as the name says, here is where you can post tips and tricks to share with other users of MEPIS.
Message
Author
User avatar
richb
Administrator
Posts: 16625
Joined: Wed Jul 12, 2006 2:17 pm

Easy change between light and dark themes

#1 Post by richb » Thu Mar 22, 2018 12:14 pm

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

Rich
SSD Production: MX 17.1
AMD A8 7600 FM2+ CPU R7 Graphics, 16 GIG Mem. Three Samsung EVO SSD's 250 GB, 350 GB HD

User avatar
mrfebruary
Forum Novice
Forum  Novice
Posts: 28
Joined: Wed Apr 04, 2007 9:03 pm

Re: Easy change between light and dark themes

#2 Post by mrfebruary » Thu Apr 05, 2018 12:47 am

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
Forum Novice
Forum  Novice
Posts: 13
Joined: Mon Mar 19, 2018 8:26 am

Re: Easy change between light and dark themes

#3 Post by bwhawk » Sat Apr 21, 2018 7:42 am

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

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

Re: Easy change between light and dark themes

#4 Post by richb » Sat Apr 21, 2018 7:53 am

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

Rich
SSD Production: MX 17.1
AMD A8 7600 FM2+ CPU R7 Graphics, 16 GIG Mem. Three Samsung EVO SSD's 250 GB, 350 GB HD

User avatar
fehlix
Forum Regular
Forum Regular
Posts: 305
Joined: Wed Apr 11, 2018 5:09 pm

Re: Easy change between light and dark themes

#5 Post by fehlix » Sat Apr 21, 2018 2:51 pm

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;

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

Re: Easy change between light and dark themes

#6 Post by richb » Sat Apr 21, 2018 3:22 pm

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

Rich
SSD Production: MX 17.1
AMD A8 7600 FM2+ CPU R7 Graphics, 16 GIG Mem. Three Samsung EVO SSD's 250 GB, 350 GB HD

balarm
Forum Novice
Forum  Novice
Posts: 63
Joined: Thu Dec 07, 2017 3:15 pm

Re: Easy change between light and dark themes

#7 Post by balarm » Sat Apr 21, 2018 4:48 pm

@richb fantastic work, thank you.
@fehlix could you explein step by step how to insert your code in the Switch Button?? Thanks a lot.
mx1 Kernel: 4.15.0-1-amd64 x86_64 bits: 64 Desktop: Xfce 4.12.3
Distro: MX-17.1_x64 Horizon December 15, 2017
Machine: Device: laptop System: LENOVO product: 1951A47 v: ThinkPad T60

User avatar
oops
Forum Novice
Forum  Novice
Posts: 91
Joined: Tue Apr 10, 2018 5:07 pm

Re: Easy change between light and dark themes

#8 Post by oops » Sat Apr 21, 2018 4:50 pm

Thanks this .desktop file completes my customization with redshift-gtk.
$ inxi -S : System: Host:XEON Kernel: 4.16.0-xeon-01.efi x86_64 bits: 64 Desktop: Xfce 4.12.3 - Distro: MX-17.1_x64 Horizon


User avatar
fehlix
Forum Regular
Forum Regular
Posts: 305
Joined: Wed Apr 11, 2018 5:09 pm

Re: Easy change between light and dark themes

#9 Post by fehlix » Sat Apr 21, 2018 5:37 pm

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 ;=)

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

Re: Easy change between light and dark themes

#10 Post by Richard » Sun Apr 22, 2018 12:58 am

Ahh, that's cool.
I've been doing it the hard way for years!
MX17.1: T430-2017, 8 GB RAM, 4.15.0-1-amd64, 119 SSD
antiX-/MX-171: AA1/Eee, 1 GB RAM, 4.15.0-1-686-pae, 149 HDD
DoubleCmd, LO604, Dropbox, Slimjet, mPDFed, Py3, CherryT, Vbox

Post Reply

Return to “Tips&Tricks”