Improving productivity from home, or how to move the mouse on the Pi Zero

Working from home is not only a blessing, but also a serious challenge for effective managers who still measure the productivity of the IT department in their work hours. The main indicator of your work reliability is often a cheerful green status in a corporate messenger. Some take it even further and deploy employee “digital experience” tools to track how much time they've spent in Word, browser, or development environment.

There are several ways how you can resist this disgrace:

  1. . , – . / “Away”

  2. :

:

, - .

3. ,

USB HID ATmega32U4. USB. , Raspberry Pi Zero (W)? Pi0 USB , , SSH, .

, .

Pi Zero (W), SSH <- .

- Pi0, USB HID :

pi@raspberrypi:~ $ echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt
pi@raspberrypi:~ $ echo "dwc2" | sudo tee -a /etc/modules
pi@raspberrypi:~ $ sudo echo "libcomposite" | sudo tee -a /etc/modules
pi@raspberrypi:~ $ sudo touch /usr/bin/pypikey_usb
pi@raspberrypi:~ $ sudo chmod +x /usr/bin/pypikey_usb

pi@raspberrypi:~ $ sudo nano /etc/rc.local

exit 0

/usr/bin/pypikey_usb # libcomposite configuration

c USB

sudo nano /usr/bin/pypikey_usb
#!/bin/bash
cd /sys/kernel/config/usb_gadget/
mkdir -p pypikey
cd pypikey
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
mkdir -p strings/0x409
echo "0123456789" > strings/0x409/serialnumber
echo "Artyom" > strings/0x409/manufacturer
echo "PyPiKey USB Device" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower

# keyboard
REPORT_DESC="\
\\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\
\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\
\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\
\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0"

mkdir -p functions/hid.usb0
echo 1 > functions/hid.usb0/protocol
echo 1 > functions/hid.usb0/subclass
echo 8 > functions/hid.usb0/report_length
echo -ne ${REPORT_DESC} > functions/hid.usb0/report_desc
ln -s functions/hid.usb0 configs/c.1/
# End keyboard

# mouse
MOUSE_COMBINED_DESC="\
\\x05\\x01\\x09\\x02\\xa1\\x01\\x09\\x01\\xa1\\x00\\x85\\x01\\x05\\x09\\x19\\x01\
\\x29\\x03\\x15\\x00\\x25\\x01\\x95\\x03\\x75\\x01\\x81\\x02\\x95\\x01\\x75\\x05\
\\x81\\x03\\x05\\x01\\x09\\x30\\x09\\x31\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x02\
\\x81\\x06\\x95\\x02\\x75\\x08\\x81\\x01\\xc0\\xc0\\x05\\x01\\x09\\x02\\xa1\\x01\
\\x09\\x01\\xa1\\x00\\x85\\x02\\x05\\x09\\x19\\x01\\x29\\x03\\x15\\x00\\x25\\x01\
\\x95\\x03\\x75\\x01\\x81\\x02\\x95\\x01\\x75\\x05\\x81\\x01\\x05\\x01\\x09\\x30\
\\x09\\x31\\x15\\x00\\x26\\xff\\x7f\\x95\\x02\\x75\\x10\\x81\\x02\\xc0\\xc0"

mkdir -p functions/hid.usb1
echo 2 > functions/hid.usb1/protocol
echo 1 > functions/hid.usb1/subclass
echo 6 > functions/hid.usb1/report_length
echo -ne ${MOUSE_COMBINED_DESC} > functions/hid.usb1/report_desc
ln -s functions/hid.usb1 configs/c.1/
# End mouse

ls /sys/class/udc > UDC

Pi0 USB ( Pi0 USB - , ).

USB HID . Pi0 - /dev/hidg0 - . /dev/hidg1 - .

(Python):

with open('/dev/hidg1', 'rb+') as hidg1:
     hidg1.write(b'\x01\x00\xff\x00\x00\x00') #move 1 pixel right
     hidg1.write(b'\x01\x00\x01\x00\x00\x00') #move 1 pixel left

:

with open('/dev/hidg0', 'rb+') as hidg0:
     hidg0.write(b'\x00\x00\x04\x00\x00\x00\x00\x00') # 
     hidg0.write(b'\x00\x00\x00\x00\x00\x00\x00\x00') # 

There are two python files on my GitHub page . The first one (pypimu.py) is convenient to register in the scheduler to run every minute. It moves the mouse cursor one pixel to the right and immediately one pixel to the left. I can't see when this happens, but it's enough to keep the computer awake.

The second (pypikey.py) prints the text you feed to it. Something like this:

You can look at how others work for a long time ...
You can look at how others work for a long time ...

It seems that everything. Thank you for attention!




All Articles