diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b981d9..b248ce4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -96,6 +96,7 @@ jobs: wix build packaging/windows/Freizeichen.wxs -arch x64 -d "Version=$env:MSI_VERSION" -d "PublishDir=$env:GITHUB_WORKSPACE\publish" + -d "IconFile=$env:GITHUB_WORKSPACE\src\Freizeichen.App\Assets\icon.ico" -o "freizeichen-$env:VERSION-windows-x64.msi" - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 @@ -168,6 +169,12 @@ jobs: dotnet publish src/Freizeichen.App/Freizeichen.App.csproj -r linux-x64 ${{ env.PUBLISH_FLAGS }} "-p:Version=${VERSION}" -o publish + # build-linux.sh renders the icon theme's sizes with rsvg-convert, which the runner lacks. + - name: Install packaging tools + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends librsvg2-bin + - name: Build .deb and .tar.gz env: VERSION: ${{ needs.version.outputs.version }} @@ -183,6 +190,8 @@ jobs: test -x /usr/bin/freizeichen desktop-file-validate /usr/share/applications/freizeichen.desktop appstreamcli validate --no-net /usr/share/metainfo/de.codeforfire.freizeichen.metainfo.xml + test -f /usr/share/icons/hicolor/48x48/apps/freizeichen.png + test -f /usr/share/icons/hicolor/scalable/apps/freizeichen.svg tar -tzf "dist/freizeichen-${VERSION}-linux-x64.tar.gz" | grep -qx "freizeichen-${VERSION}/Freizeichen" - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 diff --git a/Makefile b/Makefile index ef8de46..8a48987 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ APP := src/Freizeichen.App/Freizeichen.App.csproj SCENARIO ?= ok PHONE_PORT ?= /dev/rfcomm9 -.PHONY: help restore build test ci format format-check run fake-phone screenshots clean +.PHONY: help restore build test ci format format-check run fake-phone screenshots icon clean help: ## Show this help @grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-14s %s\n", $$1, $$2}' @@ -38,5 +38,8 @@ screenshots: ## Regenerate docs/screenshots/*.png for the README (ReadmeScreensh RENDER_OUT=$(CURDIR)/docs/screenshots dotnet test tests/Freizeichen.App.Tests -c Release \ --filter "FullyQualifiedName~ReadmeScreenshotTests" +icon: ## Re-render the committed icon derivatives from src/Freizeichen.App/Assets/icon.svg + packaging/icon/build-icon-assets.sh + clean: ## Remove build output find src tests -type d \( -name bin -o -name obj \) -prune -exec rm -rf {} + diff --git a/README.md b/README.md index a154b3d..240d854 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ make run # settings window make run ARGS=tel:0891234567 # dial window make fake-phone # a fake DL500A on /dev/rfcomm9 (Linux, needs sudo) make screenshots # regenerate docs/screenshots/ for this README +make icon # re-render the app icon from src/Freizeichen.App/Assets/icon.svg make help # everything else ``` diff --git a/packaging/icon/build-icon-assets.sh b/packaging/icon/build-icon-assets.sh new file mode 100755 index 0000000..80460a6 --- /dev/null +++ b/packaging/icon/build-icon-assets.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Regenerate the icon derivatives from the master, src/Freizeichen.App/Assets/icon.svg. Run it +# after changing the master and commit the outputs; never hand-edit them. +# +# packaging/icon/build-icon-assets.sh (or: make icon) +# +# Needs rsvg-convert (librsvg2-bin) and ImageMagick 7 (magick). ImageMagick's own SVG renderer +# drops the gradients, so it only assembles the .ico from rsvg-convert's renders. +# +# The outputs are committed rather than built in CI because the macOS and Windows runners have no +# SVG renderer: build-dmg.sh makes the .icns from icon-1024.png with sips, and the exe, the MSI +# and both windows take icon.ico. build-linux.sh renders the hicolor sizes from icon-1024.png. +set -euo pipefail + +ASSETS="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/src/Freizeichen.App/Assets" +SVG="$ASSETS/icon.svg" + +command -v rsvg-convert >/dev/null || { echo "error: rsvg-convert not found (apt install librsvg2-bin)" >&2; exit 1; } +command -v magick >/dev/null || { echo "error: ImageMagick 7 (magick) not found" >&2; exit 1; } + +STAGE="$(mktemp -d)" +trap 'rm -rf "$STAGE"' EXIT + +rsvg-convert -w 1024 -h 1024 "$SVG" -o "$ASSETS/icon-1024.png" + +# Each .ico frame is rendered from the vector at its own size, not downscaled from the 1024 +# render: at 16-32 px, the sizes Explorer and the title bar show, a downscale blurs the handset. +frames=() +for size in 16 20 24 32 40 48 64 128 256; do + rsvg-convert -w "$size" -h "$size" "$SVG" -o "$STAGE/$size.png" + frames+=("$STAGE/$size.png") +done +magick "${frames[@]}" "$ASSETS/icon.ico" diff --git a/packaging/linux/build-linux.sh b/packaging/linux/build-linux.sh index 4e001df..c5281fd 100755 --- a/packaging/linux/build-linux.sh +++ b/packaging/linux/build-linux.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash # Package a linux-x64 publish output as a .tar.gz for any distribution and a .deb for -# Debian/Ubuntu. Needs dpkg-deb. Runs on the ubuntu-latest CI runner. +# Debian/Ubuntu. Needs dpkg-deb and rsvg-convert (librsvg2-bin). Runs on the ubuntu-latest CI +# runner. # # build-linux.sh set -euo pipefail +command -v rsvg-convert >/dev/null || { echo "error: rsvg-convert not found (apt install librsvg2-bin)" >&2; exit 1; } + VERSION="$1" PUBLISH_DIR="$2" OUT_DIR="$3" @@ -34,13 +37,28 @@ install -d "$ROOT/DEBIAN" "$ROOT/usr/lib/freizeichen" "$ROOT/usr/bin" \ cp -R "$PUBLISH_DIR"/. "$ROOT/usr/lib/freizeichen/" ln -s ../lib/freizeichen/Freizeichen "$ROOT/usr/bin/freizeichen" +# The icon under the name Icon= looks up, one file per size hicolor's index.theme declares (it +# stops at 512), each rendered from the vector so the handset stays sharp at panel sizes. The +# scalable copy serves every size the theme does not declare. The publish output carries the +# master as freizeichen.svg (Freizeichen.App.csproj). +ICON_SVG="$PUBLISH_DIR/freizeichen.svg" +for size in 16 22 24 32 48 64 96 128 256 512; do + install -d "$ROOT/usr/share/icons/hicolor/${size}x${size}/apps" + rsvg-convert -w "$size" -h "$size" "$ICON_SVG" -o "$ROOT/usr/share/icons/hicolor/${size}x${size}/apps/freizeichen.png" +done +install -Dm644 "$ICON_SVG" "$ROOT/usr/share/icons/hicolor/scalable/apps/freizeichen.svg" + +# StartupWMClass is the window's WM_CLASS, which Avalonia takes from the assembly name: it is what +# ties the running window to this entry, and so to its icon, in the dock and the task switcher. cat > "$ROOT/usr/share/applications/freizeichen.desktop" <<'DESKTOP' [Desktop Entry] Type=Application Name=Freizeichen Comment=Wählt tel:-Links über ein Gigaset DL500A per Bluetooth Exec=/usr/bin/freizeichen %u +Icon=freizeichen Terminal=false +StartupWMClass=Freizeichen Categories=Network;Telephony; MimeType=x-scheme-handler/tel; DESKTOP @@ -115,6 +133,8 @@ COPYRIGHT # Debian sorts "~" before everything, so a prerelease 0.2.0-rc.1 becomes 0.2.0~rc.1 and installs # below the final 0.2.0. A self-contained .NET app still needs the system's ICU, whose package # name carries its version; the alternatives cover Debian 12/13 and Ubuntu 24.04 onwards. +# hicolor-icon-theme owns hicolor's index.theme, without which Icon=freizeichen finds nothing; a +# GTK app gets it transitively, Avalonia links no GTK. Its dpkg trigger refreshes the icon cache. DEB_VERSION="${VERSION//-/\~}" INSTALLED_KB=$(du -sk "$ROOT/usr" | cut -f1) cat > "$ROOT/DEBIAN/control" < Homepage: https://github.com/CodeForFire/freizeichen Installed-Size: ${INSTALLED_KB} -Depends: libc6, libstdc++6, libgcc-s1, zlib1g, libfontconfig1, libx11-6, libice6, libsm6, xdg-utils, libicu72 | libicu74 | libicu76 | libicu77 | libicu78 +Depends: libc6, libstdc++6, libgcc-s1, zlib1g, libfontconfig1, libx11-6, libice6, libsm6, xdg-utils, hicolor-icon-theme, libicu72 | libicu74 | libicu76 | libicu77 | libicu78 Recommends: bluez Description: Dial tel: links on a Gigaset DL500A over Bluetooth Freizeichen registers as the tel: handler and dials the number on a Gigaset diff --git a/packaging/macos/build-dmg.sh b/packaging/macos/build-dmg.sh index d3a3dc0..f5decca 100755 --- a/packaging/macos/build-dmg.sh +++ b/packaging/macos/build-dmg.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Build an unsigned Freizeichen.app and wrap it in a drag-to-Applications .dmg. macOS-only -# (hdiutil, codesign). Runs on the macos-latest CI runner. +# (sips, iconutil, hdiutil, codesign). Runs on the macos-latest CI runner. # # build-dmg.sh set -euo pipefail @@ -20,6 +20,17 @@ install -d "$APP_DIR/Contents/MacOS" "$APP_DIR/Contents/Resources" cp -R "$PUBLISH_DIR"/. "$APP_DIR/Contents/MacOS/" chmod +x "$APP_DIR/Contents/MacOS/Freizeichen" +# The Finder and Dock icon. sips cannot read the SVG master, so the .icns comes from its committed +# 1024 render (packaging/icon/build-icon-assets.sh). +ICON_PNG="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/src/Freizeichen.App/Assets/icon-1024.png" +ICONSET="$STAGE/Freizeichen.iconset" +mkdir -p "$ICONSET" +for s in 16 32 128 256 512; do + sips -z "$s" "$s" "$ICON_PNG" --out "$ICONSET/icon_${s}x${s}.png" >/dev/null + sips -z $((s * 2)) $((s * 2)) "$ICON_PNG" --out "$ICONSET/icon_${s}x${s}@2x.png" >/dev/null +done +iconutil -c icns "$ICONSET" -o "$APP_DIR/Contents/Resources/Freizeichen.icns" + # CFBundleURLTypes is what lets Launch Services hand tel: links to the app; it delivers them as an # Apple event, not an argument. The bundle id must match MacTelHandlerRegistration.BundleId. cat > "$APP_DIR/Contents/Info.plist" < "$APP_DIR/Contents/Info.plist" <CFBundleVersion $VERSION CFBundleShortVersionString$VERSION CFBundleExecutable Freizeichen + CFBundleIconFile Freizeichen CFBundlePackageType APPL LSMinimumSystemVersion 12.0 NSHighResolutionCapable diff --git a/packaging/windows/Freizeichen.wxs b/packaging/windows/Freizeichen.wxs index ca228e2..fa8ec3f 100644 --- a/packaging/windows/Freizeichen.wxs +++ b/packaging/windows/Freizeichen.wxs @@ -1,7 +1,8 @@ + + + @@ -37,7 +42,8 @@ Name="Freizeichen" Description="tel:-Links über ein Gigaset-Telefon wählen" Target="[INSTALLFOLDER]Freizeichen.exe" - WorkingDirectory="INSTALLFOLDER" /> + WorkingDirectory="INSTALLFOLDER" + Icon="FreizeichenIcon" /> diff --git a/src/Freizeichen.App/Assets/icon-1024.png b/src/Freizeichen.App/Assets/icon-1024.png new file mode 100644 index 0000000..4ea5c5c Binary files /dev/null and b/src/Freizeichen.App/Assets/icon-1024.png differ diff --git a/src/Freizeichen.App/Assets/icon.ico b/src/Freizeichen.App/Assets/icon.ico new file mode 100644 index 0000000..94bf924 Binary files /dev/null and b/src/Freizeichen.App/Assets/icon.ico differ diff --git a/src/Freizeichen.App/Assets/icon.svg b/src/Freizeichen.App/Assets/icon.svg new file mode 100644 index 0000000..dda13a1 --- /dev/null +++ b/src/Freizeichen.App/Assets/icon.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Freizeichen.App/Freizeichen.App.csproj b/src/Freizeichen.App/Freizeichen.App.csproj index 157f1c3..37fa21b 100644 --- a/src/Freizeichen.App/Freizeichen.App.csproj +++ b/src/Freizeichen.App/Freizeichen.App.csproj @@ -3,6 +3,7 @@ WinExe app.manifest + Assets\icon.ico Freizeichen Freizeichen.App Freizeichen @@ -21,6 +22,8 @@ + + @@ -29,6 +32,9 @@ + + diff --git a/src/Freizeichen.App/Platform/LinuxTelHandlerRegistration.cs b/src/Freizeichen.App/Platform/LinuxTelHandlerRegistration.cs index c9ed84d..6aef065 100644 --- a/src/Freizeichen.App/Platform/LinuxTelHandlerRegistration.cs +++ b/src/Freizeichen.App/Platform/LinuxTelHandlerRegistration.cs @@ -17,6 +17,9 @@ internal sealed class LinuxTelHandlerRegistration : ITelHandlerRegistration { internal const string EntryName = "freizeichen.desktop"; + // Published beside the executable (Freizeichen.App.csproj): the tarball installs no icon theme. + private const string IconFileName = "freizeichen.svg"; + private const string MimeType = "x-scheme-handler/tel"; private static readonly TimeSpan XdgMimeTimeout = TimeSpan.FromSeconds(5); @@ -68,11 +71,20 @@ private static string DesktopEntry(string executablePath) => .Append("Name=Freizeichen\n") .Append("Comment=Wählt tel:-Links über ein Gigaset DL500A per Bluetooth\n") .Append("Exec=").Append(QuoteExecArgument(executablePath)).Append(" %u\n") + .Append("Icon=").Append(IconPath(executablePath)).Append('\n') .Append("Terminal=false\n") + .Append("StartupWMClass=Freizeichen\n") .Append("Categories=Network;Telephony;\n") .Append("MimeType=").Append(MimeType).Append(";\n") .ToString(); + // Split on '/' rather than with Path: the entry holds a Linux path, and on Windows (where the + // tests also run) Path would turn the slashes into backslashes and split on a backslash too. + // Icon is a plain string value, whose only escape a path can need is a doubled backslash; a + // line break never gets here. + private static string IconPath(string executablePath) => + (executablePath[..(executablePath.LastIndexOf('/') + 1)] + IconFileName).Replace(@"\", @"\\", StringComparison.Ordinal); + // A path without the Desktop Entry spec's reserved characters is written bare: xdg-mime // (xdg-utils 1.2) reads the first word of Exec literally, quotes included, and ignores a default // whose program it cannot find. Any other path is quoted as the spec requires: double quotes, diff --git a/src/Freizeichen.App/Views/DialWindow.axaml b/src/Freizeichen.App/Views/DialWindow.axaml index 7bcfb90..23a10d3 100644 --- a/src/Freizeichen.App/Views/DialWindow.axaml +++ b/src/Freizeichen.App/Views/DialWindow.axaml @@ -8,6 +8,7 @@ Width="420" SizeToContent="Height" CanResize="False" Topmost="True" WindowStartupLocation="CenterScreen" + Icon="/Assets/icon.ico" Background="{StaticResource AppBackgroundBrush}"> diff --git a/src/Freizeichen.App/Views/SettingsWindow.axaml b/src/Freizeichen.App/Views/SettingsWindow.axaml index 2b6d24e..fa68fdd 100644 --- a/src/Freizeichen.App/Views/SettingsWindow.axaml +++ b/src/Freizeichen.App/Views/SettingsWindow.axaml @@ -7,6 +7,7 @@ Title="Freizeichen" Width="520" SizeToContent="Height" WindowStartupLocation="CenterScreen" + Icon="/Assets/icon.ico" Background="{StaticResource AppBackgroundBrush}">