Giter VIP home page Giter VIP logo

dark-mode-daemon's Introduction

Dark Mode Daemon

Run scripts when the system color scheme changes between light and dark.

Installation

For now, simply use Homebrew is the easiest option:

# 1. Install the binary
brew install NiclasvanEyk/dark-mode-daemon/dark-mode-daemon

# 2. (optional) Launch the daemon on system start
brew services start dark-mode-daemon

Note that if you don't run the second step, you can still manually watch for changes using dark-mode-daemon daemon.

Usage

Create a new directory for scripts that should be run when changing color modes:

mkdir $HOME/.config/dark-mode-daemon/scripts

Alternatively use $XDG_CONFIG_HOME instead of $HOME/.config if you configured it

Then create as many scripts there as you like, but don't forget to make them executable. They will be automatically be run when changing between dark and light mode. The DMD_COLOR_MODE environment variable will be either set to light or dark, depending on the new mode.

Example

The original motivation for creating this program was to sync theming environment variables, such as difftastics DFT_BACKGROUND or bats BAT_THEME with the current operating system color scheme. But lets use a more impractical example.

MacOS includes say, a text-to-speech program available on the command line. We can use this to loudly announce our dark mode changes.

First we create the script

touch $HOME/.config/dark-mode-daemon/scripts/announce.sh

Then fill it with the following content

#!/usr/bin/env bash

say "Changed to $DMD_COLOR_MODE mode"

finally make it executable

chmod +x $HOME/.config/dark-mode-daemon/scripts/announce.sh

You can verify that it will be run using

dark-mode-daemon list

this should print something like the following:

๐Ÿ“‚ Using scripts in /Users/youruser/.config/dark-mode-daemon/scripts...

/Users/youruser/.config/dark-mode-daemon/scripts/announce.sh

Now turn your volume up, toggle dark mode, and be amazed at the result. Or create more useful scripts that adjust your terminal emulator, vim/emacs/editor theme, or something totally different.

dark-mode-daemon's People

Contributors

niclasvaneyk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.