From 15fa581e6a331d9c91b5cf6da86b3f5bc3373faf Mon Sep 17 00:00:00 2001 From: PAlexanderFranklin Date: Thu, 1 Aug 2024 17:20:44 -0700 Subject: [PATCH] add LLM generated files --- README.md | 4 ++++ install.sh | 18 ++++++++++++++++++ requirements.txt | 3 +++ src/screenmonitor.py | 40 +++++++++++++++++++++++++++++++++++++++ src/screenmonitor.service | 11 +++++++++++ 5 files changed, 76 insertions(+) create mode 100644 install.sh create mode 100644 requirements.txt create mode 100644 src/screenmonitor.py create mode 100644 src/screenmonitor.service diff --git a/README.md b/README.md index e69de29..e86a281 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,4 @@ +# Update package list and install pip + +sudo apt-get update +sudo apt-get install -y python3-pip diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..2953d92 --- /dev/null +++ b/install.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Install Python dependencies +pip3 install -r requirements.txt + +# Copy the systemd service file +sudo cp src/screenmonitor.service /etc/systemd/system/ + +# Reload systemd to recognize the new service +sudo systemctl daemon-reload + +# Enable the service to start on boot +sudo systemctl enable screenmonitor + +# Start the service +sudo systemctl start screenmonitor + +echo "Service installed and started successfully." diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..af8f661 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +pillow +pyautogui +schedule \ No newline at end of file diff --git a/src/screenmonitor.py b/src/screenmonitor.py new file mode 100644 index 0000000..d89113b --- /dev/null +++ b/src/screenmonitor.py @@ -0,0 +1,40 @@ +import os +import random +import time +from datetime import datetime +from PIL import Image, ImageFilter +import pyautogui +import schedule + + +def capture_screenshot(folder): + # Capture screenshot + screenshot = pyautogui.screenshot() + + # Apply blur + blurred_screenshot = screenshot.filter(ImageFilter.GaussianBlur(10)) + + # Compress and save + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + filename = os.path.join(folder, f"screenshot_{timestamp}.jpeg") + blurred_screenshot.save(filename, "JPEG", quality=20) + print(f"Screenshot saved to {filename}") + + +def job(): + capture_screenshot("/path/to/folder") + + +def main(): + # Schedule screenshots at random intervals + for _ in range(10): # Number of times to schedule + random_interval = random.randint(1, 60) # Random interval in minutes + schedule.every(random_interval).minutes.do(job) + + while True: + schedule.run_pending() + time.sleep(1) + + +if __name__ == "__main__": + main() diff --git a/src/screenmonitor.service b/src/screenmonitor.service new file mode 100644 index 0000000..5551695 --- /dev/null +++ b/src/screenmonitor.service @@ -0,0 +1,11 @@ +[Unit] +Description=My Custom Service +After=network.target + +[Service] +ExecStart=/usr/bin/python3 /path/to/my_service/src/script.py +Restart=always +User=your_user + +[Install] +WantedBy=multi-user.target