Select Page

I have to admit: at the beginning I was pretty doubtful about the dark mode which appeared on multiple device. But years helping I got more sensible to my sleep and so electronic lights. That’s how I got into the dark mode journey.

I used to work with Auto Dark Mode on Windows, but an motherboard outage forced me to take a new computer and so I decided to give a try to Ubuntu. On windows I was a little bit limited as I was using WSL. It was hard to manage everything with the same schedule or to automate easily but I was already using https://addons.mozilla.org/fr/firefox/addon/darkreader/ to have desktop and browser synchronized.

Ubuntu allowed me to go way further in this idea and that’s what I want to share here. There are four steps:

  • Desktop/System
  • Terminal
  • Editor (vim like)
  • Browser

Desktop

First of all you can add screen dimmer with the help of Night Light offered from ubuntu. You can find it in Settings, Displays, Night Light (at the top)

Ubuntu use Gnome as desktop manager as default manager. It can be easily customised to add a complete dark mode auto switcher with https://nightthemeswitcher.romainvigier.fr/

Note I activated Always show on-demand controls to get a button in the quick actions menu
You can also notice I use Night Light too

Now you can begin to set a different wallpaper for each setup to easily recognize like I did. You should also notice the “commands” tabs which we will use later !

Terminal

As terminal, I’m using Alacrity combined to one of the official themes. Here I chose a theme with a dark and light declinaison and then set it /home/alexandre/.config/alacritty.yml by adding the following line:

import:
  - ~/.config/alacritty/themes/themes/gruvbox_dark.yaml

in the ~/.config/allacrity.yaml file (may vary according to your setup). And that’s it ! You can switch easily with a sed -i 's/light/dark/' "${FILE_NAME}". Note also this, I will come back at it.

Editor

I’m using astronvim which is a pre-built config for neovim. It comes with a lot of features, I obviously cannot list them all but if you are a vim afficionados I would encourage you to have a look ! For this we will perform the same trick as previous: find a theme you like (for me kanagawa-theme is great) and then add to your ~/.config/nvim/init.lua this kind of line vim.cmd('set background=dark')

Glue it !

Now we have set up the first parts we can use the commands tab in our night theme switcher to make everything works together. I created two scripts Sunset.sh and Sunrise.sh which are more or less like this:

#!/bin/bash

notify-send "Goodbye Sun"
FILE_LIST=(
/home/alexandre/.config/alacritty.yml 
/home/alexandre/.config/nvim/init.lua 
)
sed -i 's/light/dark/' "${FILE_LIST[@]}"

a quick overview of the commands:

  • notify-send send a notification into the ubuntu notification pane. honnestly I don’t really use it as I’m always in do not disturb but good to know
  • FILE_LIST is a bash list of all the files we want to modify
  • 's/light/dark/' "${FILE_LIST[@]}" will replace the word “light” with “dark” in all the files mentionned in the list

Browser

Last one, the program I use the most, firefox. And… it’s a peace of cake ! You just need to download the dark reader extension and activate in the options “use system color scheme”

And don’t worry if you worship use another browser, dark reader is also available on Chrome, Edge and Safari.

Adendum

I thought it was over but ! I forgot two things:

  • I use bat as replacement of cat which use a separate theming. To fix this I only added export BAT_THEME="gruvbox-dark" to my .zshrc and added .zshrc in the FILE_LIST list we created earlier
  • My setup was almost perfect but something was missing: my topbar was always white, ruining my “all black” configuration. For this I made a dirty fix: added the command gsettings set org.gnome.desktop.interface gtk-theme THEME to my sunset/sunrise theme with THEME being a dark and light theme according the script

Everything is not perfect in this setup but i hope it may help you if you are looking for a start on how to get a full dark setup 🙂