macos-defaults/record/dock
Yann Bertrand 1914ca2179 ♻️ Use MacRunner
2020-11-13 11:34:21 +01:00
..
autohide-delay Add the dock autohide-delay command 2020-09-20 19:24:09 +02:00
autohide-time-modifier Add the dock autohide-time-modifier 2020-09-20 19:48:55 +02:00
mineffect 🔨 Fix Dock mineffect automated video capture 2020-09-30 21:20:45 +02:00
orientation ♻️ Use MacRunner 2020-11-13 11:34:21 +01:00
show-recents Add the dock show-recents command 2020-09-20 19:56:17 +02:00
tilesize Add dock tilesize command (#85) 2020-11-01 23:00:55 +01:00
readme.js Add the dock autohide command 2020-09-20 19:21:57 +02:00

const delay = require('delay')
const robot = require('robotjs')
const { captureImage, compressPngImage } = require('../utils')

module.exports = {
  run: async (outputPath) => {
    console.log('> Recording dock readme screenshot')

    // Preparation
    const { width, height } = robot.getScreenSize()
    const screenshot = `${outputPath}/dock-tmp.png`

    await delay(2000)

    // Screenshot
    captureImage(0, height - 80, width, 80).write(screenshot)

    try {
      await compressPngImage(screenshot, outputPath, 'dock')
    } catch (compressPngImageError) {
      throw new Error(compressPngImageError)
    }

    return { filepath: `${outputPath}/dock` }
  }
}