Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ jobs:
- if: ${{ startsWith(matrix.os, 'ubuntu-') }}
run: sudo apt-get update && sudo apt-get install -y gcc libxcb-composite0-dev libgtk-3-dev
- run: cargo build --release
- if: ${{ matrix.tar }}
- if: ${{ matrix.artifact-name == 'mac' }}
run: bash tests/package-macos-app.sh
- if: ${{ matrix.artifact-name == 'mac' }}
run: >
scripts/package-macos-app.sh
target/release/${{ matrix.artifact-file }}
${{ env.LUDUSAVI_VERSION }}
target/release/ludusavi-v${{ env.LUDUSAVI_VERSION }}-${{ matrix.artifact-name }}
target/release/ludusavi-v${{ env.LUDUSAVI_VERSION }}-${{ matrix.artifact-name }}.tar.gz
- if: ${{ matrix.tar && matrix.artifact-name != 'mac' }}
run: |
cd target/release
tar --create --gzip --file=ludusavi-v${{ env.LUDUSAVI_VERSION }}-${{ matrix.artifact-name }}.tar.gz ${{ matrix.artifact-file }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Unreleased

* Added:
* The Mac download now includes `Ludusavi.app` for standard application launching,
alongside a `ludusavi` command-line link.
* Ludusavi can now translate native Windows paths into Wine prefixes and vice versa.
During a scan, these will appear like any other redirected path.
This is supported for Wine specifically, not any other native Linux paths.
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ These are optional:
The master icon is `assets/icon.kra`, which you can edit using
[Krita](https://krita.org/en) and then export into the other formats.

To regenerate the Mac icon, first install `rsvg-convert` (from librsvg) and Pillow,
then run:
```bash
python3 -m pip install pillow
python3 scripts/generate-macos-icon.py assets/icon.svg assets/icon.icns
```

This renders the SVG at 1024 pixels, adds the padding used by the Mac Dock,
and writes all ICNS resolutions.

### Release preparation
Commands assume you are using [Git Bash](https://git-scm.com) on Windows.

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ If you'd like to help translate Ludusavi into other languages,
Download the executable for Windows, Linux, or Mac from the
[releases page](https://github.com/mtkennerly/ludusavi/releases).
It's portable, so you can simply download it and put it anywhere on your system.
On Mac, extract the archive and open `Ludusavi.app` like any other application.
The included `ludusavi` link can still be used from the terminal.

If you prefer, Ludusavi is also available via
[Winget, Scoop, Flatpak, and Cargo](docs/help/installation.md).
Expand Down
Binary file added assets/icon.icns

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, how was this icns file generated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! I generated it from Ludusavi’s existing assets/icon.svg: rendered it to a 1024×1024 PNG with rsvg-convert, placed it on a transparent 1024×1024 canvas at 820×820 to give it more standard Dock padding (as it looked very big otherwise, compared to the other icons on the dock), then used Pillow to write the .icns sizes from 16 through 1024 pixels. I can add a small reproducible generation script or document the exact command rather than keeping the binary asset as a hand-generated export.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a reproducible script would be great if it's not too much hassle 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

Binary file not shown.
2 changes: 2 additions & 0 deletions docs/help/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ You can install Ludusavi one of these ways:
* Download the executable for your operating system from the
[releases page](https://github.com/mtkennerly/ludusavi/releases).
It's portable, so you can simply download it and put it anywhere on your system.
On Mac, extract the archive and open `Ludusavi.app` like any other application.
The included `ludusavi` link can still be used from the terminal.
**If you're unsure, choose this option.**

* On Windows, you can use [Winget](https://github.com/microsoft/winget-cli).
Expand Down
60 changes: 60 additions & 0 deletions scripts/generate-macos-icon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
"""Generate a padded macOS ICNS file from Ludusavi's SVG icon."""

import argparse
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path


CANVAS_SIZE = 1024
ART_SIZE = 820
ICON_SIZES = [(16, 16), (32, 32), (64, 64), (128, 128), (256, 256), (512, 512), (1024, 1024)]


def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("input", type=Path, help="source SVG file")
parser.add_argument("output", type=Path, help="output ICNS file")
return parser.parse_args()


def main() -> None:
args = parse_args()

if shutil.which("rsvg-convert") is None:
sys.exit("rsvg-convert is required; install librsvg before generating the macOS icon")

try:
from PIL import Image
except ImportError:
sys.exit("Pillow is required; install it with: python3 -m pip install pillow")

args.output.parent.mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory() as temp_dir:
raster = Path(temp_dir) / "icon.png"
subprocess.run(
[
"rsvg-convert",
"--width",
str(CANVAS_SIZE),
"--height",
str(CANVAS_SIZE),
str(args.input),
"--output",
str(raster),
],
check=True,
)

art = Image.open(raster).convert("RGBA")
art.thumbnail((ART_SIZE, ART_SIZE), Image.Resampling.LANCZOS)
canvas = Image.new("RGBA", (CANVAS_SIZE, CANVAS_SIZE), (0, 0, 0, 0))
canvas.alpha_composite(art, ((CANVAS_SIZE - art.width) // 2, (CANVAS_SIZE - art.height) // 2))
canvas.save(args.output, format="ICNS", sizes=ICON_SIZES)


if __name__ == "__main__":
main()
56 changes: 56 additions & 0 deletions scripts/package-macos-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
set -euo pipefail

if [ "$#" -ne 4 ]; then
echo "Usage: $0 <binary> <version> <staging-dir> <archive>" >&2
exit 64
fi

binary=$1
version=$2
staging_dir=$3
archive=$4
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
app="$staging_dir/Ludusavi.app"

test -x "$binary"
test -f "$repo_root/assets/icon.icns"

rm -rf "$staging_dir"
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
cp "$binary" "$app/Contents/MacOS/Ludusavi"
cp "$repo_root/assets/icon.icns" "$app/Contents/Resources/Ludusavi.icns"
ln -s "Ludusavi.app/Contents/MacOS/Ludusavi" "$staging_dir/ludusavi"

cat > "$app/Contents/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Ludusavi</string>
<key>CFBundleExecutable</key>
<string>Ludusavi</string>
<key>CFBundleIconFile</key>
<string>Ludusavi.icns</string>
<key>CFBundleIdentifier</key>
<string>com.mtkennerly.ludusavi</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Ludusavi</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${version}</string>
<key>CFBundleVersion</key>
<string>${version}</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
PLIST

tar --create --gzip --file="$archive" --directory="$staging_dir" Ludusavi.app ludusavi
17 changes: 17 additions & 0 deletions tests/generate-macos-icon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail

repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
temp_dir=$(mktemp -d)
trap 'rm -rf "$temp_dir"' EXIT

output="$temp_dir/icon.icns"

python3 "$repo_root/scripts/generate-macos-icon.py" "$repo_root/assets/icon.svg" "$output"

test -f "$output"
/usr/bin/file "$output" | /usr/bin/grep -F 'Mac OS X icon'

iconset="$temp_dir/icon.iconset"
/usr/bin/iconutil -c iconset -o "$iconset" "$output"
test -f "$iconset/icon_512x512@2x.png"
34 changes: 34 additions & 0 deletions tests/package-macos-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
temp_dir=$(mktemp -d)
trap 'rm -rf "$temp_dir"' EXIT

fixture_binary="$temp_dir/ludusavi"
printf '#!/usr/bin/env bash\nprintf "fixture\\n"\n' > "$fixture_binary"
chmod +x "$fixture_binary"

staging_dir="$temp_dir/staging"
archive="$temp_dir/ludusavi-v1.2.3-mac.tar.gz"

"$repo_root/scripts/package-macos-app.sh" "$fixture_binary" 1.2.3 "$staging_dir" "$archive"

app="$staging_dir/Ludusavi.app"
plist="$app/Contents/Info.plist"

test -x "$app/Contents/MacOS/Ludusavi"
test -f "$app/Contents/Resources/Ludusavi.icns"
test -L "$staging_dir/ludusavi"
test "$(readlink "$staging_dir/ludusavi")" = "Ludusavi.app/Contents/MacOS/Ludusavi"
test "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$plist")" = "Ludusavi"
test "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$plist")" = "com.mtkennerly.ludusavi"
test "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$plist")" = "1.2.3"
test "$(tar --list --gzip --file="$archive" | /usr/bin/grep -x 'Ludusavi.app/Contents/MacOS/Ludusavi')" = "Ludusavi.app/Contents/MacOS/Ludusavi"
test "$(tar --list --gzip --file="$archive" | /usr/bin/grep -x 'ludusavi')" = "ludusavi"

extracted_dir="$temp_dir/extracted"
mkdir "$extracted_dir"
tar --extract --gzip --file="$archive" --directory="$extracted_dir"
test -L "$extracted_dir/ludusavi"
test "$(readlink "$extracted_dir/ludusavi")" = "Ludusavi.app/Contents/MacOS/Ludusavi"