#!/sbin/openrc-run

description="Prepare Yoga Book camera devices"

depend() {
    need modules
    before display-manager
    before yogabook-camera
}

start() {
    ebegin "Preparing Yoga Book camera devices"

    local product_file="/sys/class/dmi/id/product_name"

    # Only run on the Yoga Book YB1-X91L.
    if [ ! -r "$product_file" ] ||
       ! grep -Eq 'YB1[-_]X91L' "$product_file"; then
        einfo "Not a supported Yoga Book; skipping"
        eend 0
        return 0
    fi

    /usr/libexec/yogabook-camera/prepare-camera.sh
    eend $?
}
