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
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand Down Expand Up @@ -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 {} +
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
33 changes: 33 additions & 0 deletions packaging/icon/build-icon-assets.sh
Original file line number Diff line number Diff line change
@@ -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"
24 changes: 22 additions & 2 deletions packaging/linux/build-linux.sh
Original file line number Diff line number Diff line change
@@ -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 <version> <publish-dir> <out-dir>
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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" <<CONTROL
Expand All @@ -126,7 +146,7 @@ Priority: optional
Maintainer: Thomas Müller <[email protected]>
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
Expand Down
14 changes: 13 additions & 1 deletion packaging/macos/build-dmg.sh
Original file line number Diff line number Diff line change
@@ -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 <version> <publish-dir> <arch> <out-dir>
set -euo pipefail
Expand All @@ -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" <<PLIST
Expand All @@ -33,6 +44,7 @@ cat > "$APP_DIR/Contents/Info.plist" <<PLIST
<key>CFBundleVersion</key> <string>$VERSION</string>
<key>CFBundleShortVersionString</key><string>$VERSION</string>
<key>CFBundleExecutable</key> <string>Freizeichen</string>
<key>CFBundleIconFile</key> <string>Freizeichen</string>
<key>CFBundlePackageType</key> <string>APPL</string>
<key>LSMinimumSystemVersion</key> <string>12.0</string>
<key>NSHighResolutionCapable</key> <true/>
Expand Down
10 changes: 8 additions & 2 deletions packaging/windows/Freizeichen.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
WiX v5 authoring for the Freizeichen MSI. Built by .github/workflows/release.yml with:
wix build packaging/windows/Freizeichen.wxs -arch x64 -d Version=<v> -d PublishDir=<dir> -o out.msi
wix build packaging/windows/Freizeichen.wxs -arch x64 -d Version=<v> -d PublishDir=<dir>
-d IconFile=<src/Freizeichen.App/Assets/icon.ico> -o out.msi

The UpgradeCode is fixed forever: it is what lets a new version replace the old one instead of
installing side by side.
Expand All @@ -19,6 +20,10 @@

<MediaTemplate EmbedCab="yes" />

<!-- The Start menu shortcut and the entry under Installed apps. -->
<Icon Id="FreizeichenIcon" SourceFile="$(IconFile)" />
<Property Id="ARPPRODUCTICON" Value="FreizeichenIcon" />

<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Freizeichen" />
</StandardDirectory>
Expand All @@ -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" />
<RegistryValue Root="HKCU" Key="Software\Freizeichen"
Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
Expand Down
Binary file added src/Freizeichen.App/Assets/icon-1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Freizeichen.App/Assets/icon.ico
Binary file not shown.
32 changes: 32 additions & 0 deletions src/Freizeichen.App/Assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/Freizeichen.App/Freizeichen.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<AssemblyName>Freizeichen</AssemblyName>
<RootNamespace>Freizeichen.App</RootNamespace>
<Product>Freizeichen</Product>
Expand All @@ -21,6 +22,8 @@
<ItemGroup>
<!-- Lagebuch's fonts (SIL OFL 1.1, see Assets/Fonts/README.md), referenced from Theme/Tokens.axaml. -->
<AvaloniaResource Include="Assets\Fonts\*.ttf" />
<!-- The windows' icon. The master is Assets/icon.svg; packaging/icon/build-icon-assets.sh renders the rest. -->
<AvaloniaResource Include="Assets\icon.ico" />
</ItemGroup>

<ItemGroup>
Expand All @@ -29,6 +32,9 @@
<None Include="..\..\LICENSE" Link="LICENSE.txt" CopyToPublishDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
<None Include="..\..\THIRD-PARTY-NOTICES.md" Link="THIRD-PARTY-NOTICES.md" CopyToPublishDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
<None Include="Assets\Fonts\OFL.txt" Link="OFL.txt" CopyToPublishDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
<!-- The icon the Linux desktop entries name: LinuxTelHandlerRegistration points at it beside the
executable, and build-linux.sh renders the .deb's icon theme from it. -->
<None Include="Assets\icon.svg" Link="freizeichen.svg" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions src/Freizeichen.App/Platform/LinuxTelHandlerRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/Freizeichen.App/Views/DialWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Width="420" SizeToContent="Height"
CanResize="False" Topmost="True"
WindowStartupLocation="CenterScreen"
Icon="/Assets/icon.ico"
Background="{StaticResource AppBackgroundBrush}">
<DockPanel>
<!-- Lagebuch's signal-red brand bar. -->
Expand Down
1 change: 1 addition & 0 deletions src/Freizeichen.App/Views/SettingsWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Title="Freizeichen"
Width="520" SizeToContent="Height"
WindowStartupLocation="CenterScreen"
Icon="/Assets/icon.ico"
Background="{StaticResource AppBackgroundBrush}">
<Window.Styles>
<Style Selector="TextBlock.overline">
Expand Down
29 changes: 29 additions & 0 deletions tests/Freizeichen.App.Tests/LinuxTelHandlerRegistrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,35 @@ public async Task Writes_a_desktop_entry_that_opens_tel_links_with_this_executab
Assert.Contains("MimeType=x-scheme-handler/tel;", entry);
}

// The tarball installs no icon theme, so the entry names the icon beside the executable.
[Fact]
public async Task Gives_the_entry_the_icon_beside_the_executable()
{
await Registration("/opt/freizeichen/Freizeichen").MakeDefaultAsync(TestContext.Current.CancellationToken);

var entry = await File.ReadAllLinesAsync(Path.Join(_applications, "freizeichen.desktop"), TestContext.Current.CancellationToken);
Assert.Contains("Icon=/opt/freizeichen/freizeichen.svg", entry);
}

[Fact]
public async Task Escapes_a_backslash_in_the_icon_path()
{
await Registration("/home/a\\b/Freizeichen").MakeDefaultAsync(TestContext.Current.CancellationToken);

var entry = await File.ReadAllLinesAsync(Path.Join(_applications, "freizeichen.desktop"), TestContext.Current.CancellationToken);
Assert.Contains("Icon=/home/a\\\\b/freizeichen.svg", entry);
}

// The window's WM_CLASS is the assembly name; without the match the dock shows a generic icon.
[Fact]
public async Task Ties_the_window_to_the_entry_by_its_window_class()
{
await Registration().MakeDefaultAsync(TestContext.Current.CancellationToken);

var entry = await File.ReadAllLinesAsync(Path.Join(_applications, "freizeichen.desktop"), TestContext.Current.CancellationToken);
Assert.Contains("StartupWMClass=Freizeichen", entry);
}

// xdg-mime (xdg-utils 1.2) takes the first word of Exec literally, quotes included, and drops a
// default whose program it cannot find: a quoted plain path made "Prüfen" report another
// handler although the default was set.
Expand Down
Loading