From 34d0a96298f35204f04927d3a92137ae31255d10 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 9 Jun 2024 22:09:00 -0600 Subject: [PATCH] add an app icon --- .gitignore | 2 +- CHANGELOG.md | 2 ++ Cargo.toml | 2 +- README.md | 18 ++++++++++++- build.rs | 13 ++++++--- publish.ps1 | 37 ++++++++++++++++++++++++++ publish.sh | 2 +- resources/min-ed-launcher.desktop | 9 +++++++ resources/min-ed-launcher.svg | 24 +++++++++++++++++ src/MinEdLauncher/MinEdLauncher.fsproj | 5 ++++ 10 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 resources/min-ed-launcher.desktop create mode 100644 resources/min-ed-launcher.svg diff --git a/.gitignore b/.gitignore index ac3048c..f6c23fa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ lib/* !lib/libsteam_api.so release-notes.md benchmarks/MinEdLauncher.Benchmarks/BenchmarkDotNet.Artifacts/ - +*.ico ## rust target/ diff --git a/CHANGELOG.md b/CHANGELOG.md index ccf85c8..243335f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ - Enable restart feature for Epic users. It's still not as seamless as non-Epic accounts. Requires the usage of [Legendary] or [Heroic]. Once you've logged in with either, you can go back to using the normal Epic launcher if you wish. It will require re-logging in every few days though, so it may be preferable to just stick with the alternate launchers. +- Added an [icon](resources/min-ed-launcher.svg) for the app. Linux users can check the [readme](README.md#icon-on-linux) + for setup instructions. ## [0.10.1] - 2024-05-03 diff --git a/Cargo.toml b/Cargo.toml index e6f993f..cc917aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ path = "src/bootstrapper-rs/main.rs" windows = { version = "0.42", features = [ "Win32_UI_Shell", "Win32_Foundation", "Win32_UI_WindowsAndMessaging" ] } [build-dependencies] -winres = "0.1" +winresource = "0.1.17" [package.metadata.winres] ProductName = "MinEdLauncher.Bootstrap" diff --git a/README.md b/README.md index 5f23b23..e1f255d 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ accounts on both Windows and Linux. * [Multi-Account] * [Frontier account via Steam or Epic] * [Epic account via Steam] + * [Icon on Linux] * [Troubleshooting] * [Cache] * [Build] @@ -92,7 +93,7 @@ Frontier's website. Linking is only required if you purchased the game via Steam `gnome-terminal -- ./MinEdLauncher %command% /autorun /autoquit /edo` - `konsole -e ./MinEdLauncher %command% /autorun /autoquit /edo` + `konsole --name min-ed-launcher -e ./MinEdLauncher %command% /autorun /autoquit /edo` 5. Launch your game as you normally would in Steam #### Epic 1. Download the [latest release] for your operating system @@ -310,6 +311,20 @@ Example _Target_ field for a shortcut that launches Odyssey: `"C:\Program Files (x86)\Steam\Steam.exe" -gameidlaunch 359320 /edo` +### Icon on Linux +1. Copy the included `min-ed-launcher.svg` file to your environment's default icon location + + Common icon locations are `~/.local/share/icons/hicolor/scalable/apps` and `/usr/share/icons/scalable/apps`. +2. Copy the included `min-ed-launcher.desktop` file to your environment's default application launcher location + + Common locations are `~/.local/share/applications` and `/usr/share/applications` + + You may need to update your cache by running `update-desktop-database` pointed at whereever you copied the + desktop file. e.g. `update-desktop-database ~/.local/share/applications/` +3. Set the WM_CLASS/Application Id property in your launch options. How you do this will depend on your terminal + emulator. Examples are below: + * Alacritty - `alacritty --class min-ed-launcher -e ./MinEdLauncher %command% /autorun /autoquit /edo` + * kitty - `kitty --class min-ed-launcher ./MinEdLauncher %command% /autorun /autoquit /edo` ### Troubleshooting Debug logging is placed in the standard log location for your operating system: @@ -386,6 +401,7 @@ Note that the bootstrap project specifically targets Windows and won't publish o [Multi-Account]: #multi-account [Frontier account via Steam or Epic]: #frontier-account-via-steam-or-epic [Epic account via Steam]: #epic-account-via-steam +[Icon on Linux]: #icon-on-linux [Troubleshooting]: #troubleshooting [Cache]: #cache [Build]: #build diff --git a/build.rs b/build.rs index 21e085c..8f1fb85 100644 --- a/build.rs +++ b/build.rs @@ -1,8 +1,13 @@ -extern crate winres; +use std::path::Path; +use winresource::WindowsResource; fn main() { - if cfg!(target_os = "windows") { - let res = winres::WindowsResource::new(); - res.compile().unwrap(); + let icon_path = "resources/min-ed-launcher.ico"; + + if Path::new(icon_path).is_file() { + let mut res = WindowsResource::new(); + + res.set_icon(icon_path); + res.compile().expect("failed to build executable icon"); } } diff --git a/publish.ps1 b/publish.ps1 index 7b65b97..3902a58 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -1,4 +1,39 @@ $ErrorActionPreference = "Stop" +Set-PSDebug -Strict +function Create-Icon { + echo "Converting SVG icon to ICO" + # https://imagemagick.org/script/download.php + $imageMagick = "magick.exe" + + if ((Get-Command $imageMagick -ErrorAction SilentlyContinue) -eq $null) + { + echo "Couldn't find ImageMagick '${imageMagick}'. Skipping icon creation" + return + } + + $iconName = "min-ed-launcher" + $svg = "resources/${iconName}.svg" + $ico = "resources/${iconName}.ico" + $resolutions = 16,20,24,32,40,48,64,256 + + $pngImages = @() + Foreach($r in $resolutions) { + $png = "resources/${r}.png" + $dim = "${r}x${r}" + + & $imageMagick -background none $svg -density $dim -resize $dim -gravity center -extent $dim $png + + $pngImages += $png + } + + # Combine all PNG image files into an ico file + & $imageMagick $pngImages $ico + + # Remove PNG files + Foreach($image in $pngImages) { + #Remove-Item $image + } +} $target="win-x64" [xml]$proj = Get-Content src\Directory.Build.props @@ -6,6 +41,8 @@ $version=$proj.Project.PropertyGroup.VersionPrefix $release_name="min-ed-launcher_v${version}_$target" $target_dir="artifacts\$release_name" +Create-Icon + dotnet publish -r "$target" --self-contained -o "$target_dir" -c ReleaseWindows -p:PublishSingleFile=true src\MinEdLauncher\MinEdLauncher.fsproj $full_version=(Get-Item "$target_dir\MinEdLauncher.exe").VersionInfo.ProductVersion (Get-Content Cargo.toml).replace('0.0.0', "$full_version") | Set-Content Cargo.toml # Workaround for https://github.com/rust-lang/cargo/issues/6583 diff --git a/publish.sh b/publish.sh index dfaf2b7..108d781 100755 --- a/publish.sh +++ b/publish.sh @@ -6,7 +6,7 @@ release_name="min-ed-launcher_v${version}_$target" dotnet restore -r $target dotnet publish src/MinEdLauncher/MinEdLauncher.fsproj -r "$target" --self-contained true --no-restore -o "artifacts/$release_name" -c Release -p:PublishSingleFile=true -cp README.md CHANGELOG.md "artifacts/$release_name" +cp README.md CHANGELOG.md resources/min-ed-launcher.svg resources/min-ed-launcher.desktop "artifacts/$release_name" rm artifacts/"$release_name"/*.pdb tar czvf "artifacts/$release_name.tar.gz" -C "artifacts" "$release_name" diff --git a/resources/min-ed-launcher.desktop b/resources/min-ed-launcher.desktop new file mode 100644 index 0000000..64a14f0 --- /dev/null +++ b/resources/min-ed-launcher.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Minimal ED Launcher +Comment=Launches the game Elite: Dangerous +Exec=MinEdLauncher %F +Terminal=true +Type=Application +Keywords=elite;ed;launcher; +Icon=min-ed-launcher +Categories=Game; diff --git a/resources/min-ed-launcher.svg b/resources/min-ed-launcher.svg new file mode 100644 index 0000000..94551bf --- /dev/null +++ b/resources/min-ed-launcher.svg @@ -0,0 +1,24 @@ + + + + + diff --git a/src/MinEdLauncher/MinEdLauncher.fsproj b/src/MinEdLauncher/MinEdLauncher.fsproj index 0e4524b..9f0d0ed 100644 --- a/src/MinEdLauncher/MinEdLauncher.fsproj +++ b/src/MinEdLauncher/MinEdLauncher.fsproj @@ -38,6 +38,11 @@ !$(DefineConstants.Contains('WINDOWS')) + $(DefineConstants.Contains('WINDOWS')) + + + + ..\..\resources\min-ed-launcher.ico