auto-terminal-profile 2.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import darkMode from 'dark-mode';
1
+ import process from 'node:process';
2
2
  import {setTerminalProfile, setTerminalDefaultProfile} from 'terminal-profile';
3
3
  import {config} from '../config.js';
4
4
 
@@ -11,7 +11,7 @@ export async function updateProfile() {
11
11
  throw new Error('Light profile not set');
12
12
  }
13
13
 
14
- const mode = (await darkMode.isEnabled()) ? 'dark' : 'light';
14
+ const mode = process.env.DARKMODE === '1' ? 'dark' : 'light';
15
15
  const profile = config[`${mode}Profile`];
16
16
 
17
17
  await Promise.all([
package/changelog.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [v3.0.1](https://github.com/ptrkcsk/terminal-profile/compare/v3.0.0...v3.0.1) – 2024-02-20
9
+
10
+ ### Fixed
11
+
12
+ - Broken post-install compilation step
13
+
14
+ ## [v3.0.0](https://github.com/ptrkcsk/terminal-profile/compare/v2.1.0...v3.0.0) – 2024-02-19
15
+
16
+ ### Removed
17
+
18
+ - Support for Node.js versions before 18
19
+
20
+ ### Fixed
21
+
22
+ - Issue causing `auto-terminal-profile` to silently fail on macOS Sonoma
23
+
24
+ ## [v2.1.0](https://github.com/ptrkcsk/terminal-profile/compare/v2.0.0...v2.1.0) – 2023-07-04
25
+
26
+ ### Changed
27
+
28
+ - Update dependencies
29
+
8
30
  ## [2.0.0](https://github.com/ptrkcsk/terminal-profile/compare/v1.1.1...v2.0.0) – 2023-05-10
9
31
 
10
32
  ### Added
package/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Conf from 'conf';
2
- import {readPackageUp} from 'read-pkg-up';
2
+ import {readPackageUp} from 'read-package-up';
3
3
 
4
4
  const {packageJson} = await readPackageUp({cwd: new URL('.', import.meta.url)});
5
5
 
@@ -1,4 +1,4 @@
1
- import {readPackageUp} from 'read-pkg-up';
1
+ import {readPackageUp} from 'read-package-up';
2
2
 
3
3
  export const {packageJson} = await readPackageUp({
4
4
  cwd: new URL('.', import.meta.url),
@@ -0,0 +1,17 @@
1
+ prefix ?= /usr/local
2
+ bindir = $(prefix)/bin
3
+
4
+ build:
5
+ swift build -c release --disable-sandbox
6
+
7
+ install: build
8
+ install -d "$(bindir)"
9
+ install ".build/release/dark-mode-notify" "$(bindir)"
10
+
11
+ uninstall:
12
+ rm -rf "$(bindir)/dark-mode-notify"
13
+
14
+ clean:
15
+ rm -rf .build
16
+
17
+ .PHONY: build install uninstall clean
@@ -0,0 +1,15 @@
1
+ // swift-tools-version:4.0
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "dark-mode-notify",
6
+ dependencies: [
7
+ ],
8
+ targets: [
9
+ .target(
10
+ name: "dark-mode-notify",
11
+ path: "."
12
+ )
13
+ ]
14
+ )
15
+
@@ -4,9 +4,13 @@ This small Swift program will run a command whenever the dark mode status change
4
4
 
5
5
  ## Usage
6
6
 
7
- You can run it directly by doing `./dark-mode-notify.swift <program>`.
7
+ Use make to compile the program, then run directly:
8
8
 
9
- Alternatively you can compile it by doing `swiftc dark-mode-notify.swift -o /usr/local/bin/dark-mode-notify`.
9
+ ```shell
10
+ .build/release/dark-mode-notify <your-program>
11
+ ```
12
+
13
+ Alternatively you can install it by doing `make install`.
10
14
 
11
15
  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`.
12
16
 
@@ -1,9 +1,6 @@
1
- #!/usr/bin/env swift
2
-
3
- // Run as ./notify.swift <program to run when dark mode changes>
4
1
  // The program will have the DARKMODE env flag set to 1 or 0
5
- // You can also compile with:
6
- // swiftc notify.swift -o notify
2
+ // Compile with:
3
+ // swift build
7
4
  // And run the binary directly
8
5
  // Most credit goes to https://github.com/mnewt/dotemacs/blob/master/bin/dark-mode-notifier.swift
9
6
 
@@ -35,4 +32,11 @@ DistributedNotificationCenter.default.addObserver(
35
32
  shell(args)
36
33
  }
37
34
 
35
+ NSWorkspace.shared.notificationCenter.addObserver(
36
+ forName: NSWorkspace.didWakeNotification,
37
+ object: nil,
38
+ queue: nil) { (notification) in
39
+ shell(args)
40
+ }
41
+
38
42
  NSApplication.shared.run()
@@ -15,7 +15,10 @@ export async function getLaunchAgentPlistFileContents() {
15
15
  new URL('../cli.js', import.meta.url),
16
16
  ),
17
17
  darkModeNotifyPath: fileURLToPath(
18
- new URL('../dark-mode-notify/dark-mode-notify.swift', import.meta.url),
18
+ new URL(
19
+ '../dark-mode-notify/.build/release/dark-mode-notify',
20
+ import.meta.url,
21
+ ),
19
22
  ),
20
23
  logPath: envPaths(packageJson.name).log,
21
24
  path: process.env.PATH,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "auto-terminal-profile",
3
- "version": "2.0.0",
4
- "description": "Automatically switch the macOS Terminal profile based on the system-wide dark / light appearance mode",
3
+ "version": "3.0.1",
4
+ "description": "Automatically switch macOS Terminal profile when system dark / light mode changes",
5
5
  "keywords": [
6
6
  "macos",
7
7
  "terminal",
@@ -10,30 +10,30 @@
10
10
  "profile"
11
11
  ],
12
12
  "license": "MIT",
13
- "author": "Patrik Csak <p@trikcsak.com>",
14
- "funding": "https://www.buymeacoffee.com/patrikcsak",
13
+ "author": "Patrik Csak <p@trikcsak.com> (https://patrikcsak.com)",
15
14
  "bin": "./cli.js",
16
15
  "repository": "github:patrik-csak/auto-terminal-profile",
17
16
  "scripts": {
18
- "format": "xo --fix",
19
- "test": "xo"
17
+ "format": "xo --fix && sort-package-json",
18
+ "postinstall": "cd dark-mode-notify && make build",
19
+ "test": "xo && sort-package-json --check"
20
20
  },
21
21
  "dependencies": {
22
- "commander": "^10.0.1",
23
- "conf": "^11.0.1",
24
- "dark-mode": "^4.0.0",
22
+ "commander": "^12.0.0",
23
+ "conf": "^12.0.0",
25
24
  "env-paths": "^3.0.0",
26
- "execa": "^7.1.1",
25
+ "execa": "^8.0.1",
27
26
  "pupa": "^3.1.0",
28
- "read-pkg-up": "^9.1.0",
27
+ "read-package-up": "^11.0.0",
29
28
  "terminal-profile": "^2.0.0",
30
- "untildify": "^4.0.0"
29
+ "untildify": "^5.0.0"
31
30
  },
32
31
  "devDependencies": {
33
- "xo": "^0.54.2"
32
+ "sort-package-json": "^2.7.0",
33
+ "xo": "^0.57.0"
34
34
  },
35
35
  "engines": {
36
- "node": ">=16 <=20"
36
+ "node": ">=18 <=20"
37
37
  },
38
38
  "os": [
39
39
  "darwin"
package/readme.md CHANGED
@@ -6,7 +6,7 @@ Automatically switch the macOS Terminal profile based on the system-wide dark /
6
6
 
7
7
  ## Prerequisites
8
8
 
9
- - [Node.js](https://nodejs.org/en/) 1419
9
+ - [Node.js](https://nodejs.org/en/) 1820
10
10
 
11
11
  ## Installation
12
12
 
@@ -32,4 +32,4 @@ auto-terminal-profile --help
32
32
 
33
33
  ## Acknowledgements
34
34
 
35
- Thanks to [Fatih Arslan](https://github.com/fatih) for his article [*Automatic dark mode for terminal applications*](https://arslan.io/2021/02/15/automatic-dark-mode-for-terminal-applications/) and [Bouke van der Bijl](https://github.com/bouk) for his project [dark-mode-notify](https://github.com/bouk/dark-mode-notify), which this project uses
35
+ Thanks [Bouke van der Bijl](https://bou.ke) for his project [dark-mode-notify](https://github.com/bouk/dark-mode-notify), which this project depends on
@@ -5,17 +5,22 @@
5
5
  <dict>
6
6
  <key>Label</key>
7
7
  <string>ke.bou.dark-mode-notify</string>
8
+
8
9
  <key>KeepAlive</key>
9
10
  <true/>
11
+
10
12
  <key>StandardErrorPath</key>
11
13
  <string>{logPath}/dark-mode-notify-stderr.log</string>
14
+
12
15
  <key>StandardOutPath</key>
13
16
  <string>{logPath}/dark-mode-notify-stdout.log</string>
17
+
14
18
  <key>EnvironmentVariables</key>
15
19
  <dict>
16
20
  <key>PATH</key>
17
21
  <string>{path}</string>
18
22
  </dict>
23
+
19
24
  <key>ProgramArguments</key>
20
25
  <array>
21
26
  <string>{darkModeNotifyPath}</string>