Add icon to modulo stub app

This commit is contained in:
Federico Terzi 2020-09-16 20:00:04 +02:00
parent 8f8d5f2f1c
commit d43f7ae205
3 changed files with 11 additions and 1 deletions

BIN
src/res/mac/AppIcon.icns Normal file

Binary file not shown.

View File

@ -7,7 +7,9 @@
<key>CFBundleExecutable</key>
<string>{{{modulo_path}}}</string>
<key>CFBundleIconFile</key>
<string></string>
<string>AppIcon</string>
<key>CFBundleIconName</key>
<string>AppIcon</string>>
<key>CFBundleIdentifier</key>
<string>com.federicoterzi.modulo</string>
<key>CFBundleInfoDictionaryVersion</key>

View File

@ -4,6 +4,7 @@ use std::os::unix::fs::symlink;
const MODULO_APP_BUNDLE_NAME: &str = "Modulo.app";
const MODULO_APP_BUNDLE_PLIST_CONTENT: &'static str = include_str!("../../res/mac/modulo.plist");
const MODULO_APP_BUNDLE_ICON: &'static str = include_str!("../../res/mac/AppIcon.icns");
pub fn generate_modulo_app_bundle(modulo_path: &str) -> Result<PathBuf, std::io::Error> {
let modulo_pathbuf = PathBuf::from(modulo_path);
@ -38,11 +39,18 @@ pub fn generate_modulo_app_bundle(modulo_path: &str) -> Result<PathBuf, std::io:
let macos_dir = contents_dir.join("MacOS");
std::fs::create_dir(&macos_dir)?;
let resources_dir = contents_dir.join("Resources");
std::fs::create_dir(&resources_dir)?;
// Generate the Plist file
let plist_content = MODULO_APP_BUNDLE_PLIST_CONTENT.replace("{{{modulo_path}}}", &modulo_path);
let plist_file = contents_dir.join("Info.plist");
std::fs::write(plist_file, plist_content)?;
// Copy the icon file
let icon_file = resources_dir.join("AppIcon.icns");
std::fs::write(icon_file, MODULO_APP_BUNDLE_ICON)?;
// Generate the symbolic link to the modulo binary
let target_link = macos_dir.join("modulo");
symlink(modulo_path, &target_link)?;