DEV Community


Theme switcher based on rofi and pywal

・2 min read

I like to have a consistent color scheme across my wallpaper, terminal and other applications. Luckily my most frequent Programs are kitty, qutebrowser, rofi and i3wm. All of theme are able to be themed via configuration file.

  • kitty is my terminal emulator
  • rofi is a window switcher, Application launcher and dmenu replacement
  • qutebrowser is my main browser fully keyboard centric
  • and i3wm is my tilling window manager

If I'm in the mood to change my wallpaper (again) I'm using pywal. The installation is quite easy. Pywal is a tool that generates a color palette from the dominant colors from an image. It then applies the colors system-wide and on-the-fly in all of your favourite programs.

But the standard look of rofi which is generated by pywal is not satisfying me, so i have to generate my own rofi configuration. For this, i wrote this small script:


# grab the purest color definition file
while IFS= read -r line

    # generate the color list for my style config
    if [ $i -eq 0 ]; then 
        content="${content}  background:${line}00;"
        content="${content}  color$i:${line};"
        content="${content}  color$i:${line};"


done < "$input"

# copied a template config to the actual config location
cp /home/maren/dotfiles/rofi/colors-rofi-template.rasi /home/maren/dotfiles/i3/rofi.rasi

# write in the 10th line my color list
sed -i "10i$content" /home/maren/dotfiles/i3/rofi.rasi

Enter fullscreen mode Exit fullscreen mode

For qutebrowser i am using qutewal

To switch between my wallpapers I have the following script.

#!/usr/bin/env bash

# feed rofi with the content of my wallpaper directory
wallpaper=`ls -1 /home/maren/Downloads/wallpapers | rofi -dmenu -theme ~/dotfiles/i3/rofi.rasi ` 

while getopts ld option
  case "${option}"

      # apply light theme
      wal -l -i /home/maren/Downloads/wallpapers/$wallpaper
      # apply dark theme
      wal -i /home/maren/Downloads/wallpapers/$wallpaper

# change the rofi color theme 

Enter fullscreen mode Exit fullscreen mode

i3wm is highly configurable in case of keybindings and whit a
fast shortkey I can define my new theme with in seconds.

bindsym $mod+d exec "sh /home/maren/dotfiles/i3/script/ -d" 
bindsym $mod+l exec "sh /home/maren/dotfiles/i3/script/ -l" 
Enter fullscreen mode Exit fullscreen mode

Theme switcher

Discussion (0)