168 lines
6.4 KiB
Markdown
168 lines
6.4 KiB
Markdown
---
|
|
author: "Devoalda"
|
|
authorEmoji: 🐺
|
|
title: "Pywal"
|
|
date: 2020-09-21T15:22:09+08:00
|
|
description: How I use pywal
|
|
draft: false
|
|
hideToc: false
|
|
enableToc: true
|
|
enableTocContent: true
|
|
tocPosition: inner
|
|
tocLevels: ["h1", "h2", "h3"]
|
|
tags:
|
|
- arch
|
|
- linux
|
|
- pywal
|
|
series:
|
|
- Linux
|
|
categories:
|
|
- arch
|
|
- linux
|
|
image: images/postImages/Rainbow.svg
|
|
---
|
|
|
|
# Introduction
|
|
|
|
[Pywal](https://github.com/dylanaraps/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](https://devoalda.gitlab.io/gallery/carnage/) themed with pywal
|
|
|
|
# Installation
|
|
|
|
I use the Arch linux AUR:
|
|
|
|
```bash
|
|
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](https://gitlab.com/devoalda/dotdrop-dotfiles/-/blob/master/dotfiles/xmonad/xmonad.hs)
|
|
|
|
Adding the following lines of code, I am able to use pywal to dynamically theme my status bars
|
|
|
|
```Haskell
|
|
-- 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
|
|
|
|
```Haskell
|
|
------------------------------------------------------------------------
|
|
---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](https://github.com/LukeSmithxyz/dwm) and [DWMBlocks](https://github.com/LukeSmithxyz/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](https://github.com/LukeSmithxyz/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](https://gitlab.com/devoalda/dotdrop-dotfiles/-/tree/master/dotfiles/config/wal/templates) 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](https://dunst-project.org/) 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.
|
|
|
|
```bash
|
|
$ 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](https://gitlab.com/devoalda/dotdrop-dotfiles/-/blob/master/dotfiles/local/bin/wallpaper) to generate new colors and update necessary files.
|
|
|
|
# Extras
|
|
|
|
Here are some of the other applications that can be themed with pywal:
|
|
|
|
- [Spotify](https://github.com/khanhas/spicetify-cli)
|
|
- [Steam](https://github.com/kotajacob/wal_steam)
|
|
- [Discord/lightcord](https://github.com/abou123/pywal-discord)
|
|
- [Others](https://github.com/dylanaraps/pywal/wiki/Customization)
|
|
|
|
# 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](https://gitlab.com/devoalda/dotdrop-dotfiles/-/tree/master/dotfiles) for other applications that can be themed by pywal!
|