Skip to content

Commit

Permalink
Merge pull request #124 from Kingtous/feat/support_linux_terminal
Browse files Browse the repository at this point in the history
feat: support terminal app using cargo-bundle
  • Loading branch information
mdsteele authored Nov 19, 2022
2 parents 630ec3f + c055cd2 commit c875d02
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ These settings are used only when bundling Linux compatible packages (currently
field in the `.desktop` file. For example if the binary is called `my_program` and
`linux_exec_args = "%f"` then the Exec filed will be `Exec=my_program %f`. Find out more from the
[specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables)
* `linux_use_terminal`: A boolean variable indicating the app is a console app or a gui app, default it's set to false.

### Debian-specific settings

Expand Down
2 changes: 1 addition & 1 deletion src/bundle/deb_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn generate_desktop_file(settings: &Settings, data_dir: &Path) -> ::Result<()> {
write!(file, "Exec={}\n", exec)?;
write!(file, "Icon={}\n", bin_name)?;
write!(file, "Name={}\n", settings.bundle_name())?;
write!(file, "Terminal=false\n")?;
write!(file, "Terminal={}\n", settings.linux_use_terminal().unwrap_or(false))?;
write!(file, "Type=Application\n")?;
write!(file, "MimeType={}\n", mime_types)?;
// The `Version` field is omitted on pupose. See `generate_control_file` for specifying
Expand Down
7 changes: 7 additions & 0 deletions src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct BundleSettings {
// OS-specific settings:
linux_mime_types: Option<Vec<String>>,
linux_exec_args: Option<String>,
linux_use_terminal: Option<bool>,
deb_depends: Option<Vec<String>>,
osx_frameworks: Option<Vec<String>>,
osx_minimum_system_version: Option<String>,
Expand Down Expand Up @@ -288,6 +289,8 @@ impl Settings {
/// Returns the path to the binary being bundled.
pub fn binary_path(&self) -> &Path { &self.binary_path }

pub fn bundle_settings(&self) -> BundleSettings { self.bundle_settings.clone() }

/// If a specific package type was specified by the command-line, returns
/// that package type; otherwise, if a target triple was specified by the
/// command-line, returns the native package type(s) for that target;
Expand Down Expand Up @@ -420,6 +423,10 @@ impl Settings {
}
}

pub fn linux_use_terminal(&self) -> Option<bool> {
self.bundle_settings.linux_use_terminal
}

pub fn linux_exec_args(&self) -> Option<&str> {
self.bundle_settings.linux_exec_args.as_ref().map(String::as_str)
}
Expand Down

0 comments on commit c875d02

Please sign in to comment.