From d9d6cbeec5721dc63ce6ca14ffeff2392a02dd1f Mon Sep 17 00:00:00 2001 From: PAlexanderFranklin Date: Thu, 1 Aug 2024 17:46:39 -0700 Subject: [PATCH] Make installation user-specific --- install.sh | 22 ++++++++++++++++------ src/screenmonitor.service | 8 ++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 2953d92..c6e15f2 100644 --- a/install.sh +++ b/install.sh @@ -1,18 +1,28 @@ #!/bin/bash # Install Python dependencies -pip3 install -r requirements.txt +pip3 install --user -r requirements.txt + +# Create necessary directories +mkdir -p ~/.screenmonitor/script +mkdir -p ~/.screenmonitor/output + +# Copy Python script to the install location +cp src/screenmonitor.py ~/.screenmonitor/script/ + +# Create user-specific systemd directory +mkdir -p ~/.config/systemd/user/ # Copy the systemd service file -sudo cp src/screenmonitor.service /etc/systemd/system/ +cp src/screenmonitor.service ~/.config/systemd/user/screenmonitor.service # Reload systemd to recognize the new service -sudo systemctl daemon-reload +systemctl --user daemon-reload # Enable the service to start on boot -sudo systemctl enable screenmonitor +systemctl --user enable screenmonitor # Start the service -sudo systemctl start screenmonitor +systemctl --user start screenmonitor -echo "Service installed and started successfully." +echo "Service installed and started successfully for user $USER." diff --git a/src/screenmonitor.service b/src/screenmonitor.service index 5551695..10c7dcd 100644 --- a/src/screenmonitor.service +++ b/src/screenmonitor.service @@ -1,11 +1,11 @@ [Unit] -Description=My Custom Service +Description=Screen Monitor Service After=network.target [Service] -ExecStart=/usr/bin/python3 /path/to/my_service/src/script.py +ExecStart=/usr/bin/python3 /home/%u/.screenmonitor/script/screenmonitor.py Restart=always -User=your_user +User=%u [Install] -WantedBy=multi-user.target +WantedBy=default.target