Control the macOS dark mode from the command-line

Overview

dark-mode

Control the macOS dark mode from the command-line

Requires macOS 10.10 or later. macOS 10.13 or earlier needs to download the Swift runtime support libraries.

Install

Homebrew
$ brew install dark-mode
npm
$ npm install --global dark-mode-cli
Manually

Download the binary and put it in /usr/local/bin.

Usage

$ dark-mode --help

  Usage
    $ dark-mode [command]

  Commands
    <none>  Toggle dark mode
    on      Enable dark mode
    off     Disable dark mode
    status  Dark mode status

Build

Run ./build. The binary can be found at ./bin/dark-mode.

Building in Xcode works, but it does not export a binary.

Related

Comments
  • dark-mode left my system in a mixed state

    dark-mode left my system in a mixed state

    After playing around with dark-mode, it left my system in a mixed-mode state. The menubar is dark, but the backgrounds for the Dock and the Cmd-Tab display are light.

    This mixed-state persists no matter what I do in System Preferences. It also persists after full reboots.

    opened by chdiza 19
  • Fatal error: Unexpectedly found nil while unwrapping an Optional value

    Fatal error: Unexpectedly found nil while unwrapping an Optional value

    Issuehunt badges

    $ dark-mode status
    Fatal error: Unexpectedly found nil while unwrapping an Optional value
    

    Subsequently, kill -9 is unable to terminate the process.

    macOS 10.14.5.


    IssueHunt Summary

    Backers (Total: $40.00)

    Become a backer now!

    Or submit a pull request to get the deposits!

    Tips


    IssueHunt has been backed by the following sponsors. Become a sponsor

    bug help wanted :dollar: Funded on Issuehunt 
    opened by dpo 7
  • New release

    New release

    The latest released version does not compile with Xcode 11 (because of the swift version used). Could you release a new version so we can ship it in Homebrew?

    opened by fxcoudert 3
  • illegal hardware instruction

    illegal hardware instruction

    I get the following error message:

    $ dark-mode status
    fatal error: unexpectedly found nil while unwrapping an Optional value
    Current stack trace:
    0    dark-mode                          0x0000000106f52b20 swift_reportError + 132
    1    dark-mode                          0x0000000106f6fed0 _swift_stdlib_reportFatalError + 61
    2    dark-mode                          0x0000000106cddc90 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 355
    3    dark-mode                          0x0000000106edff00 partial apply for (_fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never).(closure #2) + 109
    4    dark-mode                          0x0000000106cddc90 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 355
    5    dark-mode                          0x0000000106e9a880 specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never + 96
    6    dark-mode                          0x0000000106c36d60 static DarkMode.isDark.getter + 334
    7    dark-mode                          0x0000000106c376d0 main + 1450
    8    libdyld.dylib                      0x00007fffeafa1234 start + 1
    zsh: illegal hardware instruction  dark-mode status
    $ dark-mode --version
    2.0.1
    

    The program takes a few minutes to produce the error message. dark-mode on also takes several minutes to run but doesn't produce any output and doesn't enable dark mode. Everything worked fine yesterday.

    opened by fenhl 3
  • Dark-mode breaks menu-bar

    Dark-mode breaks menu-bar

    When installing dark-mode via homebrew on a brand new macOS 10.12.3 installation, the menu-bar breaks.

    Only the dock turns dark when activating dark-mode, and confirmed that using the system preference pane to do so (prior to install) works fine. After installing dark-mode, using the system pref UI will ONLY turn the menu-bar dark, and will no longer control the dock.

    A complete uninstall does not solve this problem.

    opened by brandontravis 3
  • Fix Homebrew builds

    Fix Homebrew builds

    This moves the copying of build product to ./bin/dark-mode from a build phase to the ./build script. This is done to ensure we never copy a non-codesigned binary to ./bin - which is what seems to be the cause of #19.

    This would work even without removing the build phase, as the copy from ./build will simply overwrite it. I'm not sure the build phase copy is really useful for other things than release though, and it's a bit quirky - basically it seems to never be codesigned on first build (e.g. after a "Clean build folder" + "build"), but it will then be codesinged on subsequent builds.

    If you would like me to update the PR to keep the build phase in, let me know and i'll fix that.

    Fixes #19

    opened by anderscarling 2
  • Version 3.0 is incompatible with MacOS Versions lower than 10.14

    Version 3.0 is incompatible with MacOS Versions lower than 10.14

    I guess you already know about this and it was an intentional decision but the readme still states that dark-mode works with MacOS 10.10 or later. Running on 10.13.6 (because my work machine does not support Mojave) I get the following error every time I run brew upgrade:

    dark-mode: macOS Mojave or newer is required.
    Error: dark-mode: An unsatisfied requirement failed this build
    

    If this was unintentional I would really appreciate a fix since I quite enjoy using dark-mode especially because it's not officially supported on my mac. If it was not, I can submit a PR to change the readme if you want me to and try to find an alternate solution.

    Update: I read #16 (which I obviously should've before submitting this) and now know that this was semi-intentional. I sadly don't know enough about xcode to know if it is possible to fix this though.

    opened by DysphoricUnicorn 2
  • Error: missing return in a function expected to return 'String?'

    Error: missing return in a function expected to return 'String?'

    Build with macOS Mojave 10.14.6 on MBP 2017

    Last 15 lines from /Users/mufeng/Library/Logs/Homebrew/dark-mode/01.build:
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~
    /tmp/dark-mode-20191209-84518-17xuhso/dark-mode-3.0.0/Sources/DarkMode.swift:9:3: error: missing return in a function expected to return 'Bool'
                    }
                    ^
    /tmp/dark-mode-20191209-84518-17xuhso/dark-mode-3.0.0/Sources/util.swift:6:1: error: missing return in a function expected to return 'String?'
    }
    
    opened by iMuFeng 1
  • Declined Authorization nsapplescript

    Declined Authorization nsapplescript

    I had declined the Authorization for editing system preference from the terminal, which prompted after I first time run the dark-mode.

    After some searching and looking around, I think it was linked to nsapplescript. But I don't know how to fix it or to regenerate that prompt.

    I was using MacOS Mojave 10.14 (18A391)

    opened by BenShen98 1
  • Menu Bar not changed on 10.12

    Menu Bar not changed on 10.12

    dark-mode seems incapable of changing the Menu Bar's theme in 10.12 Public Beta. The tool runs successfully and reports no errors that I can see, but only the Dock is changed to dark mode.

    opened by cleavenworth 1
  • Use of this app?

    Use of this app?

    This package is certainly functional, but it performs a single highly-specific task and no more. I found it in awesome-nodejs(the author of awesome-nodejs is also the author of this package, interestingly). Does this package demonstrate something highly interesting? Am I missing something?

    Thanks.

    opened by ghost 0
  • Set appearance to auto?

    Set appearance to auto?

    The CLI usage could be dark-mode auto.

    The dark mode in the appearance preferences object is boolean. Seems it's impossible to set appearance to auto with a simple AppleScript.

    I found a discussion at https://macscripter.net/viewtopic.php?id=48730.

    But if there is any other way to set appearance to auto, it would be a great feature.

    enhancement help wanted 
    opened by LitoMore 0
  • Fix tests

    Fix tests

    Issuehunt badges

    Tests are failing locally on and on Travis.

    There is a $40.00 open bounty on this issue. Add more on Issuehunt.

    bug help wanted :dollar: Funded on Issuehunt 
    opened by sindresorhus 3
Releases(v3.0.2)
Owner
Sindre Sorhus
Full-Time Open-Sourcerer. Wants more empathy & kindness in open source. Focuses on Swift & JavaScript. Makes macOS apps, CLI tools, npm packages. Likes unicorns
Sindre Sorhus
Control the Plash app from the command-line

plash-cli Control the Plash app from the command-line Install $ npm install --global plash Requires Node.js 14 or later. Requires Plash 2.3.0 or late

Sindre Sorhus 33 Dec 30, 2022
a simple zero-configuration command-line http server

http-server: a command-line http server http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usa

http ... PARTY! 12.4k Jan 4, 2023
node.js command-line interfaces made easy

Commander.js The complete solution for node.js command-line interfaces. Read this in other languages: English | 简体中文 Commander.js Installation Declari

TJ Holowaychuk 24k Jan 8, 2023
🌈 React for interactive command-line apps

React for CLIs. Build and test your CLI output using components. Ink provides the same component-based UI building experience that React offers in the

Vadim Demedes 19.7k Jan 9, 2023
Pretty unicode tables for the command line

cli-table3 This utility allows you to render unicode-aided tables on the command line from your node.js scripts. cli-table3 is based on (and api compa

null 418 Dec 28, 2022
A C++ based command-line (CLI) program that lets you manage your tasks

COMMAND LINE INTERFACE TODO APP a command-line (CLI) program that lets you manage your tasks. The specification for this project is written down as te

Rahul Prabhakar 1 Dec 25, 2021
1History is a command line tool to backup your histories of different browsers into one place

1History All your history in one place. 1History is a command line tool to backup your histories of different browsers into one place. Features Suppor

null 340 Dec 31, 2022
Wordle and Termooo style classic word guessing game for the command line. One new word per day!

Wordle and Termooo style classic word guessing game for the command line. One new word per day!

Anderson Silva 3 Nov 27, 2022
SFDX Plugin to set Email Deliverability Access Level for an org easily and quickly via command line interface

SFDX Plugin to set Email Deliverability Access Level for an org easily and quickly via command line interface

Max Goldfarb 11 Dec 16, 2022
A project for FAST command line interface tools.

FAST CLI Project This is the FAST CLI project, containing the FAST CLI package and other related CLI packages for FAST project creation and management

Microsoft 24 Dec 5, 2022
A command line interface for programmatically creating data silos on app.transcend.io

Table of Contents Overview Installation Authentication transcend.yml Usage tr-pull tr-push CI Integration Dynamic Variables tr-scan Overview A command

Transcend 15 Dec 13, 2022
Autify Command Line Interface (CLI)

Autify Command Line Interface (CLI) Autify CLI can help your integration with Autify! Autify Command Line Interface (CLI) Usage Commands Usage Note: n

Autify 36 Jan 2, 2023
Generate a Node.js command line tool from an OpenAPI definition

OpenAPI Commander Generate a Node.js command line tool from an OpenAPI definition using the commander library. Example usage Usage: Subcommands groupe

Barry Coughlan 12 Jan 3, 2023
Windows command line tool to block outbound connections for files within a directory.

fwg A Windows command line tool to block outbound connections for files within a directory. fwg utilizes the power of PowerShell and Windows Network S

raymond wang 3 Jul 19, 2022
The command-line interface for versum

@versumstudios/cli The command-line interface for versum. versum-cli Usage Contributing How to use Export Templates Usage To install the latest versio

Versum Studios 8 Nov 3, 2022
LinkFree CLI is a command line tool that helps you to create your LinkFree profile through CLI.

LinkFree CLI LinkFree CLI is a command line tool that helps you to create your LinkFree profile through CLI. Demo Using the CLI (Commands) Note First

Pradumna Saraf 32 Dec 26, 2022
💻 macOS interface with ReactJS

macOS a clone of the macOS interface, made with ReactJS. this open source project was made for studies, and aims to replicate the macOS interface. Be

Marcos Andre 16 Nov 10, 2022
:notes: Control iTunes via CLI

itunes-remote Control iTunes via your terminal ?? Using JXA via osascript via Node.js. Requirements Node.js (v0.12.7 or greater) Mac OS X (Yosemite 10

Michael Kühnel 422 Nov 19, 2022