6.4 KiB
Executable File
author | authorEmoji | title | date | description | draft | hideToc | enableToc | enableTocContent | tocPosition | tocLevels | tags | series | categories | image | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Devoalda | 🐺 | Pywal | 2020-09-21T15:22:09+08:00 | How I use pywal | false | false | true | true | inner |
|
|
|
|
images/postImages/Rainbow.svg |
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:
yay -S python-pywal
Window Manager/Status Bar
Xmonad/Xmobar
{{< img src="https://devoalda.gitlab.io/gallery/Carnage/Carnage%20Xmonad%20050720201.png" alt="archlinux" position="center" >}} 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
-- 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
------------------------------------------------------------------------
---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
{{< img src="https://devoalda.gitlab.io/gallery/Carnage/Carnage%20DWM%20110720202.png" alt="archlinux" position="center" >}}
I use LukeSmith's build of DWM and DWMBlocks as it is configured to use Xresources colors to theme the window manager
Terminal Emulators
{{< img src="https://devoalda.gitlab.io/gallery/Carnage/Carnage%20Xmonad%2015082020.png" alt="archlinux" position="center" >}}
I use LukeSmith's build of ST as it is configured to use Xresources colors to theme the terminal emulator
{{< alert theme="info" dir="ltr" >}} BONUS Any terminal based applications like ncmpcpp, visualisers(vis,cava,etc.), htop, etc. will be themed according to the terminal colors (in my experience)! {{< /alert >}}
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
{{< img src="https://devoalda.gitlab.io/gallery/Carnage/Carnage%20Xmonad%2005072020.png" alt="archlinux" position="center" >}} 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.
$ 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!