Page 1 of 2

Easy change between light and dark themes

Posted: Thu Mar 22, 2018 12:14 pm
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.

Re: Easy change between light and dark themes

Posted: Thu Apr 05, 2018 12:47 am
by mrfebruary
Wow. Cool!

Re: Easy change between light and dark themes

Posted: Sat Apr 21, 2018 7:42 am
by bwhawk
Thank you for posting this. This is an elegant solution that never would have occurred to me.

Re: Easy change between light and dark themes

Posted: Sat Apr 21, 2018 7:53 am
by richb
Glad you find it useful.

Re: Easy change between light and dark themes

Posted: Sat Apr 21, 2018 2:51 pm
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;

Re: Easy change between light and dark themes

Posted: Sat Apr 21, 2018 3:22 pm
by richb
Thanks. I have two buttons on the panel one for dark and one for light. Your solution is a nice refinement.

Re: Easy change between light and dark themes

Posted: Sat Apr 21, 2018 4:48 pm
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.

Re: Easy change between light and dark themes

Posted: Sat Apr 21, 2018 4:50 pm
by oops
Thanks this .desktop file completes my customization with redshift-gtk.

Re: Easy change between light and dark themes

Posted: Sat Apr 21, 2018 5:37 pm
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 ;=)

Re: Easy change between light and dark themes

Posted: Sun Apr 22, 2018 12:58 am
by Richard
Ahh, that's cool.
I've been doing it the hard way for years!