From 4fd51caee09167571af726b870274bad2f40a2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Tue, 26 Dec 2023 18:31:15 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(systemd):=20conve?= =?UTF-8?q?rt=20spotdl=20scripts=20into=201=20and=20change=20the=20name=20?= =?UTF-8?q?to=20the=20services?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/systemd/user/downloadSpotify.service | 10 ++++++++++ .../{spotdl_sync.timer => downloadSpotify.timer} | 2 +- .config/systemd/user/spotdl_sync.service | 10 ---------- .local/bin/{downloadMusic => downloadSpotify} | 8 ++++++-- .local/bin/spotdlSync | 14 -------------- 5 files changed, 17 insertions(+), 27 deletions(-) create mode 100644 .config/systemd/user/downloadSpotify.service rename .config/systemd/user/{spotdl_sync.timer => downloadSpotify.timer} (81%) delete mode 100644 .config/systemd/user/spotdl_sync.service rename .local/bin/{downloadMusic => downloadSpotify} (66%) delete mode 100755 .local/bin/spotdlSync diff --git a/.config/systemd/user/downloadSpotify.service b/.config/systemd/user/downloadSpotify.service new file mode 100644 index 00000000..078867d1 --- /dev/null +++ b/.config/systemd/user/downloadSpotify.service @@ -0,0 +1,10 @@ +[Unit] +Description=Download Spotify Lists using spotdl +After=network.target + +[Service] +Type=simple +ExecStart=/home/matt/.local/bin/downloadSpotify + +[Install] +WantedBy=default.target diff --git a/.config/systemd/user/spotdl_sync.timer b/.config/systemd/user/downloadSpotify.timer similarity index 81% rename from .config/systemd/user/spotdl_sync.timer rename to .config/systemd/user/downloadSpotify.timer index 55592048..b206ca3f 100644 --- a/.config/systemd/user/spotdl_sync.timer +++ b/.config/systemd/user/downloadSpotify.timer @@ -4,7 +4,7 @@ Description=Run Spotdl Sync Weekly [Timer] OnCalendar=Sun 18:00:00 Persistent=true -Unit=spotdl_sync.service +Unit=downloadSpotify.service [Install] WantedBy=timers.target diff --git a/.config/systemd/user/spotdl_sync.service b/.config/systemd/user/spotdl_sync.service deleted file mode 100644 index 3500ab43..00000000 --- a/.config/systemd/user/spotdl_sync.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Download music using spotdl -After=network.target - -[Service] -Type=simple -ExecStart=/home/matt/.local/bin/downloadMusic - -[Install] -WantedBy=default.target diff --git a/.local/bin/downloadMusic b/.local/bin/downloadSpotify similarity index 66% rename from .local/bin/downloadMusic rename to .local/bin/downloadSpotify index 308dce06..8d42ca21 100755 --- a/.local/bin/downloadMusic +++ b/.local/bin/downloadSpotify @@ -16,8 +16,12 @@ FOLDERS=( notify-send "Spotdl Sync" "Started syncing..." -for folder in "${FOLDERS[@]}"; do - /home/matt/.local/bin/spotdlSync "$folder" # TODO: Change the path to relative without breaking the systemd service +for FOLDER in "${FOLDERS[@]}"; do + cd "$HOME/Musica/Listen-To/$FOLDER" || continue + + spotdl sync "${FOLDER,,}.sync.spotdl" + + notify-send "Spotdl Sync" "$FOLDER synced" done notify-send "Spotdl Sync Complete" diff --git a/.local/bin/spotdlSync b/.local/bin/spotdlSync deleted file mode 100755 index 75b9f227..00000000 --- a/.local/bin/spotdlSync +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/bash - -FOLDER=$1 - -if [ ! -d "$HOME/Musica/Listen-To/$FOLDER" ]; then - notify-send "Spotdl Sync" "The folder $FOLDER doesnt exist" - exit 1 -fi - -cd "$HOME/Musica/Listen-To/$FOLDER" - -spotdl sync "${FOLDER,,}.sync.spotdl" - -notify-send "Spotdl Sync" "$FOLDER synced"