diff --git a/packaging/appimage/AppRun b/packaging/appimage/AppRun new file mode 100755 index 0000000..034cd51 --- /dev/null +++ b/packaging/appimage/AppRun @@ -0,0 +1,19 @@ +#!/bin/sh +set -e +HERE="$(dirname "$(readlink -f "$0")")" +export PATH="$HERE/usr/bin:$PATH" +export XDG_DATA_DIRS="$HERE/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" + +case "$1" in + daemon) + shift + exec "$HERE/usr/bin/blocker-daemon" "$@" + ;; + ui) + shift + exec "$HERE/usr/bin/blocker-ui" "$@" + ;; + *) + exec "$HERE/usr/bin/blocker-daemon" "$@" + ;; +esac diff --git a/packaging/appimage/blocker.desktop b/packaging/appimage/blocker.desktop new file mode 100644 index 0000000..607679d --- /dev/null +++ b/packaging/appimage/blocker.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Blocker +Comment=Focus and app blocking daemon +Exec=AppRun +Icon=blocker +Type=Application +Categories=Utility; +Terminal=true diff --git a/packaging/appimage/blocker.svg b/packaging/appimage/blocker.svg new file mode 100644 index 0000000..f45d13f --- /dev/null +++ b/packaging/appimage/blocker.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/systemd/blocker.service b/packaging/systemd/blocker.service new file mode 100644 index 0000000..60f493e --- /dev/null +++ b/packaging/systemd/blocker.service @@ -0,0 +1,13 @@ +[Unit] +Description=Blocker Focus Daemon +PartOf=graphical-session.target +After=graphical-session.target + +[Service] +Type=simple +ExecStart=%h/.local/bin/blocker-daemon +Restart=always +RestartSec=3 + +[Install] +WantedBy=graphical-session.target diff --git a/scripts/build-appimage.sh b/scripts/build-appimage.sh new file mode 100755 index 0000000..bafca64 --- /dev/null +++ b/scripts/build-appimage.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Build an AppImage packaging blocker-daemon, blocker-ui and assets. + +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +DIST_DIR="$ROOT_DIR/dist" +APPDIR="$DIST_DIR/AppDir" +PKG_DIR="$ROOT_DIR/packaging/appimage" + +echo "Building release binaries..." +cargo build --release -p blocker-daemon -p blocker-ui + +echo "Preparing AppDir structure..." +mkdir -p "$APPDIR" +mkdir -p "$APPDIR/usr/bin" +mkdir -p "$APPDIR/usr/share/applications" +mkdir -p "$APPDIR/usr/share/icons/hicolor/scalable/apps" + +cp "$ROOT_DIR/target/release/blocker-daemon" "$APPDIR/usr/bin/" +cp "$ROOT_DIR/target/release/blocker-ui" "$APPDIR/usr/bin/" +cp "$PKG_DIR/AppRun" "$APPDIR/AppRun" +cp "$PKG_DIR/blocker.desktop" "$APPDIR/blocker.desktop" +cp "$PKG_DIR/blocker.desktop" "$APPDIR/usr/share/applications/" +cp "$PKG_DIR/blocker.svg" "$APPDIR/blocker.svg" +cp "$PKG_DIR/blocker.svg" "$APPDIR/usr/share/icons/hicolor/scalable/apps/" +chmod +x "$APPDIR/AppRun" + +OUTPUT_APPIMAGE="$DIST_DIR/Blocker-x86_64.AppImage" +rm -f "$OUTPUT_APPIMAGE" + +echo "Creating AppImage with mksquashfs..." +mksquashfs "$APPDIR" "$OUTPUT_APPIMAGE" -root-owned -noappend -comp xz + +echo "Built AppImage: $OUTPUT_APPIMAGE" +ls -lh "$OUTPUT_APPIMAGE"