diff --git a/index.js b/index.js index 40a8b93..ccea032 100755 --- a/index.js +++ b/index.js @@ -8,8 +8,9 @@ import { sceneHelp, sceneList, sceneSwitch, sceneCurrent } from './utils/scene.j import { audioHelp, audioList, audioMute, audioUnmute, audioToggle, audioStatus } from './utils/audio.js' import { streamHelp, streamStart, streamStop, streamToggle, streamStatus } from './utils/stream.js' import { recordHelp, recordStart, recordStop, recordToggle, recordStatus } from './utils/record.js' -import { clipHelp, saveClip } from './utils/clip.js' -import { screenshotHelp, takeScreenshot } from './utils/screenshot.js' +import { clipHelp, clipSave } from './utils/clip.js' +import { screenshotHelp, screenshotTake } from './utils/screenshot.js' +import { virtualcamHelp, virtualcamToggle } from './utils/virtualcam.js' const input = cli.input const flags = cli.flags @@ -66,7 +67,8 @@ socket.onopen = function () { stream: streamHelp, record: recordHelp, clip: clipHelp, - screenshot: screenshotHelp + screenshot: screenshotHelp, + virtualcam: virtualcamHelp } if (flags.help && helpMap[command]) { @@ -170,17 +172,24 @@ socket.onopen = function () { } else if (command === 'clip') { const clipCommand = input[1] if (clipCommand === 'save') { - withChannel(socket, (channel) => saveClip(channel)) + withChannel(socket, (channel) => clipSave(channel)) } else { printHelp(clipHelp) } } else if (command === 'screenshot') { const screenshotCommand = input[1] if (screenshotCommand === 'take') { - withChannel(socket, (channel) => takeScreenshot(channel)) + withChannel(socket, (channel) => screenshotTake(channel)) } else { printHelp(screenshotHelp) } + } else if (command === 'virtualcam') { + const virtualcamCommand = input[1] + if (virtualcamCommand === 'toggle') { + withChannel(socket, (channel) => virtualcamToggle(channel)) + } else { + printHelp(virtualcamHelp) + } } else { printHelp(cli.help) socket.close() diff --git a/package.json b/package.json index cdde74b..dc7a874 100644 --- a/package.json +++ b/package.json @@ -49,11 +49,6 @@ "docs", "doc" ], - "env": { - "browser": true, - "node": true, - "es2021": true - }, "parserOptions": { "ecmaVersion": 12, "sourceType": "module" diff --git a/utils/cli.js b/utils/cli.js index a8f9d99..13d9106 100644 --- a/utils/cli.js +++ b/utils/cli.js @@ -19,6 +19,9 @@ const commands = { }, screenshot: { desc: 'Take a screenshot' + }, + virtualcam: { + desc: 'Manage virtual camera settings' } } diff --git a/utils/clip.js b/utils/clip.js index 26c4195..743d49a 100644 --- a/utils/clip.js +++ b/utils/clip.js @@ -18,9 +18,9 @@ const clipHelp = meowHelp({ defaults: false }) -async function saveClip (channel) { +async function clipSave (channel) { await channel.objects.meld.sendCommand('meld.recordClip') - return 'Clip command sent successfully.' + return 'Clip saved successfully.' } -export { clipHelp, saveClip } +export { clipHelp, clipSave } diff --git a/utils/screenshot.js b/utils/screenshot.js index b3dadc4..b48ecc3 100644 --- a/utils/screenshot.js +++ b/utils/screenshot.js @@ -18,9 +18,9 @@ const screenshotHelp = meowHelp({ defaults: false }) -async function takeScreenshot (channel) { +async function screenshotTake (channel) { await channel.objects.meld.sendCommand('meld.screenshot') - return 'Screenshot command sent successfully.' + return 'Screenshot taken successfully.' } -export { screenshotHelp, takeScreenshot } +export { screenshotHelp, screenshotTake } diff --git a/utils/virtualcam.js b/utils/virtualcam.js new file mode 100644 index 0000000..cf59a66 --- /dev/null +++ b/utils/virtualcam.js @@ -0,0 +1,30 @@ +import meowHelp from 'cli-meow-help' + +const commands = { + toggle: { + desc: 'Toggle the virtual camera on or off' + } +} + +const flags = { + help: { + type: 'boolean', + shortFlag: 'h', + desc: 'Display help information' + } +} + +const virtualcamHelp = meowHelp({ + name: 'virtualcam', + flags, + commands, + desc: 'Manage virtual camera settings in Meld', + defaults: false +}) + +async function virtualcamToggle (channel) { + await channel.objects.meld.sendCommand('meld.toggleVirtualCameraAction') + return 'Virtual camera toggled successfully.' +} + +export { virtualcamHelp, virtualcamToggle }