1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-26 08:25:50 +03:00

Add basic install script and icon

The icon comes from "Smoothicons 7" by Corey Marion which I found
as a royalty free icon searching the internet.  I would love to
have a purpose built icon, but this is sufficient for now.

The install script sets up a macOS application bundle that references
the generated wezterm binary and the icon.  The same technique could
be used to generate a .desktop file for linux.

I've changed the default-prog on macos to be `login -pf $USER` as
that is a better default experience on macOS.
This commit is contained in:
Wez Furlong 2019-03-23 18:37:08 -07:00
parent 967d43d57c
commit 67a57f12af
7 changed files with 100 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
/Cargo.lock /Cargo.lock
/target/ /target/
**/*.rs.bk **/*.rs.bk

BIN
assets/icon/terminal.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
assets/icon/terminal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>wezterm</string>
<key>CFBundleIdentifier</key>
<string>com.github.wez.wezterm</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>WezTerm</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleIconFile</key>
<string>terminal.icns</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSMainNibFile</key>
<string></string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleDisplayName</key>
<string>WezTerm</string>
<key>NSRequiresAquaSystemAppearance</key>
<string>NO</string>
<key>NSAppleEventsUsageDescription</key>
<string>An application launched via WezTerm would like to access AppleScript.</string>
<key>NSCalendarsUsageDescription</key>
<string>An application launched via WezTerm would like to access calendar data.</string>
<key>NSCameraUsageDescription</key>
<string>An application launched via WezTerm would like to access the camera.</string>
<key>NSContactsUsageDescription</key>
<string>An application launched via WezTerm wants to access your contacts.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>An application launched via WezTerm would like to access your location information, even in the background.</string>
<key>NSLocationUsageDescription</key>
<string>An application launched via WezTerm would like to access your location information.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>An application launched via WezTerm would like to access your location information while active.</string>
<key>NSMicrophoneUsageDescription</key>
<string>An application launched via WezTerm would like to access your microphone.</string>
<key>NSRemindersUsageDescription</key>
<string>An application launched via WezTerm would like to access your reminders.</string>
</dict>
</plist>

16
install.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
case $OSTYPE in
darwin*)
APP=$HOME/Applications/WezTerm.app
cargo build --release
rm -rf $APP
cp -r assets/macos/WezTerm.app $APP
cp target/release/wezterm $APP
echo "Installed to $APP"
;;
*)
echo "Don't know how to install the app on this system"
exit 1
;;
esac

View File

@ -381,10 +381,37 @@ impl Config {
cfg cfg
} }
/// On macOS, we get launched from: eg: spotlight or alfred
/// or the finder with whatever SHELL was set to at login time
/// (which have been subsequently changed via `chsh`) and with
/// a cwd=/.
/// That feels a bit broken, so we follow the lead of
/// Terminal.app and use `login -pf $USER` as the default
/// program to run.
/// This function computes and returns that command.
/// We don't do this on Linux because the linux `login`
/// program refuses to run except when started by root.
#[cfg(target_os = "macos")]
fn macos_login() -> Result<Vec<String>, Error> {
let ent = unsafe { libc::getpwuid(libc::getuid()) };
if ent.is_null() {
bail!("unable to resolve my own uid");
} else {
let name = unsafe { std::ffi::CStr::from_ptr((*ent).pw_name) };
let name = name.to_str().map(str::to_owned)?;
Ok(vec!["login".to_owned(), "-pf".to_owned(), name])
}
}
pub fn default_prog(&self) -> Result<Vec<String>, Error> { pub fn default_prog(&self) -> Result<Vec<String>, Error> {
if let Some(prog) = self.default_prog.as_ref() { if let Some(prog) = self.default_prog.as_ref() {
Ok(prog.clone()) Ok(prog.clone())
} else { } else {
if cfg!(target_os = "macos") {
if let Ok(login) = Self::macos_login() {
return Ok(login);
}
}
Ok(vec![get_shell()?]) Ok(vec![get_shell()?])
} }
} }