Skip to content

Commit

Permalink
added script to a service
Browse files Browse the repository at this point in the history
  • Loading branch information
bitSheriff committed Sep 17, 2023
1 parent 89583c4 commit 1f64741
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions autostart_shelfslide.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
#!/bin/bash
# copy this file to "~/.config/autostart/"

python3 ~/ShelfSlide/shelfslide.py
# Path to the Python program
PROGRAM_PATH="$HOME/ShelfSlide/shelfslide.py"

# Name of the systemd service
SERVICE_NAME="shelfslide"

# Get the username of the person running the script
CURRENT_USER="$USER"

# Create the unit file
cat <<EOF > /etc/systemd/system/${SERVICE_NAME}.service
[Unit]
Description=ShelfSlide Python Program
After=network.target
[Service]
ExecStart=/usr/bin/python3 ${PROGRAM_PATH}
WorkingDirectory=$HOME/ShelfSlide
StandardOutput=inherit
StandardError=inherit
Restart=always
User=$CURRENT_USER
[Install]
WantedBy=multi-user.target
EOF

# Reload systemd
systemctl daemon-reload

# Enable and start the service
systemctl enable ${SERVICE_NAME}
systemctl start ${SERVICE_NAME}

# Display the status of the service
systemctl status ${SERVICE_NAME}

0 comments on commit 1f64741

Please sign in to comment.