Center focused app based on window dimensions

Open center-app in Script Kit

// Menu: Center App
// Description: Center current focused app based on window size
// Author: Alois Carrera
import "@johnlindquist/kit"
const activeScreen = await getActiveScreen()
const {
workArea: {
height,
width,
x: workAreaX,
y: workAreaY
}
} = activeScreen
const activeAppBounds = await getActiveAppBounds()
const { top, left, right, bottom } = activeAppBounds
const windowHeight = bottom - top
const windowYCenter = windowHeight / 2
const windowWidth = right - left
const windowXCenter = windowWidth / 2
setActiveAppPosition({
x: workAreaX + (width / 2) - windowXCenter,
y: workAreaY + (height / 2) - windowYCenter
})