From 584574fb665b9f430b68c81a16a582b5bcd3af89 Mon Sep 17 00:00:00 2001 From: o2sh Date: Sun, 27 Nov 2022 18:42:55 +0100 Subject: [PATCH] add icon to exe #873 --- .github/workflows/windows-installer.iss | 3 ++- Cargo.lock | 10 ++++++++++ Cargo.toml | 3 +++ build.rs | 6 ++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-installer.iss b/.github/workflows/windows-installer.iss index fd2985da3..b479b8356 100644 --- a/.github/workflows/windows-installer.iss +++ b/.github/workflows/windows-installer.iss @@ -25,7 +25,8 @@ DisableProgramGroupPage=yes ;PrivilegesRequired=lowest OutputDir=..\.. OutputBaseFilename=onefetch-setup -SetupIconFile=..\..\assets\onefetch.ico +SetupIconFile=..\..\assets\onefetch.ico +UninstallDisplayIcon={app}\{#MyAppExeName} Compression=lzma SolidCompression=yes WizardStyle=modern diff --git a/Cargo.lock b/Cargo.lock index 7965637a4..3e310c54b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2057,6 +2057,7 @@ dependencies = [ "time", "time-humanize", "tokei", + "winres", "yaml-rust", ] @@ -3300,6 +3301,15 @@ version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0c9c6df55dd1bfa76e131cef44bdd8ec9c819ef3611f04dfe453fd5bfeda28" +[[package]] +name = "winres" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" +dependencies = [ + "toml", +] + [[package]] name = "xz2" version = "0.1.7" diff --git a/Cargo.toml b/Cargo.toml index 13ddb15fb..6a38a3616 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,9 @@ serde_json = "1" serde_yaml = "0.9" tera = { version = "1", default-features = false } +[target.'cfg(windows)'.build-dependencies] +winres = "0.1" + [target.'cfg(windows)'.dependencies] enable-ansi-support = "0.1.2" diff --git a/build.rs b/build.rs index b869abcf2..c7f19188b 100644 --- a/build.rs +++ b/build.rs @@ -8,6 +8,12 @@ use std::path::Path; use tera::{Context, Tera}; fn main() -> Result<(), Box> { + #[cfg(windows)] + { + let mut res = winres::WindowsResource::new(); + res.set_icon("assets/onefetch.ico"); + res.compile()?; + } let out_dir = env::var("OUT_DIR").expect("No OUT_DIR variable."); let mut tera = Tera::default(); tera.register_filter("strip_color_tokens", strip_color_tokens_filter);