diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bca3346..bf61ced 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: image: archlinux:latest steps: - name: Install packages - run: pacman -Syy -q --noconfirm && pacman -S --noconfirm git sudo base-devel p7zip nodejs jq asar electron29 libpulse dpkg unzip xdg-utils python rpm-tools + run: pacman -Syy -q --noconfirm && pacman -S -q --noconfirm git sudo base-devel p7zip nodejs jq asar electron29 libpulse dpkg unzip xdg-utils python rpm-tools - name: Checkout uses: actions/checkout@v4 with: diff --git a/build_tarball.sh b/build_tarball.sh index 58c6d3d..91b70dc 100644 --- a/build_tarball.sh +++ b/build_tarball.sh @@ -36,12 +36,12 @@ build_tarball(){ install -Dm644 "${TEMPDIR}/app/favicon.svg" "${app_dir}/usr/share/icons/hicolor/scalable/apps/yandex-music.svg" install -Dm644 "./templates/desktop" "${app_dir}/usr/share/applications/yandex-music.desktop" + install -Dm644 "./templates/default.conf" "${app_dir}/usr/lib/yandex-music/default.conf" + sed -i "s|%electron_path%|/usr/lib/yandex-music/electron/electron|g" "${app_dir}/usr/lib/yandex-music/default.conf" install -Dm644 "./LICENSE.md" "${app_dir}/usr/share/licenses/yandex-music/LICENSE" mv "${TEMPDIR}/electron-${arch}/" "${app_dir}/usr/lib/yandex-music/electron" - echo "#!/bin/sh" > "${app_dir}/usr/bin/yandex-music" - echo 'exec /usr/lib/yandex-music/electron/electron /usr/lib/yandex-music/yandex-music.asar "$@"' >> "${app_dir}/usr/bin/yandex-music" - chmod 755 "${app_dir}/usr/bin/yandex-music" + install -Dm755 "./templates/yandex-music.sh" "${app_dir}/usr/bin/yandex-music" cd "${app_dir}" tar -czf "${OUTPUT_DIR}/yandex-music_${version}_${arch}.tar.gz" * diff --git a/templates/PKGBUILD b/templates/PKGBUILD index d90001a..c1e56e0 100644 --- a/templates/PKGBUILD +++ b/templates/PKGBUILD @@ -29,10 +29,11 @@ package() { install -Dm644 "$srcdir/app/favicon.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/yandex-music.svg" install -Dm644 "$srcdir/yandex-music-linux/templates/desktop" "$pkgdir/usr/share/applications/yandex-music.desktop" + + install -Dm644 "$srcdir/yandex-music-linux/templates/default.conf" "$pkgdir/usr/lib/yandex-music/default.conf" + sed -i "s|%electron_path%|/usr/bin/electron29|g" "$pkgdir/usr/lib/yandex-music/default.conf" + install -Dm644 "$srcdir/yandex-music-linux/LICENSE.md" "$pkgdir/usr/share/licenses/$pkgname/LICENSE" - # Create a script to launch the app with Electron - echo "#!/bin/sh" > "$pkgdir/usr/bin/yandex-music" - echo 'exec electron29 /usr/lib/yandex-music/yandex-music.asar "$@"' >> "$pkgdir/usr/bin/yandex-music" - chmod 755 "$pkgdir/usr/bin/yandex-music" + install -Dm755 "$srcdir/yandex-music-linux/templates/yandex-music.sh" "$pkgdir/usr/bin/yandex-music" } diff --git a/templates/default.conf b/templates/default.conf new file mode 100644 index 0000000..522dd2a --- /dev/null +++ b/templates/default.conf @@ -0,0 +1,2 @@ +ELECTRON_BIN=%electron_path% +ELECTRON_ARGS="--no-sandbox" \ No newline at end of file diff --git a/templates/yandex-music.sh b/templates/yandex-music.sh new file mode 100644 index 0000000..b85d6a7 --- /dev/null +++ b/templates/yandex-music.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +CONFIG_FILE="${YANDEX_MUSIC_CONFIG:-$CONFIG_HOME/yandex-music.conf}" + +echo "Using config file: ${CONFIG_FILE}" + +if [ ! -f "$CONFIG_FILE" ]; then + echo "Config file not found, copying default" + mkdir -p "$(dirname "$CONFIG_FILE")" + cp /usr/lib/yandex-music/default.conf "$CONFIG_FILE" +fi + +source "$CONFIG_FILE" + +WAYLAND_FLAGS="" +if [ "$XDG_SESSION_TYPE" == "wayland" ]; then + WAYLAND_FLAGS="--enable-features=UseOzonePlatform --ozone-platform=wayland" +fi + +if [ -z "$ELECTRON_BIN" ]; then + echo "ELECTRON_BIN is not set" + exit 1 +fi + +exec "${ELECTRON_BIN}" "${ELECTRON_ARGS}" "${WAYLAND_FLAGS}" /usr/lib/yandex-music/app.asar \ No newline at end of file