Sample Header Ad - 728x90

How to automate switching between light and dark modes?

3 votes
3 answers
2608 views
I am a user of [Linux Mint](https://en.wikipedia.org/wiki/Linux_Mint) . One feature I often wish I had in Linux is the ability to switch between light and dark modes depending on the time of the day, as in macOS and mobile devices. I have put together the following script for switching from light to dark mode:
#!/bin/bash
notify-send "Switching to dark mode"
gsettings set org.cinnamon.desktop.wm.preferences theme Mint-Y-Dark
gsettings set org.cinnamon.desktop.interface gtk-theme Mint-Y-Dark
gsettings set org.cinnamon.theme name Mint-Y-Dark
and I have another one for the opposite direction
#!/bin/bash
gsettings set org.cinnamon.desktop.wm.preferences theme Mint-Y
gsettings set org.cinnamon.desktop.interface gtk-theme Mint-Y
gsettings set org.cinnamon.theme name Mint-Y
Currently, I run these manually when I want to switch between the two themes. Most programs respect the OS-wide theme meaning this method works surprisingly well! However, there are three problems that I would like to solve with this approach: 1. Automated switching between light/dark modes depending on the time of day (as in macOS). I tried using cron and anacron but they don't work well for this purpose. When my computer is turned on after a period of being off, I would like it to realise that the time to switch has passed and perform the mode switch (as in macOS and various mobile devices); 2. I would like my terminal (GNOME Terminal, Cinnamon default) to switch from a light theme to a dark theme (and vice versa); and 3. I would like my text editor (Emacs) to load a light/dark theme. Even getting just (1) to work would be quite nice!
Asked by affibern (131 rep)
Nov 18, 2020, 09:15 PM
Last activity: Nov 14, 2024, 01:07 PM