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
- while true
- do
- echo -ne "\x08\x00\x00\x00\x00\x00\x00\x02" > buf
- dd if=buf of=/dev/hidraw3 bs=8 count=1 conv=notrunc
- rm -f buf
- dd if=/dev/hidraw3 of=buf bs=1 count=1
- last=$LID_CLOSED
- siz=$(cat buf | wc -c)
- [ $siz -eq 1 ] || continue
- status=$(head -c1 buf)
- estado=$(echo $status | od -h | grep -Eo "0a[0-9]{2}" | cut -f2 -da)
- echo $estado
- status=$((16#$estado))
- echo last: $last
- echo status: $status
- [ $last -eq $LID_CLOSED -a $status -eq $LID_OPEN ] && echo LID OPEN $last $status
- [ $last -ne $BUTTON_PRESSED -a $status -eq $BUTTON_PRESSED ] && echo FIRE $last $status
- [ $last -ne $LID_CLOSED -a $status -eq $LID_CLOSED ] && echo LID CLOSED $last $status
- last=$status
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement