digitalmars.D.learn - How to use Dbus to detect application uniqueness in D?
- Hossain Adnan (31/31) Sep 27 2019 Hi I need to detect application uniqueness using dbus. I have a
- Kagamin (1/1) Sep 28 2019 https://ddbus.dpldocs.info/ddbus.bus.requestName.html
- Hossain Adnan (2/3) Sep 28 2019 It requires a Connection type which I cannot find in the API.
Hi I need to detect application uniqueness using dbus. I have a working code in Rust: fn run_as_unique_instance() { println!("First instance detected. Doing work..."); loop {} } fn run_as_nonunique_instance() { println!("Another instance is already running. Quiting..."); std::process::exit(0); } fn main() { let session = dbus::blocking::Connection::new_session().expect("Cannot setup a new dbus session"); match session.request_name("com.localserver.app.bus", false, false, false) { Ok(dbus::blocking::stdintf::org_freedesktop_dbus::RequestName eply::PrimaryOwner) => { run_as_unique_instance() } Ok(_) => run_as_nonunique_instance(), // RequestNameReply::InQueue Err(_) => panic!("Error in session name request."), } } This creates a new session in dbus and then requests name. If the response is "PrimaryOwner" it means the application is unique. However I can't find the similar symbols in ddbus. https://ddbus.dpldocs.info/search-results.html#!session https://ddbus.dpldocs.info/search-results.html#!Connection Returns nothing.
Sep 27 2019
On Saturday, 28 September 2019 at 13:37:12 UTC, Kagamin wrote:https://ddbus.dpldocs.info/ddbus.bus.requestName.htmlIt requires a Connection type which I cannot find in the API.
Sep 28 2019
On Sunday, 29 September 2019 at 02:09:56 UTC, Hossain Adnan wrote:On Saturday, 28 September 2019 at 13:37:12 UTC, Kagamin wrote:It's in ddbus.thin, missing documentation comment, see unittest: https://ddbus.dpldocs.info/source/ddbus.bus.d.html#L46https://ddbus.dpldocs.info/ddbus.bus.requestName.htmlIt requires a Connection type which I cannot find in the API.
Sep 30 2019
On Sunday, 29 September 2019 at 02:09:56 UTC, Hossain Adnan wrote:On Saturday, 28 September 2019 at 13:37:12 UTC, Kagamin wrote:It's in ddbus.thin, missing documentation comment, see unittest: https://ddbus.dpldocs.info/source/ddbus.bus.d.html#L46 and usage example at http://code.dlang.org/packages/ddbushttps://ddbus.dpldocs.info/ddbus.bus.requestName.htmlIt requires a Connection type which I cannot find in the API.
Sep 30 2019