From 68cd3025dc5fabf981a4f4d9ecb756e18aa01c66 Mon Sep 17 00:00:00 2001 From: hrdl <31923882+hrdl-github@users.noreply.github.com> Date: Fri, 16 Jun 2023 11:34:16 +0200 Subject: [PATCH] Introduce named instances --- pdf_viewer/main.cpp | 3 ++- pdf_viewer/utils.cpp | 4 ++++ resources/sioyek.1 | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pdf_viewer/main.cpp b/pdf_viewer/main.cpp index 61c4f4592..e93f06128 100644 --- a/pdf_viewer/main.cpp +++ b/pdf_viewer/main.cpp @@ -733,7 +733,8 @@ int main(int argc, char* args[]) { use_single_instance = false; } - RunGuard guard("sioyek"); + char* instance_name = get_argv_value(argc, args, "--instance-name"); + RunGuard guard(instance_name ? instance_name : "sioyek"); if (!guard.isPrimary()) { QStringList sent_args = convert_arguments(app.arguments()); diff --git a/pdf_viewer/utils.cpp b/pdf_viewer/utils.cpp index c53b3e404..f33b35612 100644 --- a/pdf_viewer/utils.cpp +++ b/pdf_viewer/utils.cpp @@ -1554,6 +1554,10 @@ QCommandLineParser* get_command_line_parser() { //new_instance_option.setDescription("When opening a new file, create a new instance of sioyek."); //parser->addOption(new_instance_option); + QCommandLineOption instance_name_option("instance-name"); + instance_name_option.setDescription("Select a specific sioyek instance by name."); + parser->addOption(instance_name_option); + QCommandLineOption new_window_option("new-window"); new_window_option.setDescription("Open the file in a new window but within the same sioyek instance (reuses the previous window if a sioyek window with the same file already exists)."); parser->addOption(new_window_option); diff --git a/resources/sioyek.1 b/resources/sioyek.1 index 1ad3a2d1e..8b705eec4 100644 --- a/resources/sioyek.1 +++ b/resources/sioyek.1 @@ -691,6 +691,10 @@ is set in a preference file (see below), then open a tutorial PDF. Displays version information .HP +.B --instance-name + +Select a specific sioyek instance by name. +.HP .B --new-window Open the file in a new window but within the same sioyek instance.