#!/bin/sh

DEVICE="/dev/input/event4"

turn_off_screen() {
    echo 0 > /sys/class/backlight/acx565akm/brightness
}

turn_on_screen() {
    echo 255 > /sys/class/backlight/acx565akm/brightness
}

evtest "$DEVICE" | while read -r line; do
    echo "$line" | grep -q "KEY_SCREENLOCK.*value 1" && turn_off_screen
    echo "$line" | grep -q "SW_KEYPAD_SLIDE.*value 1" && turn_on_screen
done


