aboutsummaryrefslogtreecommitdiffstats
path: root/build.sh
diff options
context:
space:
mode:
authorduckyriley <[email protected]>2026-11-23 20:50:50 +0800
committerduckyriley <[email protected]>2026-11-23 20:50:50 +0800
commit6bb21305adcf8155a8488bc69ebddd4edc710930 (patch)
treea607bd6c2d63d3c4c51e8a395cc8ec0e1cf43d28 /build.sh
parent24d7f554d00901841810b856b44d5763cbc5bd76 (diff)
downloadducky-6bb21305adcf8155a8488bc69ebddd4edc710930.tar.gz
ducky-6bb21305adcf8155a8488bc69ebddd4edc710930.zip
Support macOS app bundles and document Linux distro builds
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh42
1 files changed, 38 insertions, 4 deletions
diff --git a/build.sh b/build.sh
index 60a0957..3b7a91e 100755
--- a/build.sh
+++ b/build.sh
@@ -2,6 +2,12 @@
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
# Build and install for the current user. Use --debug for a faster development build.
+platform=$(uname -s)
+case "$platform" in
+ Linux) default_config="$HOME/.config" ;;
+ Darwin) default_config="$HOME/Library/Application Support" ;;
+ *) printf 'Unsupported platform: %s\n' "$platform" >&2; exit 1 ;;
+esac
profile=release
if [[ ${1:-} == --debug ]]; then profile=debug; fi
build_args=(--locked)
@@ -9,14 +15,15 @@ if [[ $profile == release ]]; then build_args+=(--release); fi
cargo build "${build_args[@]}" -j "${CARGO_BUILD_JOBS:-4}"
bin_dir="$HOME/.local/bin"
data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
-config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/ducky"
-install -d "$bin_dir" "$data_dir/applications" "$data_dir/icons/hicolor/scalable/apps" "$config_dir"
+config_dir="${XDG_CONFIG_HOME:-$default_config}/ducky"
+install -d "$bin_dir" "$config_dir"
install -m 755 "target/$profile/ducky" "$bin_dir/ducky"
install -d "$config_dir/themes"
if [[ ! -e $config_dir/shell.bash ]]; then install -m 644 assets/shell.bash "$config_dir/shell.bash"; fi
if [[ ! -e $config_dir/themes/lagoon.lua ]]; then install -m 644 assets/themes/lagoon.lua "$config_dir/themes/lagoon.lua"; fi
+if [[ $platform == Linux ]]; then
+install -d "$data_dir/applications" "$data_dir/icons/hicolor/scalable/apps"
install -m 644 assets/ducky.svg "$data_dir/icons/hicolor/scalable/apps/dev.ducky.shell.svg"
-if [[ ! -e $config_dir/config.lua ]]; then install -m 644 assets/config.lua "$config_dir/config.lua"; fi
# Desktop Exec fields have their own quoting rules (not shell quoting).
python3 - "$bin_dir/ducky" "$data_dir/applications/dev.ducky.shell.desktop" <<'PY'
import sys
@@ -26,9 +33,34 @@ with open(sys.argv[2], 'w') as f:
f'Exec="{exe}"\nIcon=dev.ducky.shell\nTerminal=false\nCategories=System;TerminalEmulator;\n'
'Keywords=terminal;shell;lua;\nStartupNotify=true\nStartupWMClass=dev.ducky.shell\n')
PY
+else
+app_dir="$HOME/Applications/Ducky.app"
+install -d "$app_dir/Contents/MacOS"
+install -m 755 "target/$profile/ducky" "$app_dir/Contents/MacOS/ducky"
+python3 - "$app_dir/Contents/Info.plist" <<'PYINFO'
+import plistlib, sys
+with open(sys.argv[1], 'wb') as f:
+ plistlib.dump({
+ 'CFBundleName': 'Ducky',
+ 'CFBundleDisplayName': 'Ducky',
+ 'CFBundleIdentifier': 'dev.ducky.shell',
+ 'CFBundleExecutable': 'ducky',
+ 'CFBundlePackageType': 'APPL',
+ 'CFBundleShortVersionString': '0.1.0',
+ 'CFBundleVersion': '1',
+ 'NSHighResolutionCapable': True,
+ }, f)
+PYINFO
+# Sign locally built code for the current Mac; no developer certificate required.
+codesign --force --deep --sign - "$app_dir"
+register=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
+if [[ -x $register ]]; then "$register" -f "$app_dir"; fi
+printf 'Installed %s (open with Finder or Spotlight).\n' "$app_dir"
+fi
+if [[ ! -e $config_dir/config.lua ]]; then install -m 644 assets/config.lua "$config_dir/config.lua"; fi
# Make the user-local executable directory persistent in common login shells.
path_line='export PATH="$HOME/.local/bin:$PATH"'
-for rc in "$HOME/.profile" "$HOME/.bashrc"; do
+for rc in "$HOME/.profile" "$HOME/.bashrc" "$HOME/.bash_profile"; do
if ! grep -Fq '# Ducky user-local binaries' "$rc" 2>/dev/null; then
printf '\n# Ducky user-local binaries\n%s\n' "$path_line" >> "$rc"
fi
@@ -42,7 +74,9 @@ if [[ -d $HOME/.config/fish || ${SHELL:-} == */fish ]]; then
install -d "$HOME/.config/fish/conf.d"
printf 'fish_add_path "$HOME/.local/bin"\n' > "$HOME/.config/fish/conf.d/ducky-path.fish"
fi
+if [[ $platform == Linux ]]; then
command -v update-desktop-database >/dev/null && update-desktop-database "$data_dir/applications" || true
command -v gtk-update-icon-cache >/dev/null && gtk-update-icon-cache -f -t "$data_dir/icons/hicolor" >/dev/null 2>&1 || true
printf '\nInstalled %s/ducky and Ducky Shell in your app launcher.\n' "$bin_dir"
+fi
printf 'Config: %s/config.lua\nOpen a new terminal or run: export PATH="$HOME/.local/bin:$PATH"\n' "$config_dir"