auto-terminal-profile 4.0.0 → 6.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/.prettierignore +3 -0
- package/actions/enable.js +47 -13
- package/actions/set-mode-profile.js +15 -1
- package/actions/update-profile.js +4 -7
- package/changelog.md +24 -7
- package/config.js +2 -2
- package/dark-mode-notify/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +7 -0
- package/dark-mode-notify/.swiftpm/xcode/package.xcworkspace/xcuserdata/patrik.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/dark-mode-notify/.swiftpm/xcode/xcuserdata/patrik.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/eslint.config.js +3 -0
- package/functions/disable-automatic-switching.js +1 -1
- package/functions/enable-automatic-switching.js +1 -1
- package/functions/get-current-mode.js +8 -0
- package/functions/index.js +2 -0
- package/functions/is-automatic-switching-enabled.js +1 -1
- package/functions/set-terminal-profile.js +11 -0
- package/package.json +20 -12
- package/prettier.config.js +11 -0
package/.prettierignore
ADDED
package/actions/enable.js
CHANGED
|
@@ -1,24 +1,58 @@
|
|
|
1
1
|
import {config} from '../config.js';
|
|
2
2
|
import {packageJson} from '../constants/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
enableAutomaticSwitching,
|
|
5
|
+
getCurrentMode,
|
|
6
|
+
isTerminalOpen,
|
|
7
|
+
setTerminalProfile,
|
|
8
|
+
} from '../functions/index.js';
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} mode
|
|
12
|
+
*/
|
|
13
|
+
function undefinedProfileMessage(mode) {
|
|
14
|
+
return `${mode} profile must be specified with --${mode}-profile or previously set with \`${packageJson.name} set-${mode}-mode\``;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {object} parameters
|
|
19
|
+
* @param {string|undefined} parameters.darkProfile
|
|
20
|
+
* @param {string|undefined} parameters.lightProfile
|
|
21
|
+
*/
|
|
22
|
+
export async function enable(parameters) {
|
|
23
|
+
if (
|
|
24
|
+
[parameters.darkProfile, config.darkProfile].every(
|
|
25
|
+
(value) => value === undefined,
|
|
26
|
+
)
|
|
27
|
+
) {
|
|
28
|
+
throw new Error(undefinedProfileMessage('dark'));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
[parameters.lightProfile, config.lightProfile].every(
|
|
33
|
+
(value) => value === undefined,
|
|
34
|
+
)
|
|
35
|
+
) {
|
|
36
|
+
throw new Error(undefinedProfileMessage('light'));
|
|
10
37
|
}
|
|
11
38
|
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
`Light profile must be specified with --light-profile or previously set with \`${packageJson.name} set-light-mode\``,
|
|
15
|
-
);
|
|
39
|
+
if (parameters.darkProfile !== undefined) {
|
|
40
|
+
config.darkProfile = parameters.darkProfile;
|
|
16
41
|
}
|
|
17
42
|
|
|
18
|
-
if (
|
|
19
|
-
|
|
43
|
+
if (parameters.lightProfile !== undefined) {
|
|
44
|
+
config.lightProfile = parameters.lightProfile;
|
|
45
|
+
}
|
|
20
46
|
|
|
21
47
|
await enableAutomaticSwitching();
|
|
22
48
|
|
|
23
|
-
|
|
49
|
+
if (await isTerminalOpen()) {
|
|
50
|
+
const mode = await getCurrentMode();
|
|
51
|
+
|
|
52
|
+
if (parameters[`${mode}Profile`] !== undefined) {
|
|
53
|
+
await setTerminalProfile(config[`${mode}Profile`]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log('automatic switching enabled');
|
|
24
58
|
}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import {config} from '../config.js';
|
|
2
|
+
import {
|
|
3
|
+
getCurrentMode,
|
|
4
|
+
isAutomaticSwitchingEnabled,
|
|
5
|
+
isTerminalOpen,
|
|
6
|
+
setTerminalProfile,
|
|
7
|
+
} from '../functions/index.js';
|
|
2
8
|
|
|
3
|
-
export function setModeProfile({mode, profile}) {
|
|
9
|
+
export async function setModeProfile({mode, profile}) {
|
|
4
10
|
config[`${mode}Profile`] = profile;
|
|
5
11
|
|
|
12
|
+
if ((await isAutomaticSwitchingEnabled()) && (await isTerminalOpen())) {
|
|
13
|
+
const currentMode = await getCurrentMode();
|
|
14
|
+
|
|
15
|
+
if (currentMode === mode) {
|
|
16
|
+
await setTerminalProfile(profile);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
6
20
|
console.log(`${mode} mode profile set to '${profile}'`);
|
|
7
21
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import darkMode from 'dark-mode';
|
|
2
|
-
import {setTerminalProfile, setTerminalDefaultProfile} from 'terminal-profile';
|
|
3
1
|
import {config} from '../config.js';
|
|
4
2
|
import {
|
|
3
|
+
getCurrentMode,
|
|
5
4
|
isAutomaticSwitchingEnabled,
|
|
6
5
|
isTerminalOpen,
|
|
6
|
+
setTerminalProfile,
|
|
7
7
|
} from '../functions/index.js';
|
|
8
8
|
|
|
9
9
|
export async function updateProfile() {
|
|
@@ -19,11 +19,8 @@ export async function updateProfile() {
|
|
|
19
19
|
throw new Error('Light profile not set');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const mode =
|
|
22
|
+
const mode = await getCurrentMode();
|
|
23
23
|
const profile = config[`${mode}Profile`];
|
|
24
24
|
|
|
25
|
-
await
|
|
26
|
-
setTerminalProfile(profile),
|
|
27
|
-
setTerminalDefaultProfile(profile),
|
|
28
|
-
]);
|
|
25
|
+
await setTerminalProfile(profile);
|
|
29
26
|
}
|
package/changelog.md
CHANGED
|
@@ -5,29 +5,46 @@ 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
|
+
## [6.0.0](https://github.com/patrik-csak/auto-terminal-profile/compare/v5.0.0...v6.0.0) – 2025-05-27
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
-
|
|
12
|
+
- Support for Node.js v22–24
|
|
13
|
+
|
|
14
|
+
### Removed
|
|
15
|
+
|
|
16
|
+
- **BREAKING**: Support for Node.js versions before v20
|
|
17
|
+
|
|
18
|
+
## [5.0.0](https://github.com/patrik-csak/auto-terminal-profile/compare/v4.0.0...v5.0.0) – 2024-11-27
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **BREAKING**: `enable` and `set-(dark|light)-profile` now set the Terminal profile
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
25
|
+
## [4.0.0](https://github.com/patrik-csak/auto-terminal-profile/compare/v3.0.2...v4.0.0) – 2024-03-25
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Documentation explaining how to automatically update Terminal profile when opening Terminal
|
|
13
30
|
|
|
14
31
|
### Changed
|
|
15
32
|
|
|
16
33
|
- **BREAKING**: `update-profile` gets appearance mode from OS instead of from `DARKMODE` environment variable
|
|
17
34
|
|
|
18
|
-
## [3.0.2](https://github.com/patrik-csak/terminal-profile/compare/v3.0.1...v3.0.2) – 2024-02-21
|
|
35
|
+
## [3.0.2](https://github.com/patrik-csak/auto-terminal-profile/compare/v3.0.1...v3.0.2) – 2024-02-21
|
|
19
36
|
|
|
20
37
|
### Fixed
|
|
21
38
|
|
|
22
39
|
- Fix Terminal opening when closed
|
|
23
40
|
|
|
24
|
-
## [3.0.1](https://github.com/patrik-csak/terminal-profile/compare/v3.0.0...v3.0.1) – 2024-02-20
|
|
41
|
+
## [3.0.1](https://github.com/patrik-csak/auto-terminal-profile/compare/v3.0.0...v3.0.1) – 2024-02-20
|
|
25
42
|
|
|
26
43
|
### Fixed
|
|
27
44
|
|
|
28
45
|
- Fix broken post-install compilation step
|
|
29
46
|
|
|
30
|
-
## [3.0.0](https://github.com/patrik-csak/terminal-profile/compare/v2.1.0...v3.0.0) – 2024-02-19
|
|
47
|
+
## [3.0.0](https://github.com/patrik-csak/auto-terminal-profile/compare/v2.1.0...v3.0.0) – 2024-02-19
|
|
31
48
|
|
|
32
49
|
### Changed
|
|
33
50
|
|
|
@@ -41,13 +58,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
41
58
|
|
|
42
59
|
- Fix issue causing `auto-terminal-profile` to silently fail on macOS Sonoma
|
|
43
60
|
|
|
44
|
-
## [2.1.0](https://github.com/patrik-csak/terminal-profile/compare/v2.0.0...v2.1.0) – 2023-07-04
|
|
61
|
+
## [2.1.0](https://github.com/patrik-csak/auto-terminal-profile/compare/v2.0.0...v2.1.0) – 2023-07-04
|
|
45
62
|
|
|
46
63
|
### Changed
|
|
47
64
|
|
|
48
65
|
- Update dependencies
|
|
49
66
|
|
|
50
|
-
## [2.0.0](https://github.com/patrik-csak/terminal-profile/compare/v1.1.1...v2.0.0) – 2023-05-10
|
|
67
|
+
## [2.0.0](https://github.com/patrik-csak/auto-terminal-profile/compare/v1.1.1...v2.0.0) – 2023-05-10
|
|
51
68
|
|
|
52
69
|
### Added
|
|
53
70
|
|
package/config.js
CHANGED
|
@@ -12,7 +12,7 @@ class Config {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @return {string}
|
|
15
|
+
* @return {string|undefined}
|
|
16
16
|
*/
|
|
17
17
|
get darkProfile() {
|
|
18
18
|
return config_.get(this.keys.darkProfile);
|
|
@@ -26,7 +26,7 @@ class Config {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @return {string}
|
|
29
|
+
* @return {string|undefined}
|
|
30
30
|
*/
|
|
31
31
|
get lightProfile() {
|
|
32
32
|
return config_.get(this.keys.lightProfile);
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>dark-mode-notify.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
package/eslint.config.js
ADDED
|
@@ -3,7 +3,7 @@ import {execa} from 'execa';
|
|
|
3
3
|
import {launchAgentPlistFilePath} from '../constants/index.js';
|
|
4
4
|
|
|
5
5
|
export async function disableAutomaticSwitching() {
|
|
6
|
-
await execa
|
|
6
|
+
await execa`launchctl unload -w ${launchAgentPlistFilePath}`;
|
|
7
7
|
|
|
8
8
|
await unlink(launchAgentPlistFilePath);
|
|
9
9
|
}
|
package/functions/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export {enableAutomaticSwitching} from './enable-automatic-switching.js';
|
|
2
2
|
export {disableAutomaticSwitching} from './disable-automatic-switching.js';
|
|
3
|
+
export {getCurrentMode} from './get-current-mode.js';
|
|
3
4
|
export {getLaunchAgentPlistFileContents} from './get-launch-agent-plist-file-contents.js';
|
|
4
5
|
export {isAutomaticSwitchingEnabled} from './is-automatic-switching-enabled.js';
|
|
5
6
|
export {isTerminalOpen} from './is-terminal-open.js';
|
|
7
|
+
export {setTerminalProfile} from './set-terminal-profile.js';
|
|
@@ -6,7 +6,7 @@ import {launchAgentPlistFilePath} from '../constants/index.js';
|
|
|
6
6
|
* @return {Promise<boolean>}
|
|
7
7
|
*/
|
|
8
8
|
async function isDarkModeNotifyRunning() {
|
|
9
|
-
const {stdout} = await execa
|
|
9
|
+
const {stdout} = await execa`launchctl list`;
|
|
10
10
|
|
|
11
11
|
return stdout.includes('ke.bou.dark-mode-notify');
|
|
12
12
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setTerminalDefaultProfile as setDefaultProfile,
|
|
3
|
+
setTerminalProfile as setProfile,
|
|
4
|
+
} from 'terminal-profile';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} profile
|
|
8
|
+
*/
|
|
9
|
+
export async function setTerminalProfile(profile) {
|
|
10
|
+
await Promise.all([setDefaultProfile(profile), setProfile(profile)]);
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auto-terminal-profile",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Automatically switch macOS Terminal profile when system dark / light mode changes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"macos",
|
|
@@ -9,35 +9,43 @@
|
|
|
9
9
|
"dark mode",
|
|
10
10
|
"profile"
|
|
11
11
|
],
|
|
12
|
-
"repository":
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/patrik-csak/auto-terminal-profile.git"
|
|
15
|
+
},
|
|
13
16
|
"funding": "https://buymeacoffee.com/patrikcsak",
|
|
14
17
|
"license": "MIT",
|
|
15
18
|
"author": "Patrik Csak <p@trikcsak.com> (https://patrikcsak.com)",
|
|
16
19
|
"type": "module",
|
|
17
|
-
"bin":
|
|
20
|
+
"bin": {
|
|
21
|
+
"auto-terminal-profile": "cli.js"
|
|
22
|
+
},
|
|
18
23
|
"scripts": {
|
|
19
|
-
"format": "
|
|
24
|
+
"format": "eslint --fix && npm run prettier -- --write && sort-package-json",
|
|
20
25
|
"postinstall": "cd dark-mode-notify && make build",
|
|
21
|
-
"
|
|
26
|
+
"prettier": "prettier .",
|
|
27
|
+
"test": "eslint && npm run prettier -- --check && sort-package-json --check"
|
|
22
28
|
},
|
|
23
29
|
"dependencies": {
|
|
24
|
-
"commander": "^
|
|
25
|
-
"conf": "^
|
|
30
|
+
"commander": "^14.0.0",
|
|
31
|
+
"conf": "^13.0.1",
|
|
26
32
|
"dark-mode": "^4.0.0",
|
|
27
33
|
"env-paths": "^3.0.0",
|
|
28
|
-
"execa": "^
|
|
34
|
+
"execa": "^9.5.1",
|
|
29
35
|
"pupa": "^3.1.0",
|
|
30
36
|
"read-package-up": "^11.0.0",
|
|
31
37
|
"run-applescript": "^7.0.0",
|
|
32
|
-
"terminal-profile": "^
|
|
38
|
+
"terminal-profile": "^3.0.0",
|
|
33
39
|
"untildify": "^5.0.0"
|
|
34
40
|
},
|
|
35
41
|
"devDependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
42
|
+
"eslint": "^9.27.0",
|
|
43
|
+
"prettier": "^3.5.3",
|
|
44
|
+
"sort-package-json": "^3.2.1",
|
|
45
|
+
"xo": "^1.0.0"
|
|
38
46
|
},
|
|
39
47
|
"engines": {
|
|
40
|
-
"node": ">=
|
|
48
|
+
"node": ">=20 <=24"
|
|
41
49
|
},
|
|
42
50
|
"os": [
|
|
43
51
|
"darwin"
|