Coder Social home page Coder Social logo

dark-mode-notify's Introduction

dark-mode-notify

This small Swift program will run a command whenever the dark mode status changes on macOS. You can use it to change your vim color config automatically for example.

Usage

Use make to compile the program, then run directly:

.build/release/dark-mode-notify <your-program>

Alternatively you can install it by doing make install.

The program will be run immediately when the command starts, and every time the OS goes from dark mode to light mode or back. The environment variable DARKMODE will be set to either 1 or 0.

Background agent

To keep this program running in the background, compile the binary to somewhere and create the following file at ~/Library/LaunchAgents/ke.bou.dark-mode-notify.plist. Don't forget to replace the arguments and the path to the logs (which comes in handy for debugging)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>ke.bou.dark-mode-notify</string>
    <key>KeepAlive</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>----Path to a location----/dark-mode-notify-stderr.log</string>
    <key>StandardOutPath</key>
    <string>----Path to a location----/dark-mode-notify-stdout.log</string>
    <key>ProgramArguments</key>
    <array>
       <string>/usr/local/bin/dark-mode-notify</string>
       <string>--- Path to your script ---</string>
    </array>
</dict>
</plist>

Then launchctl load -w ~/Library/LaunchAgents/ke.bou.dark-mode-notify.plist will keep it running on boot.

Credit

This script is a lightly modified version of https://github.com/mnewt/dotemacs/blob/master/bin/dark-mode-notifier.swift

dark-mode-notify's People

Contributors

angristan avatar bouk avatar fatih avatar jum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dark-mode-notify's Issues

Fails to build: error: no such module 'PackageDescription'

I get this when trying to build:

 make install
swift build -c release --disable-sandbox
error: 'dark-mode-notify': Invalid manifest
/Users/bart/src/dark-mode-notify/Package.swift:2:8: error: no such module 'PackageDescription'
import PackageDescription
       ^
make: *** [build] Error 1

How to best go about conditional execution based on current theme

Hey there, nice little tool you got here, I'm hoping to get it working for my use case as I have been looking for something to accomplish this for a while.

I'm running it as a service in the way you describe. I am pointing to a simple bash script to be run on a system theme change. I am piping the output of my script to the same log files I use for the service. When I change the system appearance, it doesn't seem to run my script.

Any help would be much appreciated.

Publish the binary on Homebrew

So, "compile the binary and save it somewhere," while totally making sense for a little one-off throwaway script, ain't great for reproducible / stable system configuration that lasts past the current machine's lifetime. :P

Any chance you're willing to see this shipped to Homebrew or similar, as simple as it is?

Doesn't update $DARKMODE when appearance is changed with Shortcuts

TL;DR

If I change appearance using a shortcut defined in Shortcuts, the DARKMODE variable doesn't update.

To reproduce, set the shortcut like so:

image

Try running the app and displaying the $DARKMODE variable.

Expected behavior

$DARKMODE variable is updated accordingly.

Observed behavior

$DARKMODE variable is retains its previous value and ignores system changes.

Terraform Configuration

I don't know how to do this.

Terraform Version

I don't know how to do this.

Additional information

No response

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.