Giter VIP home page Giter VIP logo

Comments (9)

betamos avatar betamos commented on August 23, 2024 3

+1! I'm looking for single-instance in my Tauri app. When a user tries to open a new instance, it should bring focus to the existing application.

However, seeing this is a low-level utility (you wouldn't even need a GUI app at all) it wouldn't make sense to try to foreground an application from this crate. However, what would work is if the existing instance got a notification that another instance has been requested, perhaps as a receiving channel + canceler API. This would be sufficient to pipe through the request and do the appropriate thing.

Note that this would have tremendous value even if it wasn't supported on all platforms. For instance, MacOS already has deduplication so it's never a problem in practice (afaik). Windows is certainly the most useful one, probably followed by Linux.

Please consider reopening this.

from single-instance.

WLBF avatar WLBF commented on August 23, 2024

I dont fully understand what you said brings the window to the foreground, Can you explain more detail about what you are proposing?

from single-instance.

SonnyX avatar SonnyX commented on August 23, 2024

A function that if another instance exists, and if that Instance has a GUI, to bring the GUI to the foreground (in case it is minimized or hidden)

from single-instance.

WLBF avatar WLBF commented on August 23, 2024

Very interesting idea. I will do some research on this, although I probably would not add this kind of complex feature to this simple crate.

from single-instance.

WLBF avatar WLBF commented on August 23, 2024

One solution I can imagine is use unix domain socket inform another instance.

from single-instance.

SonnyX avatar SonnyX commented on August 23, 2024

The same potentially with Windows named pipes, unless there is another way to get the window handle.

from single-instance.

ottosson avatar ottosson commented on August 23, 2024

I would very much love to see this feature as well. Why was it closed?

Thanks!

from single-instance.

nu11ptr avatar nu11ptr commented on August 23, 2024

A potential workaround until this feature is added: what is really needed is a "platform independent IPC". It looks like there is a crate that does this: interprocess. My plan is to use this crate plus that one (haven't tried yet, but seems like it should work). At that point, the first process could take any action needed in a GUI independent manner once notified including restoring a GUI window, etc.

from single-instance.

Hellager avatar Hellager commented on August 23, 2024

+1! I'm looking for single-instance in my Tauri app. When a user tries to open a new instance, it should bring focus to the existing application.

However, seeing this is a low-level utility (you wouldn't even need a GUI app at all) it wouldn't make sense to try to foreground an application from this crate. However, what would work is if the existing instance got a notification that another instance has been requested, perhaps as a receiving channel + canceler API. This would be sufficient to pipe through the request and do the appropriate thing.

Note that this would have tremendous value even if it wasn't supported on all platforms. For instance, MacOS already has deduplication so it's never a problem in practice (afaik). Windows is certainly the most useful one, probably followed by Linux.

Please consider reopening this.

Hi there, i wonder have you already tried using this crate in your app? I'm trying add this to my tauri app, it works well in pure rust, but seems to be not working in tauri. I tried like this

#[tauri::command]
fn check_instance() -> bool {
    let instance = SingleInstance::new("tauri-app").unwrap();
    println!("check instance whether single {}", instance.is_single());
   
    instance.is_single()
}

from single-instance.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.