-
Notifications
You must be signed in to change notification settings - Fork 431
feat(autostart): add prefered name configuration for auto start entry #2707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add PreferedName enum to support different naming strategies - Implement Default trait for PreferedName with PackageInfoName as default - Add prefered_name builder method with documentation and examples - Integrate prefered name into auto start configuration This change allows users to customize the name of their application in the auto start entry using various naming strategies like package info name, crate name, config identifier, or custom name.
Package Changes Through c5b28c0There are 2 changes which include autostart with minor, autostart-js with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
…ted logic - Change prefered_name to app_name in the Builder struct and methods - Update PreferedName enum to include new variants and set AppName as default - Modify documentation to reflect the new app_name usage for auto start entry This refactor improves clarity in naming conventions and enhances the configuration options for auto start entries.
Thanks @Legend-Master for review. I kept the original init api which not brings a breaking change. pub fn init<R: Runtime>(
#[allow(unused)] macos_launcher: MacosLauncher,
args: Option<Vec<&'static str>>,
) To setup a app name with builder method fn main() {
tauri::Builder::default()
.setup(|app| {
app.app_handle().plugin(
tauri_plugin_autostart::Builder::new()
.app_name(PreferedName::CrateName)
// .app_name("MyTauriAPP")
.build(),
)?;
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
} It supports 5 naming variants: default ( #[derive(Default)]
pub enum PreferedName {
#[default]
AppName,
CrateName,
Identifier,
ProductName,
Custom(String),
} The extra variants improve configuration file synchronization, which is a useful feature. |
I can see it's more ergonomic to use when you need them, but I can't see when would you want to use them to be honest, for the crate name, you can just do |
The On MacOS, the plist file path is generated based on and for LaunchAgent, the The #[derive(Default)]
pub enum PreferedName {
#[default]
AppName,
Identifier,
Custom(String),
} Keep only these three variants: default to Alternatively, remove the Identifier variant if you think it’s too cumbersome to handle. |
The thing here is that devs themselves can use |
- Change app_name usage in README to a custom string - Simplify app_name handling in lib.rs by removing PreferedName enum - Update Builder struct to accept app_name as an optional string This refactor enhances the clarity and usability of the auto start configuration.
Thanks @Legend-Master and @FabianLars for reviews. Let's keep the api small and simple. The only one additional function for builder is /// Sets the app name to be used for the auto start entry.
///
/// ## Examples
///
/// ```no_run
/// Builder::new()
/// .app_name("My Custom Name"))
/// .build();
/// ```
pub fn app_name(mut self, app_name: &str) -> Self {
self.app_name = Some(app_name.to_string());
self
} no more, no less. |
Thank you! And sorry for being kinda harsh about your ideas. In theory I like them but with the very limited resources we have for maintenance I try to keep things simple like that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, just a few nit picks, thanks for the contribution
Also could you add a change file?
https://github.com/tauri-apps/plugins-workspace/blob/v2/.changes/readme.md
…aming - Introduced a new builder method app_name() to customize the application name in the autostart entry. - Updated app_name handling in the Builder struct to accept a generic string type. This enhancement allows for greater flexibility in defining application names for autostart configurations.
I added the change file. Let's go |
Co-authored-by: Tony <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Add Prefered Name Configuration for AutoStart Entry
This PR introduces the ability to customize the application name used in auto start entries by adding a
PreferedName
enum to support different naming strategies.Key Changes:
PreferedName
enum with variants:PackageInfoName
(default) – Uses name from Tauri's package infoPackageInfoCrateName
– Uses the crate name fromCargo.toml
ConfigIdentifier
– Uses the identifier from Tauri's runtime configConfigProductName
Uses the product_name from Tauri's runtime configCustom(String)
– Allows specifying a custom nameDefault
trait forPreferedName
(defaults toPackageInfoName
)prefered_name
builder method with documentation and usage examplesUsage Example:
This enhancement provides flexibility for apps that need to control their display name in system auto start entries, supporting use cases like branding adjustments or multi-instance differentiation.