Enable pynput keylistener to work as service
This commit is contained in:
parent
ce88168e2e
commit
6f178c6874
5 changed files with 15 additions and 8 deletions
|
@ -1,6 +1,15 @@
|
|||
#!/bin/bash
|
||||
args="$*"
|
||||
chmod +x run.sh
|
||||
# If first arg is of form :n it will set DISPLAY to :n. Default is :0
|
||||
dsp_prefix=:
|
||||
dsp=:0
|
||||
# if [[ -n "${1+x}" ]]; then
|
||||
if [[ $1 == $dsp_prefix* ]]; then
|
||||
dsp="$1"
|
||||
shift
|
||||
fi
|
||||
# fi
|
||||
args="$*"
|
||||
rm -f fwledmonitor.service || true
|
||||
sed -i "s#led_system_monitor.py.*\$#led_system_monitor.py ${args}#" run.sh
|
||||
cat <<EOF >>./fwledmonitor.service
|
||||
|
@ -9,6 +18,7 @@ Description=Framework 16 LED System Monitor
|
|||
After=network.service
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=${dsp}
|
||||
Type=simple
|
||||
Restart=always
|
||||
WorkingDirectory=$PWD
|
||||
|
|
|
@ -16,7 +16,6 @@ from monitors import CPUMonitor, MemoryMonitor, BatteryMonitor, DiskMonitor, Net
|
|||
# External Dependencies
|
||||
import numpy as np
|
||||
from pynput.keyboard import Key, Listener
|
||||
import evdev
|
||||
from serial.tools import list_ports
|
||||
|
||||
|
||||
|
@ -35,9 +34,7 @@ def discover_led_devices():
|
|||
return sorted(locations, key = lambda x: re.sub('^\d+\-\d+\.', '', x[0]))
|
||||
except Exception as e:
|
||||
print(f"An Exception occured while tring to locate LED Matrix devices. {e}")
|
||||
|
||||
device = evdev.InputDevice('/dev/input/event7')
|
||||
|
||||
|
||||
def main(args):
|
||||
led_devices = discover_led_devices()
|
||||
if not len(led_devices):
|
||||
|
|
4
run.sh
Normal file → Executable file
4
run.sh
Normal file → Executable file
|
@ -1,3 +1,3 @@
|
|||
sudo apt install -y python3-numpy python3-psutil python3-serial python3-evdev
|
||||
|
||||
python3 ./led_system_monitor.py
|
||||
xhost +local:root
|
||||
python3 ./led_system_monitor.py
|
||||
|
|
1
snapshot_files/right/check.json
Normal file
1
snapshot_files/right/check.json
Normal file
|
@ -0,0 +1 @@
|
|||
[[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1],[0,1,0,1,0,1,0,1,0],[1,0,1,0,1,0,1,0,1]]
|
|
@ -1 +0,0 @@
|
|||
[[1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0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