diff options
| author | duckyriley <[email protected]> | 2026-11-23 20:45:44 +0800 |
|---|---|---|
| committer | duckyriley <[email protected]> | 2026-11-23 20:45:44 +0800 |
| commit | 24d7f554d00901841810b856b44d5763cbc5bd76 (patch) | |
| tree | 740eb685f70937a014a6c5e5a7fa09b51f19bac0 /build.sh | |
| download | ducky-24d7f554d00901841810b856b44d5763cbc5bd76.tar.gz ducky-24d7f554d00901841810b856b44d5763cbc5bd76.zip | |
Build native GPUI shell with Lua customization and riced defaults
Diffstat (limited to 'build.sh')
| -rwxr-xr-x | build.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..60a0957 --- /dev/null +++ b/build.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")" +# Build and install for the current user. Use --debug for a faster development build. +profile=release +if [[ ${1:-} == --debug ]]; then profile=debug; fi +build_args=(--locked) +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" +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 +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 +exe = sys.argv[1].replace('\\', '\\\\').replace('"', '\\"').replace('`', '\\`').replace('$', '\\$').replace('%', '%%') +with open(sys.argv[2], 'w') as f: + f.write('[Desktop Entry]\nType=Application\nName=Ducky Shell\nComment=Customizable native shell\n' + 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 +# 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 + 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 +done +if [[ -f $HOME/.zshrc || ${SHELL:-} == */zsh ]]; then + if ! grep -Fq '# Ducky user-local binaries' "$HOME/.zshrc" 2>/dev/null; then + printf '\n# Ducky user-local binaries\n%s\n' "$path_line" >> "$HOME/.zshrc" + fi +fi +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 +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" +printf 'Config: %s/config.lua\nOpen a new terminal or run: export PATH="$HOME/.local/bin:$PATH"\n' "$config_dir" |