tonton-cli 1.0.1 → 1.1.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/bin/tonton.js +21 -0
- package/lib/config.js +33 -0
- package/lib/index.js +3 -0
- package/package.json +1 -1
package/bin/tonton.js
CHANGED
|
@@ -27,6 +27,9 @@ Presets:
|
|
|
27
27
|
Options:
|
|
28
28
|
-s, --sound <name> Sound to play (default: "Ping" on macOS, "chime" elsewhere)
|
|
29
29
|
-v, --volume <0-1> Volume level, 0.0 to 1.0 (macOS only, default: 1.0)
|
|
30
|
+
-m, --mute Mute all sounds (persists across runs)
|
|
31
|
+
-u, --unmute Unmute sounds
|
|
32
|
+
--status Show current mute status
|
|
30
33
|
-l, --list List available sounds
|
|
31
34
|
-h, --help Show this help
|
|
32
35
|
--version Show version
|
|
@@ -62,6 +65,24 @@ After any command:
|
|
|
62
65
|
process.exit(0);
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
if (arg === '-m' || arg === '--mute') {
|
|
69
|
+
require('../lib/config').setMuted(true);
|
|
70
|
+
console.log('Muted. Run tonton --unmute to re-enable sounds.');
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (arg === '-u' || arg === '--unmute') {
|
|
75
|
+
require('../lib/config').setMuted(false);
|
|
76
|
+
console.log('Unmuted. Sounds are back on.');
|
|
77
|
+
process.exit(0);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (arg === '--status') {
|
|
81
|
+
const muted = require('../lib/config').isMuted();
|
|
82
|
+
console.log(muted ? 'Muted' : 'Unmuted');
|
|
83
|
+
process.exit(0);
|
|
84
|
+
}
|
|
85
|
+
|
|
65
86
|
if (arg === '-l' || arg === '--list') {
|
|
66
87
|
const sounds = listSounds();
|
|
67
88
|
console.log('Available sounds:');
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
const CONFIG_DIR = path.join(os.homedir(), '.config', 'tonton');
|
|
8
|
+
const CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');
|
|
9
|
+
|
|
10
|
+
function read() {
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'));
|
|
13
|
+
} catch {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function write(config) {
|
|
19
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
20
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + '\n');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isMuted() {
|
|
24
|
+
return read().muted === true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function setMuted(muted) {
|
|
28
|
+
const config = read();
|
|
29
|
+
config.muted = muted;
|
|
30
|
+
write(config);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = { isMuted, setMuted, read, write, CONFIG_PATH };
|
package/lib/index.js
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
const { resolveSound, listSounds, generateWav } = require('./sounds');
|
|
4
4
|
const { playSound } = require('./player');
|
|
5
|
+
const { isMuted } = require('./config');
|
|
5
6
|
|
|
6
7
|
async function play(options = {}) {
|
|
7
8
|
const { sound = 'default', volume } = options;
|
|
8
9
|
|
|
10
|
+
if (isMuted()) return;
|
|
11
|
+
|
|
9
12
|
try {
|
|
10
13
|
const soundInfo = resolveSound(sound);
|
|
11
14
|
await playSound(soundInfo, { volume });
|