diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b61a9dcb..01f19a6b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,6 @@ To make sure you can develop the script install all the tools you need: - [REUSE tool](https://git.fsfe.org/reuse/tool#install) - [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) -- p7zip ## 👷 Prepare environment diff --git a/bin/build.sh b/bin/build.sh index e2d0b7f6..0a0368e5 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -7,9 +7,7 @@ set -e # Make necessary directories -mkdir -p "${npm_package_config_build_dir:=build}/contents/code" -mkdir -p "$npm_package_config_build_dir/contents/config" -mkdir -p "$npm_package_config_build_dir/contents/ui" +mkdir -p "${npm_package_config_build_dir:=build}/script/contents/code" echo "Checking using TS Compiler..." npx tsc --noEmit @@ -17,18 +15,16 @@ npx tsc --noEmit echo "Bundling using esbuild..." npx esbuild \ --bundle src/index.ts \ - --outfile="$npm_package_config_build_dir/contents/code/index.mjs" \ + --outfile="$npm_package_config_build_dir/script/contents/code/index.mjs" \ --format=esm \ --platform=neutral # Copy resources to the build directory with correct paths -cp -v res/config.ui "$npm_package_config_build_dir/contents/ui/config.ui" -cp -v res/popup.qml "$npm_package_config_build_dir/contents/ui/popup.qml" -cp -v res/main.qml "$npm_package_config_build_dir/contents/ui/main.qml" -cp -v res/config.xml "$npm_package_config_build_dir/contents/config/main.xml" +cp -rv res/ui "$npm_package_config_build_dir/script/contents" +cp -rv res/config "$npm_package_config_build_dir/script/contents" # Copy and update metadata -METADATA_FILE="$npm_package_config_build_dir/metadata.desktop" +METADATA_FILE="$npm_package_config_build_dir/script/metadata.desktop" cp -v res/metadata.desktop "$METADATA_FILE" sed -i "s/\$VER/${npm_package_version:-1.0}/" "$METADATA_FILE" diff --git a/bin/install.sh b/bin/install.sh index 86628a31..e881325f 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -6,17 +6,16 @@ set -e -# Install icons -APP_ICONS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor/scalable/apps" -mkdir -p "$APP_ICONS_DIR" -cp -v res/icons/bismuth.svg "$APP_ICONS_DIR/bismuth.svg" +EXTRACT_DIR="${npm_package_config_build_dir:-build}/extracted-package" -# Display info and upgrade/install script -KWINPKG_FILE="${npm_package_config_build_dir:-build}/${npm_package_name:=Bismuth}-${npm_package_version:-1.0}.kwinscript" -plasmapkg2 -u "$KWINPKG_FILE" || plasmapkg2 -i "$KWINPKG_FILE" -plasmapkg2 -t kwinscript -s "$npm_package_name" +# Make directory for extraction +mkdir -p "$EXTRACT_DIR" -# Enable user configuration dialog -mkdir -p ~/.local/share/kservices5/ -ln -sf ~/.local/share/kwin/scripts/bismuth/metadata.desktop ~/.local/share/kservices5/bismuth.desktop +# Extract built package +tar xf "${npm_package_config_build_dir:-build}/package/bismuth.tar.gz" --directory="$EXTRACT_DIR" + +# Run installation script +cd "$EXTRACT_DIR" +./install.sh +cd - > /dev/null diff --git a/bin/package.sh b/bin/package.sh index 52a2f660..2210c1b9 100755 --- a/bin/package.sh +++ b/bin/package.sh @@ -6,10 +6,35 @@ set -e -KWINPKG_FILE="${npm_package_config_build_dir:=build}/${npm_package_name:-Bismuth}-${npm_package_version:-1.0}.kwinscript" +KWINPKG_NAME="bismuth.kwinscript" +FINAL_ARCHIVE_NAME="bismuth.tar.gz" -# Remove old archive -rm -f "$KWINPKG_FILE" +# Temporary change directory for archive tools +cd "./${npm_package_config_build_dir:-build}/script" -# Create new installable package -7z a -tzip "$KWINPKG_FILE" ./${npm_package_config_build_dir}/contents/ ./${npm_package_config_build_dir}/metadata.desktop +# Remove old packages +rm -f "$KWINPKG_NAME" + +# Create new .kwinscript package +zip -qr "$KWINPKG_NAME" ./contents/ ./metadata.desktop + +# Get back to the original directory +cd - > /dev/null + +# Create subdir for final package +mkdir -p "./${npm_package_config_build_dir:-build}/package" +cd "./${npm_package_config_build_dir:-build}/package" + +# Copy necessary files for package +cp -v "../script/$KWINPKG_NAME" "$KWINPKG_NAME" +cp -v "../../res/install.sh" install.sh +mkdir -p icons/ && cp -v "../../res/icons/bismuth.svg" icons/bismuth.svg + +# Create installation archive for the end user +tar -czf "$FINAL_ARCHIVE_NAME" \ + "$KWINPKG_NAME" \ + install.sh \ + icons/bismuth.svg + +# Get back to the original directory +cd - > /dev/null diff --git a/res/config.xml b/res/config/config.xml similarity index 100% rename from res/config.xml rename to res/config/config.xml diff --git a/res/install.sh b/res/install.sh new file mode 100644 index 00000000..c212207d --- /dev/null +++ b/res/install.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +# SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin +# +# SPDX-License-Identifier: MIT + +# Installation script, that comes inside of the tar.gz package + +set -e + +# Install icons +echo "🖼️ Installing icons..." +APP_ICONS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor/scalable/apps" +mkdir -p "$APP_ICONS_DIR" +cp icons/bismuth.svg "$APP_ICONS_DIR/bismuth.svg" + +# Upgrade/install script +echo "📦 Installing the script..." +KWINPKG_FILE="bismuth.kwinscript" +plasmapkg2 -u "$KWINPKG_FILE" > /dev/null || plasmapkg2 -i "$KWINPKG_FILE" > /dev/null + +# Enable user configuration dialog +echo "🔧 Enabling user configuration..." +mkdir -p ~/.local/share/kservices5/ +ln -sf ~/.local/share/kwin/scripts/bismuth/metadata.desktop ~/.local/share/kservices5/bismuth.desktop + diff --git a/res/config.ui b/res/ui/config.ui similarity index 100% rename from res/config.ui rename to res/ui/config.ui diff --git a/res/config.ui.license b/res/ui/config.ui.license similarity index 100% rename from res/config.ui.license rename to res/ui/config.ui.license diff --git a/res/main.qml b/res/ui/main.qml similarity index 100% rename from res/main.qml rename to res/ui/main.qml diff --git a/res/popup.qml b/res/ui/popup.qml similarity index 100% rename from res/popup.qml rename to res/ui/popup.qml