From f97c64965359ace747b6b4128fdaf65e0fc3f215 Mon Sep 17 00:00:00 2001 From: Jun Wei Woon Date: Mon, 21 Sep 2020 16:19:37 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=95=20New=20Post=20on=20Pywal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/en/posts/pywal.md | 167 +++++++++++++++++++++++++++ static/images/postImages/Rainbow.svg | 1 + 2 files changed, 168 insertions(+) create mode 100644 content/en/posts/pywal.md create mode 100644 static/images/postImages/Rainbow.svg diff --git a/content/en/posts/pywal.md b/content/en/posts/pywal.md new file mode 100644 index 0000000..c931165 --- /dev/null +++ b/content/en/posts/pywal.md @@ -0,0 +1,167 @@ +--- +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 = " :: " -- 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! diff --git a/static/images/postImages/Rainbow.svg b/static/images/postImages/Rainbow.svg new file mode 100644 index 0000000..de0f69e --- /dev/null +++ b/static/images/postImages/Rainbow.svg @@ -0,0 +1 @@ + \ No newline at end of file