You are not logged in.

#1 2010-06-02 18:49:49

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

[Tip] How to change meld colors (for dark themes)

I've looked for a GTK visual diff tool and I couldn't find anything except "meld". Meld is a nice tool, except that it is totally unusable with the "Xfce-Dusk" theme (text is written black on black, or white on white...)

Searching the web didn't return any solution, only a post 9 months ago on their mailing list that apparently didn't lead to anything.

So I had a look at the source files and found how to change the colors. If anyone's interested, hop to /usr/lib/meld/ and open meldapp.py in your editor. Search for color and change the following lines:

        "color_delete_bg" : prefs.Value(prefs.STRING, "#003300"),
        "color_delete_fg" : prefs.Value(prefs.STRING, "Red"),
        "color_replace_bg" : prefs.Value(prefs.STRING, "#112233"),
        "color_replace_fg" : prefs.Value(prefs.STRING, "gray80"),
        "color_conflict_bg" : prefs.Value(prefs.STRING, "Pink"),
        "color_conflict_fg" : prefs.Value(prefs.STRING, "White"),
        "color_inline_bg" : prefs.Value(prefs.STRING, "#223344"),
        "color_inline_fg" : prefs.Value(prefs.STRING, "White"),
        "color_edited_bg" : prefs.Value(prefs.STRING, "gray20"),
        "color_edited_fg" : prefs.Value(prefs.STRING, "White"),

(The values here are the ones I came up with; they should be a good starting point for people using dark themes.)

You can also edit tree.py and look for foreground=.

            '<span foreground="white">%s</span>', # STATE_NORMAL
            '<span foreground="white" style="italic">%s</span>', # STATE_NOCHANGE

(I only changed those two lines from black to white.)

Edit: Does not work anymore; see https://wiki.gnome.org/Meld/DarkThemes instead.

Last edited by stqn (2013-09-09 12:52:47)

Offline

#2 2010-06-02 22:51:29

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

Re: [Tip] How to change meld colors (for dark themes)

Hmm, doesn't look like it'd be too hard to write a script to handle that (just some sed lines), similar to openoffice-dark-gtk-fix.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2010-08-09 09:29:01

lxz
Member
Registered: 2010-08-09
Posts: 4

Re: [Tip] How to change meld colors (for dark themes)

Thanks stqn, I like your solution!

Here's a script to do that:

#!/bin/sh  

cd /usr/lib/meld/
echo "Patching files in $(pwd)"

sed '
s/\(color_delete_bg"[^"]*\)"[^"]*"/\1"#003300"/
s/\(color_replace_bg"[^"]*\)"[^"]*"/\1"#112233"/
s/\(color_replace_fg"[^"]*\)"[^"]*"/\1"gray80"/
s/\(color_conflict_fg"[^"]*\)"[^"]*"/\1"White"/
s/\(color_inline_bg"[^"]*\)"[^"]*"/\1"#223344"/
s/\(color_inline_fg"[^"]*\)"[^"]*"/\1"White"/
s/\(color_edited_bg"[^"]*\)"[^"]*"/\1"gray20"/
s/\(color_edited_fg"[^"]*\)"[^"]*"/\1"White"/
' meldapp.py > meldapp.py.new

sed '    
s/foreground="[^"]*"\([^#]*#[ ]*STATE_NORMAL\)/foreground="white"\1/
s/foreground="[^"]*"\([^#]*#[ ]*STATE_NOCHANGE\)/foreground="white"\1/
' tree.py > tree.py.new

for file in meldapp.py tree.py; do
        mv "$file.new" "$file"
done

echo -e "\e[32;1mDone\e[0m (Note: In case meld doesn't work anymore, please reinstall it.)"

edit: added some messages

Last edited by lxz (2010-08-09 10:27:57)

Offline

#4 2010-08-21 04:07:59

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

Re: [Tip] How to change meld colors (for dark themes)

lxz wrote:

Thanks stqn, I like your solution!

Here's a script to do that:
edit: added some messages

The latest meld has moved some stuff, here's the changes.

#!/bin/sh  

cd /usr/lib/meld/meld/
echo "Patching files in $(pwd)"

sed '
s/\(color_delete_bg"[^"]*\)"[^"]*"/\1"#003300"/
s/\(color_replace_bg"[^"]*\)"[^"]*"/\1"#112233"/
s/\(color_replace_fg"[^"]*\)"[^"]*"/\1"gray80"/
s/\(color_conflict_fg"[^"]*\)"[^"]*"/\1"White"/
s/\(color_inline_bg"[^"]*\)"[^"]*"/\1"#223344"/
s/\(color_inline_fg"[^"]*\)"[^"]*"/\1"White"/
s/\(color_edited_bg"[^"]*\)"[^"]*"/\1"gray20"/
s/\(color_edited_fg"[^"]*\)"[^"]*"/\1"White"/
' preferences.py > preferences.py.new

sed '    
s/foreground="[^"]*"\([^#]*#[ ]*STATE_NORMAL\)/foreground="white"\1/
s/foreground="[^"]*"\([^#]*#[ ]*STATE_NOCHANGE\)/foreground="white"\1/
' tree.py > tree.py.new

for file in preferences.py tree.py; do
        mv "$file.new" "$file"
done

echo -e "\e[32;1mDone\e[0m (Note: In case meld doesn't work anymore, please reinstall it.)"

Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#5 2010-08-21 09:20:34

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [Tip] How to change meld colors (for dark themes)

Thanks, lxz and ngoonee!

Offline

#6 2011-01-18 19:34:14

frigaut
Member
From: Canberra, Australia
Registered: 2009-05-10
Posts: 215
Website

Re: [Tip] How to change meld colors (for dark themes)

yep, very handy. Thanks, I can use meld again.


Archer since 03/2009 - AUR packages

Offline

#7 2013-09-09 12:04:32

mizux
Member
Registered: 2010-10-03
Posts: 6

Re: [Tip] How to change meld colors (for dark themes)

Seems not to work with last version of meld aka meld 1.7.5-1

Offline

#8 2013-09-09 12:24:58

progandy
Member
Registered: 2012-05-17
Posts: 5,263

Re: [Tip] How to change meld colors (for dark themes)

You can now change the color with ~/.gtkrc-2.0. The default colors are defined in /usr/share/meld/gtkrc.
https://mail.gnome.org/archives/meld-li … 00051.html


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#9 2013-09-09 12:36:36

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Tip] How to change meld colors (for dark themes)

Offline

#10 2013-09-09 12:46:04

mizux
Member
Registered: 2010-10-03
Posts: 6

Re: [Tip] How to change meld colors (for dark themes)

Yep,

I was on it until now trying to tweak it according to my "dark" NOX theme.

Offline

#11 2013-09-09 12:51:46

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [Tip] How to change meld colors (for dark themes)

karol wrote:

Great! These colors are ugly, but readable.
Thanks.

Offline

#12 2013-09-09 13:06:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Tip] How to change meld colors (for dark themes)

stqn wrote:
karol wrote:

Great! These colors are ugly, but readable.
Thanks.

You can try using values from https://bbs.archlinux.org/viewtopic.php … 95#p812795

Offline

#13 2014-07-29 22:17:10

falstaff_ch
Member
Registered: 2013-06-09
Posts: 26

Re: [Tip] How to change meld colors (for dark themes)

For newer version, this trick does not work anymore (likely due to the switch to GTK 3). However, it's possible to create a css file located in ~/.config/gtk-3.0/gtk.css similar to this:

https://github.com/GNOME/meld/blob/master/data/meld.css

My gtk.css

--
falstaff

Offline

#14 2014-07-30 02:03:55

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [Tip] How to change meld colors (for dark themes)

falstaff_ch wrote:

Thanks a lot! It’s working perfectly. I had to put gtk.css in /root/.config/gtk-3.0/ for "sudo meld" to get the css, of course… (forgot it at first and was disappointed it wasn’t working).

Now we just have to wait a couple months for the next breaking change by the meld authors…

Offline

#15 2017-09-07 11:43:59

postadelmaga
Member
Registered: 2012-12-22
Posts: 5

Re: [Tip] How to change meld colors (for dark themes)

@stqn
Naaa , you were wrong:
- they implemented in the app settings and now we are all happy smile

Offline

#16 2017-09-07 12:24:31

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,254

Re: [Tip] How to change meld colors (for dark themes)

Compare the dates, one would think that this has changed quite a bit in three years.

Do not necropost.

Closing.

Last edited by V1del (2017-09-07 12:24:59)

Offline

Board footer

Powered by FluxBB