Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- LID_CLOSED=21
- BUTTON_PRESSED=22
- LID_OPEN=23
- last=$LID_CLOSED
- buffer="\x08\x00\x00\x00\x00\x00\x00\x02"
- while true
- do
- echo -ne "$buffer" > /dev/hidraw3
- buf=$(head -c1 /dev/hidraw3)
- [ ${#buf} -eq 1 ] || continue
- status=$(head -c1 <<< $buf)
- status=$(echo -ne "$status" | hexdump -v -e '/1 "%d"')
- if [ $last -eq $LID_CLOSED -a $status -eq $LID_OPEN ]
- then
- echo LID OPEN $last $status
- elif [ $last -ne $BUTTON_PRESSED -a $status -eq $BUTTON_PRESSED ]
- then
- echo FIRE $last $status
- elif [ $last -ne $LID_CLOSED -a $status -eq $LID_CLOSED ]
- then
- echo LID CLOSED $last $status
- fi
- last=$status
- sleep 0.02
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement