mirror of
https://github.com/yannbertrand/macos-defaults
synced 2025-01-07 08:58:45 +00:00
🔥 Remove deprecated screen recorder code
This commit is contained in:
parent
5b33a7d65e
commit
1f02b3add1
47 changed files with 0 additions and 5401 deletions
|
@ -1 +0,0 @@
|
|||
16.20.2
|
|
@ -1,89 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock autohide-delay with param set to 0.5')
|
||||
|
||||
const { stderr: setEnvError } = await exec(
|
||||
'defaults write com.apple.dock autohide -bool true && defaults write com.apple.dock autohide-delay -float 0.5 && killall Dock',
|
||||
)
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the dock autohide-delay command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await delay(1000)
|
||||
|
||||
const { height } = robot.getScreenSize()
|
||||
const pos1 = { x: 475, y: height - 100 }
|
||||
const pos2 = { x: 495, y: height }
|
||||
const pos3 = { x: 500, y: height - 80 }
|
||||
const recordWidth = 441
|
||||
const recordHeight = 150
|
||||
const cropArea = {
|
||||
x: pos2.x - recordWidth / 2,
|
||||
y: 0,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
robot.mouseClick()
|
||||
await delay(500)
|
||||
robot.moveMouseSmooth(pos1.x, pos2.y)
|
||||
await delay(500)
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ highlightClicks: true, cropArea })
|
||||
|
||||
await delay(200)
|
||||
robot.moveMouseSmooth(pos2.x, pos2.y, 2)
|
||||
await delay(1000)
|
||||
robot.moveMouseSmooth(pos3.x, pos3.y, 5)
|
||||
await delay(100)
|
||||
robot.moveMouseSmooth(pos1.x, pos1.y, 10)
|
||||
await delay(500)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, '0.5')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-delay && killall Dock',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the dock autohide-delay environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/0.5`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-delay && killall Dock',
|
||||
)
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock autohide-delay with param set to 0')
|
||||
|
||||
const { stderr: setEnvError } = await exec(
|
||||
'defaults write com.apple.dock autohide -bool true && defaults write com.apple.dock autohide-delay -float 0 && killall Dock',
|
||||
)
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the dock autohide-delay command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await delay(1000)
|
||||
|
||||
const { height } = robot.getScreenSize()
|
||||
const pos1 = { x: 475, y: height - 100 }
|
||||
const pos2 = { x: 495, y: height }
|
||||
const pos3 = { x: 500, y: height - 80 }
|
||||
const recordWidth = 441
|
||||
const recordHeight = 150
|
||||
const cropArea = {
|
||||
x: pos2.x - recordWidth / 2,
|
||||
y: 0,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
robot.mouseClick()
|
||||
await delay(500)
|
||||
robot.moveMouseSmooth(pos1.x, pos2.y)
|
||||
await delay(500)
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ highlightClicks: true, cropArea })
|
||||
|
||||
await delay(200)
|
||||
robot.moveMouseSmooth(pos2.x, pos2.y, 2)
|
||||
await delay(1000)
|
||||
robot.moveMouseSmooth(pos3.x, pos3.y, 5)
|
||||
await delay(100)
|
||||
robot.moveMouseSmooth(pos1.x, pos1.y, 10)
|
||||
await delay(500)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, '0')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-delay && killall Dock',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the dock autohide-delay environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/0`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-delay && killall Dock',
|
||||
)
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock autohide-time-modifier with param set to 0.5')
|
||||
|
||||
const { stderr: setEnvError } = await exec(
|
||||
'defaults write com.apple.dock autohide -bool true && defaults write com.apple.dock autohide-time-modifier -float 0.5 && killall Dock',
|
||||
)
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the dock autohide-time-modifier command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await delay(1000)
|
||||
|
||||
const { height } = robot.getScreenSize()
|
||||
const pos1 = { x: 475, y: height - 100 }
|
||||
const pos2 = { x: 495, y: height }
|
||||
const pos3 = { x: 500, y: height - 80 }
|
||||
const recordWidth = 441
|
||||
const recordHeight = 150
|
||||
const cropArea = {
|
||||
x: pos2.x - recordWidth / 2,
|
||||
y: 0,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
robot.mouseClick()
|
||||
await delay(500)
|
||||
robot.moveMouseSmooth(pos1.x, pos2.y)
|
||||
await delay(500)
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ highlightClicks: true, cropArea })
|
||||
|
||||
await delay(200)
|
||||
robot.moveMouseSmooth(pos2.x, pos2.y, 2)
|
||||
await delay(1000)
|
||||
robot.moveMouseSmooth(pos3.x, pos3.y, 5)
|
||||
await delay(100)
|
||||
robot.moveMouseSmooth(pos1.x, pos1.y, 10)
|
||||
await delay(500)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, '0.5')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-time-modifier && killall Dock',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the dock autohide-time-modifier environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/0.5`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-time-modifier && killall Dock',
|
||||
)
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock autohide-time-modifier with param set to 0')
|
||||
|
||||
const { stderr: setEnvError } = await exec(
|
||||
'defaults write com.apple.dock autohide -bool true && defaults write com.apple.dock autohide-time-modifier -float 0 && killall Dock',
|
||||
)
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the dock autohide-time-modifier command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await delay(1000)
|
||||
|
||||
const { height } = robot.getScreenSize()
|
||||
const pos1 = { x: 475, y: height - 100 }
|
||||
const pos2 = { x: 495, y: height }
|
||||
const pos3 = { x: 500, y: height - 80 }
|
||||
const recordWidth = 441
|
||||
const recordHeight = 150
|
||||
const cropArea = {
|
||||
x: pos2.x - recordWidth / 2,
|
||||
y: 0,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
robot.mouseClick()
|
||||
await delay(500)
|
||||
robot.moveMouseSmooth(pos1.x, pos2.y)
|
||||
await delay(500)
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ highlightClicks: true, cropArea })
|
||||
|
||||
await delay(200)
|
||||
robot.moveMouseSmooth(pos2.x, pos2.y, 2)
|
||||
await delay(1000)
|
||||
robot.moveMouseSmooth(pos3.x, pos3.y, 5)
|
||||
await delay(100)
|
||||
robot.moveMouseSmooth(pos1.x, pos1.y, 10)
|
||||
await delay(500)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, '0')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-time-modifier && killall Dock',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the dock autohide-time-modifier environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/0`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-time-modifier && killall Dock',
|
||||
)
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock autohide-time-modifier with param set to 2')
|
||||
|
||||
const { stderr: setEnvError } = await exec(
|
||||
'defaults write com.apple.dock autohide -bool true && defaults write com.apple.dock autohide-time-modifier -float 2 && killall Dock',
|
||||
)
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the dock autohide-time-modifier command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await delay(1000)
|
||||
|
||||
const { height } = robot.getScreenSize()
|
||||
const pos1 = { x: 475, y: height - 100 }
|
||||
const pos2 = { x: 495, y: height }
|
||||
const pos3 = { x: 500, y: height - 80 }
|
||||
const recordWidth = 441
|
||||
const recordHeight = 150
|
||||
const cropArea = {
|
||||
x: pos2.x - recordWidth / 2,
|
||||
y: 0,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
robot.mouseClick()
|
||||
await delay(500)
|
||||
robot.moveMouseSmooth(pos1.x, pos2.y)
|
||||
await delay(500)
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ highlightClicks: true, cropArea })
|
||||
|
||||
await delay(200)
|
||||
robot.moveMouseSmooth(pos2.x, pos2.y, 2)
|
||||
await delay(1000)
|
||||
robot.moveMouseSmooth(pos3.x, pos3.y, 5)
|
||||
await delay(100)
|
||||
robot.moveMouseSmooth(pos1.x, pos1.y, 10)
|
||||
await delay(500)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, '2')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-time-modifier && killall Dock',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the dock autohide-time-modifier environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/2`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-time-modifier && killall Dock',
|
||||
)
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const {
|
||||
makeAppActive,
|
||||
moveAndResizeApp,
|
||||
compressVideo,
|
||||
} = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock mineffect with param set to genie')
|
||||
|
||||
const { stderr: setEnvError } = await exec(
|
||||
'defaults write com.apple.dock mineffect -string genie && killall Dock',
|
||||
)
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the dock mineffect command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await makeAppActive('System Preferences')
|
||||
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const pos1 = { x: width - 932, y: height - 695 }
|
||||
const pos2 = { x: width - 270, y: height - 50 }
|
||||
const recordWidth = 1000
|
||||
const recordHeight = 750
|
||||
const cropArea = {
|
||||
x: width - recordWidth,
|
||||
y: 0,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
const windowCropArea = {
|
||||
x: cropArea.x + 21,
|
||||
y: 156,
|
||||
width: 668,
|
||||
height: 568,
|
||||
}
|
||||
|
||||
await moveAndResizeApp('System Preferences', windowCropArea, height)
|
||||
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ highlightClicks: true, cropArea })
|
||||
|
||||
await delay(500)
|
||||
robot.mouseClick()
|
||||
await delay(500)
|
||||
robot.moveMouseSmooth(pos2.x, pos2.y, 2)
|
||||
await delay(800)
|
||||
robot.mouseClick()
|
||||
await delay(800)
|
||||
robot.moveMouseSmooth(pos1.x, pos1.y, 2)
|
||||
await delay(800)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
robot.keyTap('q', 'command')
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, 'genie')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.dock mineffect && killall Dock',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the dock mineffect environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/genie`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock mineffect && killall Dock')
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const {
|
||||
makeAppActive,
|
||||
moveAndResizeApp,
|
||||
compressVideo,
|
||||
} = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock mineffect with param set to scale')
|
||||
|
||||
const { stderr: setEnvError } = await exec(
|
||||
'defaults write com.apple.dock mineffect -string scale && killall Dock',
|
||||
)
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the dock mineffect command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await makeAppActive('System Preferences')
|
||||
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const pos1 = { x: width - 932, y: height - 695 }
|
||||
const pos2 = { x: width - 270, y: height - 50 }
|
||||
const recordWidth = 1000
|
||||
const recordHeight = 750
|
||||
const cropArea = {
|
||||
x: width - recordWidth,
|
||||
y: 0,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
const windowCropArea = {
|
||||
x: cropArea.x + 21,
|
||||
y: 156,
|
||||
width: 668,
|
||||
height: 568,
|
||||
}
|
||||
|
||||
await moveAndResizeApp('System Preferences', windowCropArea, height)
|
||||
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ highlightClicks: true, cropArea })
|
||||
|
||||
await delay(500)
|
||||
robot.mouseClick()
|
||||
await delay(500)
|
||||
robot.moveMouseSmooth(pos2.x, pos2.y, 2)
|
||||
await delay(800)
|
||||
robot.mouseClick()
|
||||
await delay(800)
|
||||
robot.moveMouseSmooth(pos1.x, pos1.y, 2)
|
||||
await delay(800)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
robot.keyTap('q', 'command')
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, 'scale')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.dock mineffect && killall Dock',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the dock mineffect environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/scale`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock mineffect && killall Dock')
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const {
|
||||
makeAppActive,
|
||||
moveAndResizeApp,
|
||||
compressVideo,
|
||||
} = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock mineffect with param set to suck')
|
||||
|
||||
const { stderr: setEnvError } = await exec(
|
||||
'defaults write com.apple.dock mineffect -string suck && killall Dock',
|
||||
)
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the dock mineffect command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await makeAppActive('System Preferences')
|
||||
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const pos1 = { x: width - 932, y: height - 695 }
|
||||
const pos2 = { x: width - 270, y: height - 50 }
|
||||
const recordWidth = 1000
|
||||
const recordHeight = 750
|
||||
const cropArea = {
|
||||
x: width - recordWidth,
|
||||
y: 0,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
const windowCropArea = {
|
||||
x: cropArea.x + 21,
|
||||
y: 156,
|
||||
width: 668,
|
||||
height: 568,
|
||||
}
|
||||
|
||||
await moveAndResizeApp('System Preferences', windowCropArea, height)
|
||||
|
||||
robot.moveMouse(pos1.x, pos1.y)
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ highlightClicks: true, cropArea })
|
||||
|
||||
await delay(500)
|
||||
robot.mouseClick()
|
||||
await delay(500)
|
||||
robot.moveMouseSmooth(pos2.x, pos2.y, 2)
|
||||
await delay(800)
|
||||
robot.mouseClick()
|
||||
await delay(800)
|
||||
robot.moveMouseSmooth(pos1.x, pos1.y, 2)
|
||||
await delay(800)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
robot.keyTap('q', 'command')
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, 'suck')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.dock mineffect && killall Dock',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the dock mineffect environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/suck`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock mineffect && killall Dock')
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock orientation with param set to bottom')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.dock', 'orientation', '-string bottom', 'bottom')
|
||||
.killApp('Dock')
|
||||
.wait(1000)
|
||||
.captureScreen(`${outputPath}/bottom-tmp.png`)
|
||||
.deleteDefault('com.apple.dock', 'orientation')
|
||||
.killApp('Dock')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(
|
||||
`${outputPath}/bottom-tmp.png`,
|
||||
outputPath,
|
||||
'bottom',
|
||||
)
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/bottom` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock orientation && killall Dock')
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock orientation with param set to left')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.dock', 'orientation', '-string left', 'left')
|
||||
.killApp('Dock')
|
||||
.wait(1000)
|
||||
.captureScreen(`${outputPath}/left-tmp.png`)
|
||||
.deleteDefault('com.apple.dock', 'orientation')
|
||||
.killApp('Dock')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/left-tmp.png`, outputPath, 'left')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/left` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock orientation && killall Dock')
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock orientation with param set to right')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.dock', 'orientation', '-string right', 'right')
|
||||
.killApp('Dock')
|
||||
.wait(1000)
|
||||
.captureScreen(`${outputPath}/right-tmp.png`)
|
||||
.deleteDefault('com.apple.dock', 'orientation')
|
||||
.killApp('Dock')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/right-tmp.png`, outputPath, 'right')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/right` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock orientation && killall Dock')
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
const MacRunner = require('../mac-runner')
|
||||
const { compressPngImage } = require('../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock readme screenshot')
|
||||
|
||||
try {
|
||||
const { screenWidth, screenHeight } = MacRunner.getScreenSize()
|
||||
const dockHeight = MacRunner.getDockHeight()
|
||||
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.captureScreenRect(
|
||||
0,
|
||||
screenHeight - dockHeight,
|
||||
screenWidth,
|
||||
dockHeight,
|
||||
`${outputPath}/dock-tmp.png`,
|
||||
)
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/dock-tmp.png`, outputPath, 'dock')
|
||||
} catch (compressPngImageError) {
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/dock` }
|
||||
},
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock show-recents with param set to false')
|
||||
|
||||
try {
|
||||
const { screenWidth, screenHeight } = MacRunner.getScreenSize()
|
||||
|
||||
// Dock gets larger when not showing most recent Apps
|
||||
const dockHeight = MacRunner.getDockHeight() + 4
|
||||
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.dock', 'show-recents', '-bool false', '0')
|
||||
.killApp('Dock')
|
||||
.wait(1000)
|
||||
.captureScreenRect(
|
||||
screenWidth - 740,
|
||||
screenHeight - dockHeight,
|
||||
740,
|
||||
dockHeight,
|
||||
`${outputPath}/false-tmp.png`,
|
||||
)
|
||||
.deleteDefault('com.apple.dock', 'show-recents')
|
||||
.killApp('Dock')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/false-tmp.png`, outputPath, 'false')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock show-recents && killall Dock')
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock show-recents with param set to true')
|
||||
|
||||
try {
|
||||
const { screenWidth, screenHeight } = MacRunner.getScreenSize()
|
||||
const dockHeight = MacRunner.getDockHeight()
|
||||
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.dock', 'show-recents', '-bool true', '1')
|
||||
.killApp('Dock')
|
||||
.wait(1000)
|
||||
.captureScreenRect(
|
||||
screenWidth - 740,
|
||||
screenHeight - dockHeight,
|
||||
740,
|
||||
dockHeight,
|
||||
`${outputPath}/true-tmp.png`,
|
||||
)
|
||||
.deleteDefault('com.apple.dock', 'show-recents')
|
||||
.killApp('Dock')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/true-tmp.png`, outputPath, 'true')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock show-recents && killall Dock')
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock icon size with param set to 36')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.dock', 'tilesize', '-int 36', '36')
|
||||
.killApp('Dock')
|
||||
.wait(1000)
|
||||
.captureScreen(`${outputPath}/36-tmp.png`)
|
||||
.deleteDefault('com.apple.dock', 'tilesize')
|
||||
.killApp('Dock')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/36-tmp.png`, outputPath, '36')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/36` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock tilesize && killall Dock')
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording dock icon size with param set to 48')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.dock', 'tilesize', '-int 48', '48')
|
||||
.killApp('Dock')
|
||||
.wait(1000)
|
||||
.captureScreen(`${outputPath}/48-tmp.png`)
|
||||
.deleteDefault('com.apple.dock', 'tilesize')
|
||||
.killApp('Dock')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/48-tmp.png`, outputPath, '48')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/48` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.dock tilesize && killall Dock')
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder show hidden files to false')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.finder', 'AppleShowAllFiles', '-bool false', '0')
|
||||
.killApp('Finder')
|
||||
.wait(1000)
|
||||
.openApp('Finder', '~')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/false.png`)
|
||||
.deleteDefault('com.apple.finder', 'AppleShowAllFiles')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/false.png`, outputPath, 'false')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.finder AppleShowAllFiles && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder show hidden files to true')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.finder', 'AppleShowAllFiles', '-bool true', '1')
|
||||
.killApp('Finder')
|
||||
.wait(1000)
|
||||
.openApp('Finder', '~')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/true.png`)
|
||||
.deleteDefault('com.apple.finder', 'AppleShowAllFiles')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/true.png`, outputPath, 'true')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.finder AppleShowAllFiles && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
const robot = require('robotjs')
|
||||
const MacRunner = require('../../mac-runner')
|
||||
const delay = require('delay')
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording finder FXEnableExtensionChangeWarning with param set to false',
|
||||
)
|
||||
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const recordWidth = 720
|
||||
const recordHeight = 404
|
||||
const cropArea = {
|
||||
x: 0,
|
||||
y: height - recordHeight - MacRunner.getMenuBarHeight(),
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'com.apple.finder',
|
||||
'FXEnableExtensionChangeWarning',
|
||||
'-bool false',
|
||||
'0',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.register(() => robot.keyTap('right'))
|
||||
.register(() => delay(100))
|
||||
.register(() => robot.keyTap('right'))
|
||||
.register(() => delay(100))
|
||||
.startVideo({ highlightClicks: true, cropArea })
|
||||
.register(() => robot.keyTap('enter'))
|
||||
.register(() => robot.keyTap('right', 'command'))
|
||||
.register(() => robot.keyTap('left', ['shift', 'alt']))
|
||||
.register(() => robot.typeStringDelayed('txt', 300))
|
||||
.register(() => robot.keyTap('enter'))
|
||||
.register(() => delay(800))
|
||||
.register(() => robot.keyTap('enter'))
|
||||
.register(() => robot.keyTap('right', 'command'))
|
||||
.register(() => robot.keyTap('left', ['shift', 'alt']))
|
||||
.register(() => robot.typeStringDelayed('md', 300))
|
||||
.register(() => robot.keyTap('enter'))
|
||||
.register(() => delay(800))
|
||||
.stopVideo(`${outputPath}/false.mp4`)
|
||||
.deleteDefault('com.apple.finder', 'FXEnableExtensionChangeWarning')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressVideo(`${outputPath}/false.mp4`, outputPath, 'false')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.finder FXEnableExtensionChangeWarning && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
const robot = require('robotjs')
|
||||
const MacRunner = require('../../mac-runner')
|
||||
const delay = require('delay')
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording finder FXEnableExtensionChangeWarning with param set to true',
|
||||
)
|
||||
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const recordWidth = 720
|
||||
const recordHeight = 404
|
||||
const cropArea = {
|
||||
x: width / 2 - recordWidth / 2,
|
||||
y: height / 2 - recordHeight / 2 + 200,
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'com.apple.finder',
|
||||
'FXEnableExtensionChangeWarning',
|
||||
'-bool true',
|
||||
'1',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', cropArea.x, cropArea.y - 398, 740, 400)
|
||||
.register(() => robot.keyTap('right'))
|
||||
.register(() => delay(100))
|
||||
.register(() => robot.keyTap('right'))
|
||||
.register(() => delay(100))
|
||||
.startVideo({ highlightClicks: true, cropArea })
|
||||
.register(() => robot.keyTap('enter'))
|
||||
.register(() => robot.keyTap('right', 'command'))
|
||||
.register(() => robot.keyTap('left', ['shift', 'alt']))
|
||||
.register(() => robot.typeStringDelayed('txt', 300))
|
||||
.register(() => robot.keyTap('enter'))
|
||||
.register(() => delay(800))
|
||||
.register(() => robot.keyTap('escape'))
|
||||
.register(() => delay(800))
|
||||
.stopVideo(`${outputPath}/true.mp4`)
|
||||
.deleteDefault('com.apple.finder', 'FXEnableExtensionChangeWarning')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressVideo(`${outputPath}/true.mp4`, outputPath, 'true')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.finder FXEnableExtensionChangeWarning && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder NSTableViewDefaultSizeMode to 1')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'NSGlobalDomain',
|
||||
'NSTableViewDefaultSizeMode',
|
||||
'-int 1',
|
||||
'1',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/1.png`)
|
||||
.deleteDefault('NSGlobalDomain', 'NSTableViewDefaultSizeMode')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/1.png`, outputPath, '1')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/1` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete NSGlobalDomain NSTableViewDefaultSizeMode && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder NSTableViewDefaultSizeMode to 2')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'NSGlobalDomain',
|
||||
'NSTableViewDefaultSizeMode',
|
||||
'-int 2',
|
||||
'2',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/2.png`)
|
||||
.deleteDefault('NSGlobalDomain', 'NSTableViewDefaultSizeMode')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/2.png`, outputPath, '2')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/2` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete NSGlobalDomain NSTableViewDefaultSizeMode && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder NSTableViewDefaultSizeMode to 3')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'NSGlobalDomain',
|
||||
'NSTableViewDefaultSizeMode',
|
||||
'-int 3',
|
||||
'3',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/3.png`)
|
||||
.deleteDefault('NSGlobalDomain', 'NSTableViewDefaultSizeMode')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/3.png`, outputPath, '3')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/3` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete NSGlobalDomain NSTableViewDefaultSizeMode && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
const robot = require('robotjs')
|
||||
const MacRunner = require('../../mac-runner')
|
||||
const delay = require('delay')
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording finder NSToolbarTitleViewRolloverDelay with param set to 0',
|
||||
)
|
||||
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const recordWidth = 740
|
||||
const recordHeight = 404
|
||||
const cropArea = {
|
||||
x: 0,
|
||||
y: height - recordHeight - MacRunner.getMenuBarHeight(),
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
const pos1 = {
|
||||
x: cropArea.x + recordWidth / 3 + 20,
|
||||
y: MacRunner.getMenuBarHeight() + 100,
|
||||
}
|
||||
const pos2 = {
|
||||
x: cropArea.x + recordWidth / 3 + 20,
|
||||
y: MacRunner.getMenuBarHeight() + 30,
|
||||
}
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'NSGlobalDomain',
|
||||
'NSToolbarTitleViewRolloverDelay',
|
||||
'-float 0',
|
||||
'0',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.register(() => robot.moveMouse(pos1.x, pos1.y))
|
||||
.startVideo({ highlightClicks: true, cropArea })
|
||||
.register(() => delay(300))
|
||||
.register(() => robot.moveMouseSmooth(pos2.x, pos2.y))
|
||||
.register(() => delay(1500))
|
||||
.register(() => robot.moveMouseSmooth(pos1.x, pos1.y))
|
||||
.register(() => delay(1000))
|
||||
.stopVideo(`${outputPath}/0.mp4`)
|
||||
.deleteDefault('NSGlobalDomain', 'NSToolbarTitleViewRolloverDelay')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressVideo(`${outputPath}/0.mp4`, outputPath, '0')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/0`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete NSGlobalDomain NSToolbarTitleViewRolloverDelay && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
const robot = require('robotjs')
|
||||
const MacRunner = require('../../mac-runner')
|
||||
const delay = require('delay')
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording finder NSToolbarTitleViewRolloverDelay with param set to 0.5',
|
||||
)
|
||||
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const recordWidth = 740
|
||||
const recordHeight = 404
|
||||
const cropArea = {
|
||||
x: 0,
|
||||
y: height - recordHeight - MacRunner.getMenuBarHeight(),
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
const pos1 = {
|
||||
x: cropArea.x + recordWidth / 3 + 20,
|
||||
y: MacRunner.getMenuBarHeight() + 100,
|
||||
}
|
||||
const pos2 = {
|
||||
x: cropArea.x + recordWidth / 3 + 20,
|
||||
y: MacRunner.getMenuBarHeight() + 30,
|
||||
}
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'NSGlobalDomain',
|
||||
'NSToolbarTitleViewRolloverDelay',
|
||||
'-float 0.5',
|
||||
'0.5',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.register(() => robot.moveMouse(pos1.x, pos1.y))
|
||||
.startVideo({ highlightClicks: true, cropArea })
|
||||
.register(() => delay(300))
|
||||
.register(() => robot.moveMouseSmooth(pos2.x, pos2.y))
|
||||
.register(() => delay(1500))
|
||||
.register(() => robot.moveMouseSmooth(pos1.x, pos1.y))
|
||||
.register(() => delay(1000))
|
||||
.stopVideo(`${outputPath}/0.5.mp4`)
|
||||
.deleteDefault('NSGlobalDomain', 'NSToolbarTitleViewRolloverDelay')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressVideo(`${outputPath}/0.5.mp4`, outputPath, '0.5')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/0.5`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete NSGlobalDomain NSToolbarTitleViewRolloverDelay && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
const robot = require('robotjs')
|
||||
const MacRunner = require('../../mac-runner')
|
||||
const delay = require('delay')
|
||||
const { compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording finder NSToolbarTitleViewRolloverDelay with param set to 1',
|
||||
)
|
||||
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const recordWidth = 740
|
||||
const recordHeight = 404
|
||||
const cropArea = {
|
||||
x: 0,
|
||||
y: height - recordHeight - MacRunner.getMenuBarHeight(),
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
const pos1 = {
|
||||
x: cropArea.x + recordWidth / 3 + 20,
|
||||
y: MacRunner.getMenuBarHeight() + 100,
|
||||
}
|
||||
const pos2 = {
|
||||
x: cropArea.x + recordWidth / 3 + 20,
|
||||
y: MacRunner.getMenuBarHeight() + 30,
|
||||
}
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'NSGlobalDomain',
|
||||
'NSToolbarTitleViewRolloverDelay',
|
||||
'-float 1',
|
||||
'1',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.register(() => robot.moveMouse(pos1.x, pos1.y))
|
||||
.startVideo({ highlightClicks: true, cropArea })
|
||||
.register(() => delay(300))
|
||||
.register(() => robot.moveMouseSmooth(pos2.x, pos2.y))
|
||||
.register(() => delay(1500))
|
||||
.register(() => robot.moveMouseSmooth(pos1.x, pos1.y))
|
||||
.register(() => delay(1000))
|
||||
.stopVideo(`${outputPath}/1.mp4`)
|
||||
.deleteDefault('NSGlobalDomain', 'NSToolbarTitleViewRolloverDelay')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressVideo(`${outputPath}/1.mp4`, outputPath, '1')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/1`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete NSGlobalDomain NSToolbarTitleViewRolloverDelay && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder ShowPathbar to false')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.finder', 'ShowPathbar', '-bool false', '0')
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/false.png`)
|
||||
.deleteDefault('com.apple.finder', 'ShowPathbar')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/false.png`, outputPath, 'false')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.finder ShowPathbar && killall Finder')
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder ShowPathbar to true')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.finder', 'ShowPathbar', '-bool true', '1')
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/true.png`)
|
||||
.deleteDefault('com.apple.finder', 'ShowPathbar')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/true.png`, outputPath, 'true')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info('defaults delete com.apple.finder ShowPathbar && killall Finder')
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording finder _FXSortFoldersFirst with param set to false',
|
||||
)
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'com.apple.finder',
|
||||
'_FXSortFoldersFirst',
|
||||
'-bool false',
|
||||
'0',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/false.png`)
|
||||
.deleteDefault('com.apple.finder', '_FXSortFoldersFirst')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/false.png`, outputPath, 'false')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.finder _FXSortFoldersFirst && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder _FXSortFoldersFirst with param set to true')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'com.apple.finder',
|
||||
'_FXSortFoldersFirst',
|
||||
'-bool true',
|
||||
'1',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/true.png`)
|
||||
.deleteDefault('com.apple.finder', '_FXSortFoldersFirst')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/true.png`, outputPath, 'true')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.finder _FXSortFoldersFirst && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder show window title bar icons to false')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'com.apple.universalaccess',
|
||||
'showWindowTitlebarIcons',
|
||||
'-bool false',
|
||||
'0',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/false.png`)
|
||||
.deleteDefault('com.apple.universalaccess', 'showWindowTitlebarIcons')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/false.png`, outputPath, 'false')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.universalaccess showWindowTitlebarIcons && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording finder showWindowTitlebarIcons to true')
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault(
|
||||
'com.apple.universalaccess',
|
||||
'showWindowTitlebarIcons',
|
||||
'-bool true',
|
||||
'1',
|
||||
)
|
||||
.killApp('Finder')
|
||||
.openApp('Finder', '~/macos-defaults')
|
||||
.activateApp('Finder')
|
||||
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
||||
.captureApp('Finder', `${outputPath}/true.png`)
|
||||
.deleteDefault('com.apple.universalaccess', 'showWindowTitlebarIcons')
|
||||
.killApp('Finder')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/true.png`, outputPath, 'true')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.universalaccess showWindowTitlebarIcons && killall Finder',
|
||||
)
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
const record = require('./record')
|
||||
|
||||
;(async () => await record(process.argv.slice(2, process.argv.length)))()
|
|
@ -1,233 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const robot = require('robotjs')
|
||||
const wait = require('delay')
|
||||
const fs = require('fs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
|
||||
class MacRunner {
|
||||
constructor(commands = []) {
|
||||
this.commands = commands
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {{screenWidth: number, screenHeight: number}} The main screen size
|
||||
*/
|
||||
static getScreenSize() {
|
||||
const { width, height } = robot.getScreenSize()
|
||||
return { screenWidth: width, screenHeight: height }
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {number} The Dock height
|
||||
*/
|
||||
static getDockHeight() {
|
||||
return 100
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {number} The Menu Bar height
|
||||
*/
|
||||
static getMenuBarHeight() {
|
||||
return 23
|
||||
}
|
||||
|
||||
/**
|
||||
* Set MacOS defaults system
|
||||
* @param {*} domain Application domain
|
||||
* @param {*} key Default key
|
||||
* @param {*} params Values for the default
|
||||
* @param {*} expectedResult Expected defaults read result
|
||||
*/
|
||||
setDefault(domain, key, params, expectedResult) {
|
||||
return this.register(async () => {
|
||||
const defaultCommand = `defaults write ${domain} ${key} ${params}`
|
||||
|
||||
// Retry command until it works (sometimes it doesn't...)
|
||||
for (let i = 10; i--; i > 0) {
|
||||
try {
|
||||
await execCommand(defaultCommand, 100)
|
||||
const result = await execCommand(`defaults read ${domain} ${key}`, 0)
|
||||
if (expectedResult === result.trim()) {
|
||||
break
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
if (i === 1) {
|
||||
throw new Error(`[${defaultCommand}] failed (too much trials)`)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Read MacOS defaults system
|
||||
* @param {*} domain Application domain
|
||||
* @param {*} key Default key
|
||||
*/
|
||||
readDefault(domain, key) {
|
||||
return this.register(async () => {
|
||||
const defaultCommand = `defaults read ${domain} | grep ${key}`
|
||||
console.log(await execCommand(defaultCommand, 0))
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete MacOS defaults system
|
||||
* @param {*} domain Application domain
|
||||
* @param {*} key Default key
|
||||
*/
|
||||
deleteDefault(domain, key) {
|
||||
return this.register(async () => {
|
||||
const defaultCommand = `defaults delete ${domain} ${key}`
|
||||
await execCommand(defaultCommand)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Open an application from it's name
|
||||
* @param {*} appName Application name (ex: Finder)
|
||||
* @param {*} params Application parameters
|
||||
*/
|
||||
openApp(appName, params = '') {
|
||||
return this.register(() => execCommand(`open -a "${appName}" ${params}`))
|
||||
}
|
||||
|
||||
/**
|
||||
* Make active a running application
|
||||
* @param {*} appName Application name
|
||||
*/
|
||||
activateApp(appName) {
|
||||
return this.register(() =>
|
||||
execCommand(`osascript -e 'tell application "${appName}" to activate'`),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill an application from it's name
|
||||
* @param {*} appName Application name
|
||||
*/
|
||||
killApp(appName) {
|
||||
return this.register(() => execCommand(`killall ${appName}`))
|
||||
}
|
||||
|
||||
/**
|
||||
* Move and resize an application window
|
||||
* @param {*} appName Application name
|
||||
* @param {*} x X coordinate (from the left of the screen)
|
||||
* @param {*} y Y coordinate (from the top of the screen)
|
||||
* @param {*} width Width of the app window
|
||||
* @param {*} height Height of the app window
|
||||
*/
|
||||
moveAndResizeApp(appName, x, y, width, height) {
|
||||
const h = { start: x, end: x + width }
|
||||
const v = { start: y, end: y + height }
|
||||
return this.register(() =>
|
||||
execCommand(
|
||||
`osascript -e 'tell application "${appName}" to set the bounds of the first window to {${h.start}, ${v.start}, ${h.end}, ${v.end}}'`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture the whole screen into a file
|
||||
* @param {*} output Output file name (png)
|
||||
*/
|
||||
captureScreen(output) {
|
||||
return this.register(async () => {
|
||||
await this.wait(2000)
|
||||
execCommand(`screencapture ${output}`)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture a screen rect into a file
|
||||
* @param {*} x X coordinate (from the left of the screen)
|
||||
* @param {*} y Y coordinate (from the top of the screen)
|
||||
* @param {*} width Width of the capture
|
||||
* @param {*} height Height of the capture
|
||||
* @param {*} output Output file name (png)
|
||||
*/
|
||||
captureScreenRect(x, y, width, height, output) {
|
||||
return this.register(() =>
|
||||
execCommand(`screencapture -R${x},${y},${width},${height} ${output}`),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture the app window into a file
|
||||
* @param {*} appName Application name to capture
|
||||
* @param {*} output Output file name (png)
|
||||
* @param {boolean} disableShadow Do not capture the App shadow
|
||||
*/
|
||||
captureApp(appName, output, disableShadow = true) {
|
||||
return this.register(() =>
|
||||
execCommand(
|
||||
`screencapture ${
|
||||
disableShadow ? '-o' : ''
|
||||
} -l$(osascript -e 'tell app "${appName}" to id of window 1') ${output}`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the video recording using aperturejs
|
||||
* @param {*} options aperturejs options
|
||||
*/
|
||||
startVideo(options) {
|
||||
return this.register(async () => {
|
||||
console.info(' Start video recording...')
|
||||
await aperture.startRecording(options)
|
||||
await aperture.isFileReady
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the video recording
|
||||
* @param {*} output video file output
|
||||
*/
|
||||
stopVideo(output) {
|
||||
return this.register(async () => {
|
||||
console.info(' Stop video recording...')
|
||||
const fp = await aperture.stopRecording()
|
||||
if (fs.existsSync(output)) {
|
||||
fs.unlinkSync(output)
|
||||
}
|
||||
fs.renameSync(fp, output)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a given delay
|
||||
* @param {*} delay Delay in ms
|
||||
*/
|
||||
wait(delay) {
|
||||
return this.register(() => wait(delay))
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the runner with all given commands
|
||||
*/
|
||||
async run() {
|
||||
await this.commands.reduce((p, fn) => p.then(fn), Promise.resolve())
|
||||
}
|
||||
|
||||
register(command) {
|
||||
this.commands.push(command)
|
||||
return new MacRunner(this.commands)
|
||||
}
|
||||
}
|
||||
|
||||
async function execCommand(command, delay = 1000) {
|
||||
console.info(` Command: [${command}]`)
|
||||
const { stderr, stdout } = await exec(command)
|
||||
if (stderr) {
|
||||
throw new Error(stderr)
|
||||
}
|
||||
await wait(delay)
|
||||
return stdout
|
||||
}
|
||||
|
||||
module.exports = MacRunner
|
|
@ -1,75 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { makeAppActive, compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording menu bar clock FlashDateSeparators with param set to false',
|
||||
)
|
||||
|
||||
// Set the menu bar menuExtras to only show the clock, it will be on the left of notification center, siri, and spotlight search.
|
||||
const { stderr: setEnvError } = await exec(
|
||||
`defaults write com.apple.menuextra.clock FlashDateSeparators -bool false && killall SystemUIServer && sleep 10`,
|
||||
)
|
||||
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the menu bar clock FlashDateSeparators command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await makeAppActive('Finder')
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const recordWidth = 400
|
||||
const recordHeight = 29
|
||||
const cropArea = {
|
||||
x: width - recordWidth,
|
||||
y: height - recordHeight, // Film the menu bar, which is 29 pixels
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ cropArea })
|
||||
await delay(2000)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, 'false')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.menuextra.clock FlashDateSeparators && killall SystemUIServer && sleep 10',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the menu bar clock FlashDateSeparators environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.menuextra.clock FlashDateSeparators && killall SystemUIServer',
|
||||
)
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
const aperture = require('aperture')()
|
||||
const delay = require('delay')
|
||||
const robot = require('robotjs')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { makeAppActive, compressVideo } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording menu bar clock FlashDateSeparators with param set to true',
|
||||
)
|
||||
|
||||
// Set the menu bar menuExtras to only show the clock, it will be on the left of notification center, siri, and spotlight search.
|
||||
const { stderr: setEnvError } = await exec(
|
||||
`defaults write com.apple.menuextra.clock FlashDateSeparators -bool true && killall SystemUIServer && sleep 10`,
|
||||
)
|
||||
|
||||
if (setEnvError) {
|
||||
console.error(
|
||||
'An error occured while setting up the menu bar clock FlashDateSeparators command',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(setEnvError)
|
||||
}
|
||||
|
||||
// Preparation
|
||||
await makeAppActive('Finder')
|
||||
const { width, height } = robot.getScreenSize()
|
||||
const recordWidth = 400
|
||||
const recordHeight = 29
|
||||
const cropArea = {
|
||||
x: width - recordWidth,
|
||||
y: height - recordHeight, // Film the menu bar, which is 29 pixels
|
||||
width: recordWidth,
|
||||
height: recordHeight,
|
||||
}
|
||||
|
||||
// Action!
|
||||
await aperture.startRecording({ cropArea })
|
||||
await delay(2000)
|
||||
|
||||
const fp = await aperture.stopRecording()
|
||||
// End recording
|
||||
|
||||
try {
|
||||
await compressVideo(fp, outputPath, 'true')
|
||||
} catch (compressVideoError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressVideoError)
|
||||
}
|
||||
|
||||
const { stderr: deleteEnvError } = await exec(
|
||||
'defaults delete com.apple.menuextra.clock FlashDateSeparators && killall SystemUIServer && sleep 10',
|
||||
)
|
||||
if (deleteEnvError) {
|
||||
console.error(
|
||||
'An error occured while cleaning the menu bar clock FlashDateSeparators environment',
|
||||
)
|
||||
logRollbackInfo()
|
||||
throw new Error(deleteEnvError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true`, isVideo: true }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {
|
||||
console.info(
|
||||
'Please manually run this command to make sure everything is properly reset:',
|
||||
)
|
||||
console.info(
|
||||
'defaults delete com.apple.menuextra.clock FlashDateSeparators && killall SystemUIServer',
|
||||
)
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
"private": true,
|
||||
"name": "macos-defaults-images-recorder",
|
||||
"version": "0.1.0",
|
||||
"main": "record.js",
|
||||
"engines": {
|
||||
"node": ">=15 <=16"
|
||||
},
|
||||
"scripts": {
|
||||
"record": "node index.js",
|
||||
"record:debug": "NODE_ENV=DEBUG node index.js",
|
||||
"record:next": "node record-next.mjs",
|
||||
"build": "yarn record",
|
||||
"format": "prettier --write . --ignore-path ../.prettierignore",
|
||||
"lint": "prettier --check . --ignore-path ../.prettierignore"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"aperture": "6.1.3",
|
||||
"delay": "5.0.0",
|
||||
"glob": "^9",
|
||||
"glob-promise": "6.0.3",
|
||||
"jimp": "0.22.10",
|
||||
"mkdirp": "^2",
|
||||
"node-pngquant-native": "2.2.0",
|
||||
"prettier": "^3.0.0",
|
||||
"prompt-confirm": "2.0.4",
|
||||
"robotjs": "0.6.0",
|
||||
"sharp": "0.32.5"
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
# macos-defaults recorder 📷
|
||||
|
||||
**Stability: 1 - Experimental**
|
||||
|
||||
All the images and videos you will find on **macos-defaults** are built programmatically. It's done using **Node.js** scripts found in this folder subfolders.
|
||||
|
||||
Programmatic record serves 2 goals:
|
||||
|
||||
- Record similar actions with different `defaults` config.
|
||||
- Make it easy to replay when a new version comes out.
|
||||
|
||||
## Technical overview
|
||||
|
||||
The [record.js](./record.js) file launches subfolders' recording scripts.
|
||||
|
||||
The scripts are all the `.js` files in this folder subfolders. There is one script per screenshot/video. These scripts share the same workflow:
|
||||
|
||||
1. Set a `defaults` command value
|
||||
2. Prepare the recording using [robot.js](https://github.com/octalmage/robotjs)
|
||||
3. Record using [Aperture](https://github.com/wulkano/aperture-node)
|
||||
4. Post production (resize, compress, move)
|
||||
5. Reset the `defaults` value
|
||||
I try to keep as much similarity as possible for same-command examples.
|
||||
|
||||
Some [utils](./utils.js) are available to simplify scripts dev:
|
||||
|
||||
- `captureImage(x, y, width, height)` capture a screenshot using [jimp](https://github.com/oliver-moran/jimp)
|
||||
- `x`: position from the left border of the screen.
|
||||
- `y`: position from the bottom border of the screen.
|
||||
- `width`: the width of the image.
|
||||
- `height`: the height of the image.
|
||||
- `async compressPngImage(inputPath, outputFolder, outputName)` try to resize the image to a max width of 740 (VuePress page width) using [sharp](https://github.com/lovell/sharp) and compress it using [pngquant](https://github.com/xiangshouding/node-pngquant-native)
|
||||
- `inputPath`: the original image path.
|
||||
- `outputFolder`: where the compressed image should be placed.
|
||||
- `outputName`: what the compressed image file should be called.
|
||||
- `async compressVideo(inputPath, outputFolder, outputName)` resize and compress the video using [ffmpeg](https://ffmpeg.org)
|
||||
- `inputPath`: the original video path.
|
||||
- `outputFolder`: where the compressed video should be placed.
|
||||
- `outputName`: what the compressed video file should be called.
|
||||
- `async makeAppActive(appName)` open an App and set it as active using AppleScript
|
||||
- `appName`: the app name.
|
||||
- `async moveAndResizeApp(appName, cropArea, screenHeight)` move and resize an App using AppleScript
|
||||
- `appName`: the app name.
|
||||
- `cropArea`: the cropArea used by Aperture (`{ x ,y , width, height }`).
|
||||
- `screenHeight`: the screen height.
|
||||
|
||||
I consider removing the resize/compression part and upload these assets to a media CDN like [Cloudinary](https://cloudinary.com) to serve optimal resources based on user preferences.
|
||||
|
||||
## Launch locally
|
||||
|
||||
This part is only useful if you want to add a command. I **strongely recommand** not to launch the scripts locally if you don't want to mess up your config.
|
||||
|
||||
### 💻 My setup
|
||||
|
||||
I'm personally launching these scripts on a 15" 2015 MacBook Pro running the latest macOS developer beta version. I log in as another account when I want to work on the scripts. The scripts should be agnostic from the hardware they run on, please let me know if some of them do not by [opening an issue](https://github.com/yannbertrand/macos-defaults/issues/new).
|
||||
|
||||
### 🏗 Install
|
||||
|
||||
```sh
|
||||
yarn install
|
||||
```
|
||||
|
||||
### 🚀 Usage
|
||||
|
||||
⚠️ **Do not launch these commands on your daily user account!** The scripts override your user config.
|
||||
|
||||
When launching for the first time, you'll have some security prompts to confirm.
|
||||
|
||||
Hope you'll have as much fun as I had when I launched it for the first time 😊.
|
||||
|
||||
```sh
|
||||
# Launch all recording
|
||||
yarn record
|
||||
|
||||
# Launch a specific command script recording
|
||||
yarn record screenshots/disable-shadow/false.js
|
||||
|
||||
# Launch all scripts of a command recording
|
||||
yarn record dock/autohide-delay/*
|
||||
|
||||
# Launch a whole category recording
|
||||
yarn record dock/*/*
|
||||
```
|
||||
|
||||
### 🚧 Run unit tests
|
||||
|
||||
I couldn't find a way to unit test these scripts. If you have an idea, I'm really interested.
|
|
@ -1,22 +0,0 @@
|
|||
import path from 'path'
|
||||
|
||||
const FILES = [
|
||||
'dock/orientation/bottom.js',
|
||||
'dock/orientation/left.js',
|
||||
'dock/orientation/right.js',
|
||||
'finder/AppleShowAllFiles/false.js',
|
||||
'finder/AppleShowAllFiles/true.js',
|
||||
]
|
||||
|
||||
console.info(`\nFound ${FILES.length} scripts to run.`)
|
||||
|
||||
for (const scriptFile of FILES) {
|
||||
const script = await import(`./${scriptFile}`)
|
||||
await script.run(getImagePath(scriptFile))
|
||||
}
|
||||
|
||||
console.info(`\nAll videos and screenshots were successfully recorded.\n`)
|
||||
|
||||
function getImagePath(file) {
|
||||
return path.normalize(`../images/${path.dirname(file)}`)
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
const glob = require('glob-promise')
|
||||
const path = require('path')
|
||||
const robot = require('robotjs')
|
||||
const Confirm = require('prompt-confirm')
|
||||
const { makeAppActive } = require('./utils')
|
||||
|
||||
module.exports = async (files) => {
|
||||
try {
|
||||
const scriptFiles =
|
||||
files.length > 0 ? files : await glob('!(node_modules)/**/*.js')
|
||||
|
||||
console.info(`\nFound ${scriptFiles.length} scripts to run.`)
|
||||
console.info('Please close Safari and do not move the mouse until the end.')
|
||||
console.info('It should take a few minutes, go grab a drink!\n')
|
||||
console.info('iTerm should reopen when its done.\n')
|
||||
|
||||
const prompt = new Confirm('Ready?')
|
||||
if (!(await prompt.run())) return
|
||||
|
||||
robot.keyTap('h', 'command')
|
||||
|
||||
for (const scriptFile of scriptFiles) {
|
||||
const script = require(`./${scriptFile}`)
|
||||
try {
|
||||
await script.run(getImagePath(scriptFile))
|
||||
} catch (error) {
|
||||
await makeAppActive('iTerm')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
await makeAppActive('iTerm')
|
||||
|
||||
console.info(
|
||||
`\nAll videos and screenshots were successfully recorded. You can use your mouse again\n`,
|
||||
)
|
||||
} catch (error) {
|
||||
await makeAppActive('iTerm')
|
||||
|
||||
if (error.code === 'RECORDER_TIMEOUT') {
|
||||
console.info('The recorder timed out.')
|
||||
console.info(
|
||||
"You probably need to activate the screen recording feature for the terminal you're using.",
|
||||
)
|
||||
console.info(
|
||||
"You'll find that settings under: System Parameters > Security & Confidentiality > Confidentiality > Screen recording",
|
||||
)
|
||||
} else if (error.code === 'ENOTDIR') {
|
||||
console.info('A mandatory folder was not found.')
|
||||
} else {
|
||||
console.error('An error occured while recording')
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const getImagePath = (file) => path.normalize(`../images/${path.dirname(file)}`)
|
|
@ -1,36 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording screencapture disable-shadow with param set to false',
|
||||
)
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.openApp('Safari', '-F https://apple.com')
|
||||
.activateApp('Safari')
|
||||
.moveAndResizeApp('Safari', 0, 0, 740 * 2, 413 * 2)
|
||||
// We do not set the default as `captureApp` takes a param to disable shadow
|
||||
.captureApp('Safari', `${outputPath}/false-tmp.png`, false)
|
||||
.killApp('Safari')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/false-tmp.png`, outputPath, 'false')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {}
|
|
@ -1,36 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log(
|
||||
'> Recording screencapture disable-shadow with param set to true',
|
||||
)
|
||||
|
||||
try {
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.openApp('Safari', '-F https://apple.com')
|
||||
.activateApp('Safari')
|
||||
.moveAndResizeApp('Safari', 0, 0, 740 * 2, 413 * 2)
|
||||
// We do not set the default as `captureApp` takes a param to disable shadow
|
||||
.captureApp('Safari', `${outputPath}/true-tmp.png`, true)
|
||||
.killApp('Safari')
|
||||
.run()
|
||||
} catch (runnerError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/true-tmp.png`, outputPath, 'true')
|
||||
} catch (compressPngImageError) {
|
||||
logRollbackInfo()
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true` }
|
||||
},
|
||||
}
|
||||
|
||||
function logRollbackInfo() {}
|
|
@ -1,62 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording TextEdit opens rich text files to true')
|
||||
|
||||
try {
|
||||
const fileName = '/tmp/lorem.txt'
|
||||
await manageFile(fileName, true)
|
||||
await addContentToFile(fileName, '')
|
||||
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.TextEdit', 'RichText', '-bool false', '0')
|
||||
.openApp('TextEdit', fileName)
|
||||
.moveAndResizeApp('TextEdit', 0, 0, 740, 400)
|
||||
.captureApp('TextEdit', `${outputPath}/false.png`)
|
||||
.deleteDefault('com.apple.TextEdit', 'RichText')
|
||||
.killApp('TextEdit')
|
||||
.run()
|
||||
|
||||
await manageFile(fileName, false)
|
||||
} catch (runnerError) {
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/false.png`, outputPath, 'false')
|
||||
} catch (compressPngImageError) {
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/false` }
|
||||
},
|
||||
}
|
||||
|
||||
async function manageFile(filename, create) {
|
||||
console.log(` Command: ${create ? 'create' : 'remove'} ${filename}`)
|
||||
const { stderr: mngFile } = await exec(
|
||||
`${create ? 'touch' : 'rm -f'} ${filename}`,
|
||||
)
|
||||
if (mngFile) {
|
||||
console.error('An error occured while working with a file')
|
||||
throw new Error(mngFile)
|
||||
}
|
||||
}
|
||||
|
||||
async function addContentToFile(filename, content) {
|
||||
console.log(` Command: add content to ${filename}`)
|
||||
const { stderr: mngFile } = await exec(
|
||||
`cat > ${filename} << EOF
|
||||
${content}
|
||||
EOF`,
|
||||
)
|
||||
if (mngFile) {
|
||||
console.error('An error occured while working with a file')
|
||||
throw new Error(mngFile)
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
const MacRunner = require('../../mac-runner')
|
||||
const util = require('util')
|
||||
const exec = util.promisify(require('child_process').exec)
|
||||
const { compressPngImage } = require('../../utils')
|
||||
|
||||
module.exports = {
|
||||
run: async (outputPath) => {
|
||||
console.log('> Recording TextEdit opens rich text files to true')
|
||||
|
||||
try {
|
||||
const filename = '/tmp/lorem.rtf'
|
||||
await manageFile(filename, true)
|
||||
await addContentToFile(
|
||||
filename,
|
||||
'{\\rtf1\\ansi\\ansicpg1252\\cocoartf2577\\cocoatextscaling0\\cocoaplatform0{\\fonttbl}{\\colortbl;\\red255\\green255\\blue255;}{\\*\\expandedcolortbl;;}\\paperw11900\\paperh16840\\margl1440\\margr1440\\vieww11520\\viewh8400\\viewkind0}',
|
||||
)
|
||||
|
||||
const runner = new MacRunner()
|
||||
await runner
|
||||
.setDefault('com.apple.TextEdit', 'RichText', '-bool true', '1', '')
|
||||
.openApp('TextEdit', filename)
|
||||
.moveAndResizeApp('TextEdit', 0, 0, 740, 400)
|
||||
.captureApp('TextEdit', `${outputPath}/true.png`)
|
||||
.deleteDefault('com.apple.TextEdit', 'RichText')
|
||||
.killApp('TextEdit')
|
||||
.run()
|
||||
|
||||
await manageFile(filename, false)
|
||||
} catch (runnerError) {
|
||||
throw new Error(runnerError)
|
||||
}
|
||||
|
||||
try {
|
||||
await compressPngImage(`${outputPath}/true.png`, outputPath, 'true')
|
||||
} catch (compressPngImageError) {
|
||||
throw new Error(compressPngImageError)
|
||||
}
|
||||
|
||||
return { filepath: `${outputPath}/true` }
|
||||
},
|
||||
}
|
||||
|
||||
async function manageFile(filename, create) {
|
||||
console.log(` Command: ${create ? 'create' : 'remove'} ${filename}`)
|
||||
const { stderr: mngFile } = await exec(
|
||||
`${create ? 'touch' : 'rm -f'} ${filename}`,
|
||||
)
|
||||
if (mngFile) {
|
||||
console.error('An error occured while working with a file')
|
||||
throw new Error(mngFile)
|
||||
}
|
||||
}
|
||||
|
||||
async function addContentToFile(filename, content) {
|
||||
console.log(` Command: add content to ${filename}`)
|
||||
const { stderr: mngFile } = await exec(
|
||||
`cat > ${filename} << EOF
|
||||
${content}
|
||||
EOF`,
|
||||
)
|
||||
if (mngFile) {
|
||||
console.error('An error occured while working with a file')
|
||||
throw new Error(mngFile)
|
||||
}
|
||||
}
|
193
record/utils.js
193
record/utils.js
|
@ -1,193 +0,0 @@
|
|||
const fs = require('fs')
|
||||
const mkdirp = require('mkdirp')
|
||||
const pngquant = require('node-pngquant-native')
|
||||
const sharp = require('sharp')
|
||||
const Jimp = require('jimp')
|
||||
const robot = require('robotjs')
|
||||
const { spawn } = require('child_process')
|
||||
|
||||
module.exports.captureImage = (x, y, w, h) => {
|
||||
// Taken from https://github.com/octalmage/robotjs/issues/13#issuecomment-501102240
|
||||
const pic = robot.screen.capture(x, y, w, h)
|
||||
const width = pic.byteWidth / pic.bytesPerPixel // pic.width is sometimes wrong!
|
||||
const height = pic.height
|
||||
const image = new Jimp(width, height)
|
||||
let red, green, blue
|
||||
pic.image.forEach((byte, i) => {
|
||||
switch (i % 4) {
|
||||
case 0:
|
||||
return (blue = byte)
|
||||
case 1:
|
||||
return (green = byte)
|
||||
case 2:
|
||||
return (red = byte)
|
||||
case 3:
|
||||
image.bitmap.data[i - 3] = red
|
||||
image.bitmap.data[i - 2] = green
|
||||
image.bitmap.data[i - 1] = blue
|
||||
image.bitmap.data[i] = 255
|
||||
}
|
||||
})
|
||||
return image
|
||||
}
|
||||
|
||||
module.exports.compressPngImage = async (
|
||||
inputPath,
|
||||
outputFolder,
|
||||
outputName,
|
||||
) => {
|
||||
const tmpOutput = `${outputFolder}/${outputName}-tmp.png`
|
||||
const finalOutput = `${outputFolder}/${outputName}.png`
|
||||
|
||||
await mkdirp(outputFolder)
|
||||
fs.renameSync(inputPath, tmpOutput)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
console.info(' Compressing PNG image')
|
||||
sharp(tmpOutput)
|
||||
.resize(740, undefined, {
|
||||
fit: sharp.fit.inside,
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
.toFormat('png')
|
||||
.toBuffer()
|
||||
.then((resizedBuffer) => {
|
||||
const responseBuffer = pngquant.compress(resizedBuffer)
|
||||
fs.writeFile(finalOutput, responseBuffer, (writeFileError) => {
|
||||
removeSync(tmpOutput)
|
||||
if (writeFileError) {
|
||||
console.error('An error occured while saving the image')
|
||||
reject(writeFileError)
|
||||
}
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.compressVideo = async (inputPath, outputFolder, outputName) => {
|
||||
const tmpOutput = `${outputFolder}/${outputName}-tmp.mp4`
|
||||
const finalOutput = `${outputFolder}/${outputName}.mp4`
|
||||
|
||||
await mkdirp(outputFolder)
|
||||
fs.renameSync(inputPath, tmpOutput)
|
||||
|
||||
try {
|
||||
await resizeVideo(tmpOutput, finalOutput)
|
||||
} catch (resizeVideoError) {
|
||||
console.error('An error occured while resizing the video')
|
||||
throw new Error(resizeVideoError)
|
||||
} finally {
|
||||
removeSync(tmpOutput)
|
||||
}
|
||||
}
|
||||
|
||||
function resizeVideo(input, output) {
|
||||
console.info(' Resizing video')
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const ffmpegRawLogs = []
|
||||
const ffmpeg = spawn('ffmpeg', [
|
||||
'-i',
|
||||
input,
|
||||
'-vf',
|
||||
"scale='min(740,iw)':-2",
|
||||
'-c:v',
|
||||
'libx264',
|
||||
'-crf',
|
||||
'18',
|
||||
'-preset',
|
||||
'veryslow',
|
||||
'-y',
|
||||
'-c:a',
|
||||
'copy',
|
||||
output,
|
||||
])
|
||||
|
||||
ffmpeg.stderr.on('data', (message) =>
|
||||
ffmpegRawLogs.push(message.toString('utf8')),
|
||||
)
|
||||
ffmpeg.on('exit', (ffmpegExitCode) => {
|
||||
if (process.env.NODE_ENV === 'DEBUG') {
|
||||
console.debug(ffmpegRawLogs.join('\n'))
|
||||
}
|
||||
|
||||
if (ffmpegExitCode !== 0) {
|
||||
return reject(ffmpegRawLogs.join('\n'))
|
||||
}
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function removeSync(file) {
|
||||
if (fs.existsSync(file)) {
|
||||
fs.unlinkSync(file)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.makeAppActive = async (appName) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const osascript = spawn('osascript', [
|
||||
'-e',
|
||||
'try',
|
||||
'-e',
|
||||
`tell application "${appName}" to activate`,
|
||||
'-e',
|
||||
'end try',
|
||||
])
|
||||
|
||||
if (process.env.NODE_ENV === 'DEBUG') {
|
||||
osascript.stderr.on('data', function (message) {
|
||||
console.debug(`${message}`)
|
||||
})
|
||||
}
|
||||
|
||||
osascript.on('exit', (osascriptExitCode) => {
|
||||
if (osascriptExitCode === '1') {
|
||||
return reject('osascript')
|
||||
}
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.moveAndResizeApp = async (appName, cropArea, screenHeight) => {
|
||||
const x = { start: cropArea.x, end: cropArea.x + cropArea.width }
|
||||
const y = {
|
||||
start: screenHeight - cropArea.y - cropArea.height,
|
||||
end: screenHeight - cropArea.y,
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const osascript = spawn('osascript', [
|
||||
'-e',
|
||||
'try',
|
||||
'-e',
|
||||
`tell application "${appName}"`,
|
||||
'-e',
|
||||
`set the bounds of the first window to {${x.start}, ${y.start}, ${x.end}, ${y.end}}`,
|
||||
'-e',
|
||||
'end tell',
|
||||
'-e',
|
||||
'end try',
|
||||
])
|
||||
|
||||
if (process.env.NODE_ENV === 'DEBUG') {
|
||||
osascript.stderr.on('data', function (message) {
|
||||
console.debug(`${message}`)
|
||||
})
|
||||
}
|
||||
|
||||
osascript.on('exit', (osascriptExitCode) => {
|
||||
if (osascriptExitCode === '1') {
|
||||
return reject('osascript')
|
||||
}
|
||||
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
2464
record/yarn.lock
2464
record/yarn.lock
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue