diff --git a/.gitignore b/.gitignore index 7e99e36..1059bd4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.pyc \ No newline at end of file +*.pyc +fwledmonitor.service diff --git a/install_as_service.sh b/install_as_service.sh new file mode 100644 index 0000000..09aab1a --- /dev/null +++ b/install_as_service.sh @@ -0,0 +1,21 @@ +chmod +x run.sh +rm -f fwledmonitor.service || true +cat <>./fwledmonitor.service +[Unit] +Description=Framework 16 LED System Monitor +After=network.service + +[Service] +Type=simple +Restart=always +WorkingDirectory=$PWD +ExecStart=sh -c "'$PWD/run.sh'" + +[Install] +WantedBy=default.target +EOF + +sudo systemctl stop fwledmonitor +sudo cp fwledmonitor.service /lib/systemd/system +sudo systemctl daemon-reload +sudo systemctl enable fwledmonitor diff --git a/led_system_monitor.py b/led_system_monitor.py index be34761..c519af1 100644 --- a/led_system_monitor.py +++ b/led_system_monitor.py @@ -78,9 +78,13 @@ if __name__ == "__main__": draw_bar(grid, last_network_download, foreground_value, bar_x_offset=5, draw_at_bottom=True) # Download draw_borders_right(grid, background_value) right_drawing_queue.put(grid) + except KeyboardInterrupt: + break except Exception as e: import traceback print(f"Error in main loop: {e}") traceback.print_exc() time.sleep(1.0) - time.sleep(0.1) \ No newline at end of file + time.sleep(0.1) + + print("Exiting") \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..f6dab9f --- /dev/null +++ b/run.sh @@ -0,0 +1,3 @@ +sudo apt install python3-numpy python3-psutil + +python3 ./led_system_monitor.py