This page looks best with JavaScript enabled

Pywal

 ·  ☕ 4 min read  ·  🐺 Devoalda

Introduction

Pywal is a incredible script for colorscheme generation and theming/ricing Linux desktops. Pywal will generate colors based on the image given to the script, it will then make that image the wallpaper.

In this article, I will share about how I integrated this script with my desktop.

Checkout my Desktop themed with pywal

Installation

I use the Arch linux AUR:

1
yay -S python-pywal

Window Manager/Status Bar

Xmonad/Xmobar

archlinux

I use Xmonad as my Linux window manager, here are my Configurations

Adding the following lines of code, I am able to use pywal to dynamically theme my status bars

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
   -- Colors
import Control.Monad(when)
import Data.List
import System.Directory
import System.Environment
import System.Exit
import System.IO

getConfigFilePath f =
  getHomeDirectory >>= \hd -> return $ hd ++ "/" ++ f

getWalColors = do
  file <- getConfigFilePath ".cache/wal/colors"
  contents <- readFile file
  let colors = lines contents
  return (colors ++ (replicate (16 - length colors) "#000000"))

My main method consists of the function getWalColors and uses the colors generated by pywal to theme the statusbar

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
------------------------------------------------------------------------
---MAIN
------------------------------------------------------------------------
main = do
    nScreens <- countScreens
    colors <- getWalColors
    xmproc <- spawnPipe "xmobar ~/.xmonad/xmobarrc"
    xmonad $ ewmh $ desktopConfig
        { manageHook = ( isFullscreen --> doFullFloat ) <+> manageDocks <+> myManageHook <+> manageHook desktopConfig
        , modMask            = myModMask
        , terminal           = myTerminal
	, startupHook        = myStartupHook
        , layoutHook         = myLayoutHook
	, workspaces         = myWorkspaces
        , borderWidth        = myBorderWidth
	, normalBorderColor  = colors!!10
	, focusedBorderColor = colors!!12
        , logHook = dynamicLogWithPP xmobarPP
                        { ppOutput = hPutStrLn xmproc
                        , ppCurrent = xmobarColor (colors!!14) "" . wrap "[" "]" -- Current workspace in xmobar
                        , ppVisible = xmobarColor  (colors!!13) ""                -- Visible but not current workspace
                        , ppHidden = xmobarColor (colors!!15) "" . wrap "*" ""   -- Hidden workspaces in xmobar
                        , ppHiddenNoWindows = xmobarColor (colors!!11) ""        -- Hidden workspaces (no windows)
                        , ppTitle = xmobarColor (colors!!14) "" . shorten 60     -- Title of active window in xmobar
			, ppSep =  "<fc=" ++ (colors!!2) ++ "> :: </fc>"                     -- Separators in xmobar
                        , ppUrgent = xmobarColor  (colors!!15) "" . wrap "!" "!"  -- Urgent workspace
                        , ppExtras  = [windowCount]                           -- # of windows current workspace
                        , ppOrder  = \(ws:l:t:ex) -> [ws,l]++ex++[t]
                        }
        } `additionalKeysP`         myKeys

DWM/DWMBlocks

archlinux

I use LukeSmith’s build of DWM and DWMBlocks as it is configured to use Xresources colors to theme the window manager

Terminal Emulators

archlinux

I use LukeSmith’s build of ST as it is configured to use Xresources colors to theme the terminal emulator

Pywal templates

Pywal templates is another powerful function of pywal, they allow for dynamic theming of individual applications to your liking. Here are some of the templates I use.

Notification Manager

archlinux

I use dunst as my notification manager of choice. This is themed with pywal with the following lines of configurations in the templates

# Set the background and foreground (text) color for all notifications
[urgency_low]
    background = "{background}"
    foreground = "{foreground}"

[urgency_normal]
    background = "{color9}"
    foreground = "{foreground}"

[urgency_critical]
    background = "{color10}"
    foreground = "{foreground}"

After creating the template and adding these lines, run the following command to add a symbolic link to the main dunstrc file.

1
$ ln -sf "${HOME}/.cache/wal/dunstrc" "${HOME}/.config/dunst/dunstrc"

Script

To dynamically theme all these with a click of a button, I have created a script to generate new colors and update necessary files.

Extras

Here are some of the other applications that can be themed with pywal:

Summary

Pywal is an incredible script to help theme everything in my desktop. I strongly recommend pywal to linux users who are new to ricing.

Do checkout my Dotfiles for other applications that can be themed by pywal!

Share on

Devoalda
WRITTEN BY
Devoalda
Technophile