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
|
#!/bin/bash
|
||||||
args="$*"
|
|
||||||
chmod +x run.sh
|
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
|
rm -f fwledmonitor.service || true
|
||||||
sed -i "s#led_system_monitor.py.*\$#led_system_monitor.py ${args}#" run.sh
|
sed -i "s#led_system_monitor.py.*\$#led_system_monitor.py ${args}#" run.sh
|
||||||
cat <<EOF >>./fwledmonitor.service
|
cat <<EOF >>./fwledmonitor.service
|
||||||
|
@ -9,6 +18,7 @@ Description=Framework 16 LED System Monitor
|
||||||
After=network.service
|
After=network.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
Environment=DISPLAY=${dsp}
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
WorkingDirectory=$PWD
|
WorkingDirectory=$PWD
|
||||||
|
|
|
@ -16,7 +16,6 @@ from monitors import CPUMonitor, MemoryMonitor, BatteryMonitor, DiskMonitor, Net
|
||||||
# External Dependencies
|
# External Dependencies
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pynput.keyboard import Key, Listener
|
from pynput.keyboard import Key, Listener
|
||||||
import evdev
|
|
||||||
from serial.tools import list_ports
|
from serial.tools import list_ports
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,8 +35,6 @@ def discover_led_devices():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"An Exception occured while tring to locate LED Matrix devices. {e}")
|
print(f"An Exception occured while tring to locate LED Matrix devices. {e}")
|
||||||
|
|
||||||
device = evdev.InputDevice('/dev/input/event7')
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
led_devices = discover_led_devices()
|
led_devices = discover_led_devices()
|
||||||
if not len(led_devices):
|
if not len(led_devices):
|
||||||
|
|
2
run.sh
Normal file → Executable file
2
run.sh
Normal file → Executable file
|
@ -1,3 +1,3 @@
|
||||||
sudo apt install -y python3-numpy python3-psutil python3-serial python3-evdev
|
sudo apt install -y python3-numpy python3-psutil python3-serial python3-evdev
|
||||||
|
xhost +local:root
|
||||||
python3 ./led_system_monitor.py
|
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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