aboutsummaryrefslogtreecommitdiffstats
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
parent24d7f554d00901841810b856b44d5763cbc5bd76 (diff)
downloadducky-6bb21305adcf8155a8488bc69ebddd4edc710930.tar.gz
ducky-6bb21305adcf8155a8488bc69ebddd4edc710930.zip
Support macOS app bundles and document Linux distro builds
Diffstat (limited to '')
-rw-r--r--.github/workflows/macos.yml30
-rw-r--r--assets/config.lua2
-rwxr-xr-xbuild.sh42
-rw-r--r--readme.md79
-rw-r--r--scripts/test-installer.py54
-rw-r--r--src/config.rs19
-rw-r--r--src/main.rs94
7 files changed, 265 insertions, 55 deletions
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
new file mode 100644
index 0000000..55c5d67
--- /dev/null
+++ b/.github/workflows/macos.yml
@@ -0,0 +1,30 @@
+name: macOS build
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
+jobs:
+ build:
+ strategy:
+ matrix:
+ os: [macos-15, macos-15-intel]
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/checkout@v4
+ - name: Prepare Rust and native tools
+ run: |
+ rustup update stable
+ rustup default stable
+ brew install cmake pkgconf python
+ if ! xcrun --find metal >/dev/null 2>&1; then
+ xcodebuild -downloadComponent MetalToolchain
+ fi
+ - name: Test
+ run: cargo test --locked
+ - name: Build and package
+ run: ./build.sh
+ - name: Check installed configuration and app bundle
+ run: |
+ "$HOME/.local/bin/ducky" --check-config
+ plutil -lint "$HOME/Applications/Ducky.app/Contents/Info.plist"
+ codesign --verify --deep --strict "$HOME/Applications/Ducky.app"
diff --git a/assets/config.lua b/assets/config.lua
index 0a5694f..65de5ea 100644
--- a/assets/config.lua
+++ b/assets/config.lua
@@ -20,7 +20,7 @@ return {
height = 720,
scrollback = 10000,
shell = '/bin/bash',
- args = { '--rcfile', (os.getenv('XDG_CONFIG_HOME') or home .. '/.config') .. '/ducky/shell.bash', '-i' },
+ args = { '--rcfile', ducky.config_dir .. '/shell.bash', '-i' },
cwd = home,
env = { COLORTERM = 'truecolor' },
-- Send any command or escape sequence using a custom shortcut.
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"
diff --git a/readme.md b/readme.md
index 17f90a7..eb465ff 100644
--- a/readme.md
+++ b/readme.md
@@ -1,15 +1,86 @@
# Build
-Linux (Ubuntu/Debian), Rust 1.94 or newer, Python 3, and a Vulkan-capable graphics driver:
+Rust 1.94 or newer, Python 3, Git, and Bash are required. Linux also needs a Vulkan-capable graphics driver; macOS uses Metal. Install the dependencies for your system below, then follow **Build and install**.
+
+## Ubuntu / Debian / Linux Mint / Pop!_OS
```sh
-sudo apt install build-essential pkg-config cmake clang libclang-dev \
+sudo apt install build-essential git curl python3 pkg-config cmake clang libclang-dev \
libfontconfig1-dev libfreetype-dev libxkbcommon-dev libxkbcommon-x11-dev \
libwayland-dev libssl-dev libzstd-dev libxcb1-dev vulkan-tools
+```
+
+## Arch Linux / EndeavourOS / Manjaro
+
+```sh
+sudo pacman -Syu --needed base-devel git curl python pkgconf cmake clang \
+ fontconfig freetype2 libxkbcommon libxkbcommon-x11 wayland openssl zstd \
+ libxcb vulkan-icd-loader vulkan-tools ttf-jetbrains-mono-nerd
+```
+
+Install your GPU's Vulkan driver as well: `vulkan-radeon` for AMD, `vulkan-intel` for Intel, or the appropriate NVIDIA driver for your GPU. Manjaro users should use their distribution's driver tools.
+
+## Fedora
+
+```sh
+sudo dnf install gcc gcc-c++ make git curl python3 pkgconf-pkg-config cmake \
+ clang clang-devel fontconfig-devel freetype-devel libxkbcommon-devel \
+ libxkbcommon-x11-devel wayland-devel openssl-devel libzstd-devel \
+ libxcb-devel vulkan-loader vulkan-tools
+```
+
+## openSUSE Tumbleweed
+
+```sh
+sudo zypper install gcc gcc-c++ make git curl python3 pkg-config cmake clang \
+ clang-devel fontconfig-devel freetype2-devel libxkbcommon-devel \
+ libxkbcommon-x11-devel wayland-devel libopenssl-3-devel libzstd-devel \
+ libxcb-devel vulkan-tools
+```
+
+## macOS (Apple Silicon or Intel)
+
+Install and open [Xcode](https://developer.apple.com/xcode/) with the macOS components, then select its developer tools:
+
+```sh
+xcode-select --install
+sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
+sudo xcodebuild -license accept
+```
+
+With [Homebrew](https://brew.sh/) installed:
+
+```sh
+brew install cmake pkgconf python git
+```
+
+If Xcode reports that the Metal toolchain is missing, run `xcodebuild -downloadComponent MetalToolchain` before building. Build on the Mac you will run Ducky on; the script builds for the host architecture.
+
+## Build and install
+
+Install Rust using [rustup](https://rustup.rs/) if needed:
+
+```sh
+curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
+. "$HOME/.cargo/env"
+rustup update stable
+```
+
+Clone the repository and run the installer:
+
+```sh
+git clone https://github.com/OrielProject/ducky.git
+cd ducky
./build.sh
```
-`./build.sh` builds the release binary, installs `~/.local/bin/ducky`, adds that directory to your shell's PATH, and installs **Ducky Shell** in your desktop app launcher. Open a new terminal to use `ducky`. Use `./build.sh --debug` for a development build, or `cargo build --locked` to build without installing.
+`./build.sh` builds the release binary, installs `~/.local/bin/ducky`, and adds that directory to your shell's PATH. Open a new terminal to use `ducky`.
+
+- **Linux:** installs **Ducky Shell** in your desktop app launcher. Configuration is in `~/.config/ducky/`.
+- **macOS:** installs `~/Applications/Ducky.app` for Finder or Spotlight. Configuration is in `~/Library/Application Support/ducky/`. You can launch it with `open "$HOME/Applications/Ducky.app"`.
+- Set `XDG_CONFIG_HOME` to override the configuration root on either platform. Existing configuration files are preserved.
+- Use `./build.sh --debug` for a development build, or `cargo build --locked` to build without installing.
+- For the default appearance, install **JetBrainsMono Nerd Font Mono** from [Nerd Fonts](https://www.nerdfonts.com/font-downloads), or set `font` in `config.lua` to an installed monospace font. Arch's command above includes the font.
# Screenshots
@@ -26,7 +97,7 @@ sudo apt install build-essential pkg-config cmake clang libclang-dev \
- Tabs: `Ctrl+Shift+T` opens, `Ctrl+Shift+W` closes, `Ctrl+Tab` cycles.
- Mouse selection, `Ctrl+Shift+C` copies selection (or visible screen), `Ctrl+Shift+V` pastes with bracketed-paste support.
- Mouse-wheel scrollback and `Shift+PageUp` / `Shift+PageDown`.
-- Lua 5.4 configuration in `$XDG_CONFIG_HOME/ducky/config.lua` (defaults to `~/.config/ducky/config.lua`), created on first launch. Lua modules can live alongside it.
+- Lua 5.4 configuration in your platform's config directory under `ducky/config.lua` (paths above), created on first launch. Lua modules can live alongside it.
- Customize fonts, spacing, colors, ANSI palette, window dimensions, shell arguments, environment, startup commands, and shortcuts. The generated config contains examples. Lua scripts run with your user permissions.
- `Ctrl+Shift+R` reloads appearance and bindings; new tabs pick up shell/environment changes. `Ctrl+Shift++` / `Ctrl+Shift+-` changes font size.
- `ducky --check-config` validates Lua; `ducky --config-dir` prints its location.
diff --git a/scripts/test-installer.py b/scripts/test-installer.py
new file mode 100644
index 0000000..3be193c
--- /dev/null
+++ b/scripts/test-installer.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+"""Check installer layout with mocked build/OS tools; not a native macOS build."""
+import os
+from pathlib import Path
+import plistlib
+import shutil
+import subprocess
+import tempfile
+
+SOURCE = Path(__file__).resolve().parents[1]
+for platform in ('Linux', 'Darwin'):
+ with tempfile.TemporaryDirectory(prefix='ducky-install-') as temporary:
+ root = Path(temporary)
+ checkout = root / 'checkout'
+ checkout.mkdir()
+ shutil.copy2(SOURCE / 'build.sh', checkout / 'build.sh')
+ shutil.copytree(SOURCE / 'assets', checkout / 'assets')
+ binary = checkout / 'target/release/ducky'
+ binary.parent.mkdir(parents=True)
+ binary.write_text('#!/bin/sh\nexit 0\n')
+ binary.chmod(0o755)
+ home = root / 'home with spaces'
+ home.mkdir()
+ stubs = root / 'stubs'
+ stubs.mkdir()
+ for name, body in {'uname': f'printf "{platform}\\n"', 'cargo': 'exit 0', 'codesign': 'exit 0'}.items():
+ path = stubs / name
+ path.write_text('#!/bin/sh\n' + body + '\n')
+ path.chmod(0o755)
+ env = dict(os.environ, HOME=str(home), SHELL='/bin/zsh', PATH=f'{stubs}:{os.environ["PATH"]}')
+ for key in ('XDG_CONFIG_HOME', 'XDG_DATA_HOME'):
+ env.pop(key, None)
+ config = home / ('Library/Application Support' if platform == 'Darwin' else '.config') / 'ducky'
+ def install():
+ subprocess.run(['bash', str(checkout / 'build.sh')], env=env, check=True, stdout=subprocess.DEVNULL)
+ install()
+ assert (home / '.local/bin/ducky').read_bytes() == binary.read_bytes()
+ assert (config / 'shell.bash').is_file()
+ assert (config / 'config.lua').is_file()
+ if platform == 'Darwin':
+ app = home / 'Applications/Ducky.app/Contents'
+ with (app / 'Info.plist').open('rb') as stream:
+ info = plistlib.load(stream)
+ assert info['CFBundleExecutable'] == 'ducky'
+ assert info['CFBundleIdentifier'] == 'dev.ducky.shell'
+ assert (app / 'MacOS/ducky').read_bytes() == binary.read_bytes()
+ assert not (home / '.local/share/applications').exists()
+ else:
+ assert (home / '.local/share/applications/dev.ducky.shell.desktop').is_file()
+ (config / 'config.lua').write_text('-- keep my config\nreturn {}\n')
+ install()
+ assert (config / 'config.lua').read_text().startswith('-- keep my config')
+ assert (home / '.zshrc').read_text().count('# Ducky user-local binaries') == 1
+ print(f'{platform}: package layout, paths with spaces, config preservation, and repeat installation passed')
diff --git a/src/config.rs b/src/config.rs
index 65720e3..c1b00ae 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -29,7 +29,10 @@ pub struct Config {
pub startup: Option<String>,
}
pub fn directory() -> PathBuf {
- dirs::config_dir()
+ std::env::var_os("XDG_CONFIG_HOME")
+ .filter(|value| !value.is_empty())
+ .map(PathBuf::from)
+ .or_else(dirs::config_dir)
.unwrap_or_else(|| PathBuf::from("."))
.join("ducky")
}
@@ -57,6 +60,14 @@ impl Config {
}
pub(crate) fn parse(source: &str, dir: &std::path::Path) -> Result<Self> {
let lua = Lua::new();
+ let api = lua
+ .create_table()
+ .map_err(|e| anyhow::anyhow!(e.to_string()))?;
+ api.set("config_dir", dir.to_string_lossy().as_ref())
+ .map_err(|e| anyhow::anyhow!(e.to_string()))?;
+ lua.globals()
+ .set("ducky", api)
+ .map_err(|e| anyhow::anyhow!(e.to_string()))?;
let package: Table = lua
.globals()
.get("package")
@@ -173,6 +184,12 @@ mod tests {
assert_eq!(c.palette.len(), 16);
}
#[test]
+ fn prompt_path_uses_platform_config_directory() {
+ let dir = std::path::Path::new("/Users/example/Library/Application Support/ducky");
+ let c = Config::parse(DEFAULT, dir).unwrap();
+ assert_eq!(c.args[1], dir.join("shell.bash").to_string_lossy());
+ }
+ #[test]
fn rejects_bad_config() {
assert!(Config::parse("return {font_size=0}", std::path::Path::new("/tmp")).is_err());
assert!(color("#ff").is_err());
diff --git a/src/main.rs b/src/main.rs
index 34117c3..f6a6dfb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -539,6 +539,7 @@ impl Render for Ducky {
.flex()
.items_center()
.gap_2()
+ .when(cfg!(target_os = "macos"), |s| s.pl(px(84.)))
.children(tabs)
.child(
div()
@@ -566,51 +567,54 @@ impl Render for Ducky {
}
},
))
- .child(
- div()
- .id("minimize")
- .size(px(28.))
- .rounded_md()
- .flex()
- .items_center()
- .justify_center()
- .text_size(px(14.))
- .text_color(rgb(c.muted))
- .hover(|s| s.bg(rgb(c.surface)).text_color(rgb(c.foreground)))
- .cursor_pointer()
- .child("−")
- .on_click(|_, window, _| window.minimize_window()),
- )
- .child(
- div()
- .id("maximize")
- .size(px(28.))
- .rounded_md()
- .flex()
- .items_center()
- .justify_center()
- .text_size(px(13.))
- .text_color(rgb(c.muted))
- .hover(|s| s.bg(rgb(c.surface)).text_color(rgb(c.foreground)))
- .cursor_pointer()
- .child("□")
- .on_click(|_, window, _| window.zoom_window()),
- )
- .child(
- div()
- .id("close-window")
- .size(px(28.))
- .rounded_md()
- .flex()
- .items_center()
- .justify_center()
- .text_size(px(17.))
- .text_color(rgb(c.muted))
- .hover(|s| s.bg(rgb(0x58333f)).text_color(rgb(0xf5a5b6)))
- .cursor_pointer()
- .child("×")
- .on_click(|_, window, _| window.remove_window()),
- ),
+ .when(!cfg!(target_os = "macos"), |header| {
+ header
+ .child(
+ div()
+ .id("minimize")
+ .size(px(28.))
+ .rounded_md()
+ .flex()
+ .items_center()
+ .justify_center()
+ .text_size(px(14.))
+ .text_color(rgb(c.muted))
+ .hover(|s| s.bg(rgb(c.surface)).text_color(rgb(c.foreground)))
+ .cursor_pointer()
+ .child("−")
+ .on_click(|_, window, _| window.minimize_window()),
+ )
+ .child(
+ div()
+ .id("maximize")
+ .size(px(28.))
+ .rounded_md()
+ .flex()
+ .items_center()
+ .justify_center()
+ .text_size(px(13.))
+ .text_color(rgb(c.muted))
+ .hover(|s| s.bg(rgb(c.surface)).text_color(rgb(c.foreground)))
+ .cursor_pointer()
+ .child("□")
+ .on_click(|_, window, _| window.zoom_window()),
+ )
+ .child(
+ div()
+ .id("close-window")
+ .size(px(28.))
+ .rounded_md()
+ .flex()
+ .items_center()
+ .justify_center()
+ .text_size(px(17.))
+ .text_color(rgb(c.muted))
+ .hover(|s| s.bg(rgb(0x58333f)).text_color(rgb(0xf5a5b6)))
+ .cursor_pointer()
+ .child("×")
+ .on_click(|_, window, _| window.remove_window()),
+ )
+ }),
)
.child(
div()