How to Create Color Schemes to Match Your Wallpaper on Linux

If you run a lot of applications in the command line interface (CLI), or you’re a fan of window managers, you know that styling them can be a real pain. It’s not easy to come up with a cohesive color scheme across all of your applications, and it’s even more difficult to match that scheme to your wallpaper. Then what if you want to change your wallpaper? You definitely don’t want to do that all again.

Enter Wal, a script that uses your wallpaper to automatically generate a color palate in your “.Xresorces” file or another convenient location. Creating and changing your entire color scheme on the fly with Wal is super easy.

You might also want to check out pywal. It was written by the same developer and works the same way but in Python. At the time of writing this, pywal only supports Python 3.6, which isn’t packaged nor the default version in most distributions.

If you don’t already have one, create a local “bin” folder in your Home directory. It’ll be much easier to work with that way.

cd ~
mkdir bin

Enter your new directory and grab Wal from Github, then make it executable.

cd bin
chmod +x wal

You’ll need to reread your profile file, too, so do that.

cd ~
source .profile

Default Wal in Ubuntu i3

Wal is very easy to use. You just need to issue the command and tell it which picture to use. The example below created the picture above.

wal -i Pictures/Wallpaper/kde.png

Wal on Ubuntu

Wal based the new color scheme off of the KDE wallpaper specified in the command. As a general rule Wal will use the darkest color it can find in the image for the background. Take a look at this rather bright image. You still have a black background since it’s the darkest color Wal found.

Wal Dark Terminal Background

You may have already noticed that Wal doesn’t change any other terminals by default. There are a couple of ways to handle running Wal automatically. The first, and easiest, is to add Wal to your “.bashrc” or “.zshrc” file (if you are using zsh). This will reload your most recent Wal settings for your terminal sessions.

(wal -r &)

The -r flag stands for reload. You can do that manually in a new terminal, too.

Also, remember that by styling your terminal itself, Wal also styles all of your terminal applications.

That doesn’t do you much good on reboot, though. In order to make Wal run automatically when your X Server starts up, you’ll need to add the following line or something similar to your “.xinitrc” file:

wal -i "$(< "${HOME}/.cache/wal/wal")"

If you’re interested in Wal, you’re probably running a window manager. i3 is easily the most popular tiling window manager among Linux customization enthusiasts, and Wal can integrate nicely with it.

Wal With i3 integration

You can make i3 load colors from the “.Xresources” file which Wal creates. All you need to do is assign your color variables in i3 from “.Xresources.” Wal will reload i3 and the colors will change dynamically. Even though the image above didn’t do so, you can carry the theme through your status bar, too.

set_from_resource $fg i3wm.color1
set_from_resource $bg i3wm.color2
set_from_resource $ac i3wm.color3

Choose the colors that you want based on the “.Xresources” numbering scheme.

There’s a complementary script called wal-set that loads changes to other common programs like Dunst and Lemonbar. You can grab the script from Github and place it in your local “bin” directory, too.

cd ~/bin

Once you have it, add it on to your Wal commands with the -o flag.

wal -i Pictures/Wallpaper/kde.png -o wal-set

Polybar is a hugely popular window manager menu bar. Like i3, it can load its color values from “.Xresources,” Just set your color variables in your Polybar configuration to “.Xresorces” values.

fg = ${xrdb:color1}
bg = ${xrdb:color2}

You can modify any program that reads from “.Xresources” with Wal and even more if you get creative with it. Wal is also scriptable, so that adds loads more options, including setting Wal on a timer. Experiment with it and achieve the desktop you’ve been waiting for.

Leave a Reply

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.