Compare commits
2 commits
853be109e7
...
6f178c6874
Author | SHA1 | Date | |
---|---|---|---|
6f178c6874 | |||
ce88168e2e |
5 changed files with 107 additions and 77 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
|
||||
|
|
|
@ -15,7 +15,7 @@ from monitors import CPUMonitor, MemoryMonitor, BatteryMonitor, DiskMonitor, Net
|
|||
|
||||
# External Dependencies
|
||||
import numpy as np
|
||||
import evdev
|
||||
from pynput.keyboard import Key, Listener
|
||||
from serial.tools import list_ports
|
||||
|
||||
|
||||
|
@ -35,8 +35,6 @@ def discover_led_devices():
|
|||
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):
|
||||
|
@ -113,6 +111,27 @@ def main(args):
|
|||
"none": lambda *x: x # noop
|
||||
}
|
||||
|
||||
def on_press(key):
|
||||
global alt_pressed
|
||||
global i_pressed
|
||||
if type(key).__name__ == 'KeyCode':
|
||||
if key.char == 'i':
|
||||
i_pressed = True
|
||||
elif key == Key.alt:
|
||||
alt_pressed = True
|
||||
|
||||
def on_release(key):
|
||||
global alt_pressed
|
||||
global i_pressed
|
||||
if type(key).__name__ == 'KeyCode':
|
||||
if key.char == 'i':
|
||||
i_pressed = False
|
||||
elif key == Key.alt:
|
||||
alt_pressed = False
|
||||
if key == Key.esc:
|
||||
# Stop listener
|
||||
return False
|
||||
|
||||
#################################################
|
||||
### Load app functions from plugins ###
|
||||
if not re.search(r"--disable-plugins|-dp", str(sys.argv)):
|
||||
|
@ -133,7 +152,9 @@ def main(args):
|
|||
if args.snapshot_duration > args.snapshot_interval:
|
||||
print("Snapshot duration must be less than snapshot interval. Exiting...")
|
||||
sys.exit(0)
|
||||
start_time = time.time()
|
||||
with Listener(
|
||||
on_press=on_press,
|
||||
on_release=on_release):
|
||||
while True:
|
||||
elapsed_time = time.time()
|
||||
show_snapshot = True if args.snapshot_interval == 0 or elapsed_time % args.snapshot_interval <= args.snapshot_duration else False
|
||||
|
@ -142,8 +163,7 @@ def main(args):
|
|||
background_value = int(screen_brightness * (max_background_brightness - min_background_brightness) + min_background_brightness)
|
||||
foreground_value = int(screen_brightness * (max_foreground_brightness - min_foreground_brightness) + min_foreground_brightness)
|
||||
grid = np.zeros((9,34), dtype = int)
|
||||
active_keys = device.active_keys(verbose=True)
|
||||
if (MODIFIER_KEYS[0] in active_keys or MODIFIER_KEYS[1] in active_keys) and KEY_I in active_keys and not args.no_key_listener:
|
||||
if i_pressed and alt_pressed and not args.no_key_listener:
|
||||
if args.left_snap and show_snapshot:
|
||||
draw_id(grid, "snap", foreground_value)
|
||||
else:
|
||||
|
|
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
|
||||
|
||||
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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