auto-terminal-profile 3.0.1 → 4.0.0
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.
- package/.github/funding.yml +1 -0
- package/actions/update-profile.js +10 -2
- package/changelog.md +26 -6
- package/config.js +5 -5
- package/functions/index.js +1 -0
- package/functions/is-terminal-open.js +18 -0
- package/package.json +7 -4
- package/readme.md +26 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
buy_me_a_coffee: patrikcsak
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import darkMode from 'dark-mode';
|
|
2
2
|
import {setTerminalProfile, setTerminalDefaultProfile} from 'terminal-profile';
|
|
3
3
|
import {config} from '../config.js';
|
|
4
|
+
import {
|
|
5
|
+
isAutomaticSwitchingEnabled,
|
|
6
|
+
isTerminalOpen,
|
|
7
|
+
} from '../functions/index.js';
|
|
4
8
|
|
|
5
9
|
export async function updateProfile() {
|
|
10
|
+
if (!(await isAutomaticSwitchingEnabled()) || !(await isTerminalOpen())) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
if (!config.darkProfile) {
|
|
7
15
|
throw new Error('Dark profile not set');
|
|
8
16
|
}
|
|
@@ -11,7 +19,7 @@ export async function updateProfile() {
|
|
|
11
19
|
throw new Error('Light profile not set');
|
|
12
20
|
}
|
|
13
21
|
|
|
14
|
-
const mode =
|
|
22
|
+
const mode = (await darkMode.isEnabled()) ? 'dark' : 'light';
|
|
15
23
|
const profile = config[`${mode}Profile`];
|
|
16
24
|
|
|
17
25
|
await Promise.all([
|
package/changelog.md
CHANGED
|
@@ -5,13 +5,33 @@ 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
|
-
## [
|
|
8
|
+
## [4.0.0](https://github.com/patrik-csak/terminal-profile/compare/v3.0.2...v4.0.0) – 2024-03-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Documentation explaining how to automatically update Terminal profile when opening Terminal
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **BREAKING**: `update-profile` gets appearance mode from OS instead of from `DARKMODE` environment variable
|
|
17
|
+
|
|
18
|
+
## [3.0.2](https://github.com/patrik-csak/terminal-profile/compare/v3.0.1...v3.0.2) – 2024-02-21
|
|
9
19
|
|
|
10
20
|
### Fixed
|
|
11
21
|
|
|
12
|
-
-
|
|
22
|
+
- Fix Terminal opening when closed
|
|
23
|
+
|
|
24
|
+
## [3.0.1](https://github.com/patrik-csak/terminal-profile/compare/v3.0.0...v3.0.1) – 2024-02-20
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Fix broken post-install compilation step
|
|
29
|
+
|
|
30
|
+
## [3.0.0](https://github.com/patrik-csak/terminal-profile/compare/v2.1.0...v3.0.0) – 2024-02-19
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
13
33
|
|
|
14
|
-
|
|
34
|
+
- **BREAKING**: `update-profile` gets appearance mode from `DARKMODE` environment variable instead of from OS
|
|
15
35
|
|
|
16
36
|
### Removed
|
|
17
37
|
|
|
@@ -19,15 +39,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
39
|
|
|
20
40
|
### Fixed
|
|
21
41
|
|
|
22
|
-
-
|
|
42
|
+
- Fix issue causing `auto-terminal-profile` to silently fail on macOS Sonoma
|
|
23
43
|
|
|
24
|
-
## [
|
|
44
|
+
## [2.1.0](https://github.com/patrik-csak/terminal-profile/compare/v2.0.0...v2.1.0) – 2023-07-04
|
|
25
45
|
|
|
26
46
|
### Changed
|
|
27
47
|
|
|
28
48
|
- Update dependencies
|
|
29
49
|
|
|
30
|
-
## [2.0.0](https://github.com/
|
|
50
|
+
## [2.0.0](https://github.com/patrik-csak/terminal-profile/compare/v1.1.1...v2.0.0) – 2023-05-10
|
|
31
51
|
|
|
32
52
|
### Added
|
|
33
53
|
|
package/config.js
CHANGED
|
@@ -3,7 +3,7 @@ import {readPackageUp} from 'read-package-up';
|
|
|
3
3
|
|
|
4
4
|
const {packageJson} = await readPackageUp({cwd: new URL('.', import.meta.url)});
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const config_ = new Conf({projectName: packageJson.name});
|
|
7
7
|
|
|
8
8
|
class Config {
|
|
9
9
|
keys = {
|
|
@@ -15,28 +15,28 @@ class Config {
|
|
|
15
15
|
* @return {string}
|
|
16
16
|
*/
|
|
17
17
|
get darkProfile() {
|
|
18
|
-
return
|
|
18
|
+
return config_.get(this.keys.darkProfile);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @param {string} profile
|
|
23
23
|
*/
|
|
24
24
|
set darkProfile(profile) {
|
|
25
|
-
|
|
25
|
+
config_.set(this.keys.darkProfile, profile);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* @return {string}
|
|
30
30
|
*/
|
|
31
31
|
get lightProfile() {
|
|
32
|
-
return
|
|
32
|
+
return config_.get(this.keys.lightProfile);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* @param {string} profile
|
|
37
37
|
*/
|
|
38
38
|
set lightProfile(profile) {
|
|
39
|
-
|
|
39
|
+
config_.set(this.keys.lightProfile, profile);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
package/functions/index.js
CHANGED
|
@@ -2,3 +2,4 @@ export {enableAutomaticSwitching} from './enable-automatic-switching.js';
|
|
|
2
2
|
export {disableAutomaticSwitching} from './disable-automatic-switching.js';
|
|
3
3
|
export {getLaunchAgentPlistFileContents} from './get-launch-agent-plist-file-contents.js';
|
|
4
4
|
export {isAutomaticSwitchingEnabled} from './is-automatic-switching-enabled.js';
|
|
5
|
+
export {isTerminalOpen} from './is-terminal-open.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {runAppleScript} from 'run-applescript';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @returns {Promise<boolean>}
|
|
5
|
+
*/
|
|
6
|
+
export async function isTerminalOpen() {
|
|
7
|
+
const result = await runAppleScript(`tell application "System Events"
|
|
8
|
+
set isOpen to (name of processes) contains "Terminal"
|
|
9
|
+
end tell
|
|
10
|
+
|
|
11
|
+
if isOpen then
|
|
12
|
+
return "true"
|
|
13
|
+
else
|
|
14
|
+
return "false"
|
|
15
|
+
end if`);
|
|
16
|
+
|
|
17
|
+
return result === 'true';
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auto-terminal-profile",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Automatically switch macOS Terminal profile when system dark / light mode changes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"macos",
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
"dark mode",
|
|
10
10
|
"profile"
|
|
11
11
|
],
|
|
12
|
+
"repository": "github:patrik-csak/auto-terminal-profile",
|
|
13
|
+
"funding": "https://buymeacoffee.com/patrikcsak",
|
|
12
14
|
"license": "MIT",
|
|
13
15
|
"author": "Patrik Csak <p@trikcsak.com> (https://patrikcsak.com)",
|
|
16
|
+
"type": "module",
|
|
14
17
|
"bin": "./cli.js",
|
|
15
|
-
"repository": "github:patrik-csak/auto-terminal-profile",
|
|
16
18
|
"scripts": {
|
|
17
19
|
"format": "xo --fix && sort-package-json",
|
|
18
20
|
"postinstall": "cd dark-mode-notify && make build",
|
|
@@ -21,10 +23,12 @@
|
|
|
21
23
|
"dependencies": {
|
|
22
24
|
"commander": "^12.0.0",
|
|
23
25
|
"conf": "^12.0.0",
|
|
26
|
+
"dark-mode": "^4.0.0",
|
|
24
27
|
"env-paths": "^3.0.0",
|
|
25
28
|
"execa": "^8.0.1",
|
|
26
29
|
"pupa": "^3.1.0",
|
|
27
30
|
"read-package-up": "^11.0.0",
|
|
31
|
+
"run-applescript": "^7.0.0",
|
|
28
32
|
"terminal-profile": "^2.0.0",
|
|
29
33
|
"untildify": "^5.0.0"
|
|
30
34
|
},
|
|
@@ -37,6 +41,5 @@
|
|
|
37
41
|
},
|
|
38
42
|
"os": [
|
|
39
43
|
"darwin"
|
|
40
|
-
]
|
|
41
|
-
"type": "module"
|
|
44
|
+
]
|
|
42
45
|
}
|
package/readme.md
CHANGED
|
@@ -1,35 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Auto Terminal Profile
|
|
2
2
|
|
|
3
|
-
Automatically switch
|
|
3
|
+
Automatically switch [macOS Terminal](https://en.wikipedia.org/wiki/Terminal_%28macOS%29) profiles when the [dark / light appearance mode](https://support.apple.com/guide/mac-help/use-a-light-or-dark-appearance-mchl52e1c2d2/mac) changes
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
7
|
## Prerequisites
|
|
8
8
|
|
|
9
|
-
- [Node.js](https://nodejs.org/
|
|
9
|
+
- [Node.js](https://nodejs.org/) 18–20
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```shell
|
|
14
14
|
npm install --global auto-terminal-profile
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
+
### Enable automatic profile switching
|
|
20
|
+
|
|
19
21
|
To get started, enable automatic profile switching and set your preferred dark and light mode profiles:
|
|
20
22
|
|
|
21
|
-
```
|
|
23
|
+
```shell
|
|
22
24
|
auto-terminal-profile enable \
|
|
23
25
|
--dark-profile='One Dark' \
|
|
24
26
|
--light-profile='One Light'
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
### Switch profile on Terminal startup
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
Auto Terminal Profile only runs if Terminal is running, so the profile can fall out of sync if the macOS appearance mode changes while Terminal isn’t running.
|
|
32
|
+
|
|
33
|
+
To sync the Terminal profile to the current macOS appearance mode once:
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
auto-terminal-profile update-profile
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To sync the Terminal profile to the current macOS appearance mode when Terminal app is opened, you can add that line to your shell startup script (e.g. `.zshrc`), but it will increase the startup time of new shell sessions.
|
|
40
|
+
|
|
41
|
+
### Disable automatic profile switching
|
|
42
|
+
|
|
43
|
+
```shell
|
|
44
|
+
auto-terminal-profile disable
|
|
31
45
|
```
|
|
32
46
|
|
|
33
|
-
|
|
47
|
+
### Help
|
|
34
48
|
|
|
35
|
-
|
|
49
|
+
```shell
|
|
50
|
+
auto-terminal-profile --help
|
|
51
|
+
```
|