Skip to content

Commit 9d21a01

Browse files
committed
core/command: add --no-duplicate
1 parent 47ec85f commit 9d21a01

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/core/main.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ struct CommandState {
132132
struct {
133133
bool printVersion = false;
134134
bool killAll = false;
135+
bool noDuplicate = false;
135136
} misc;
136137
};
137138

@@ -239,13 +240,13 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
239240
{
240241
cli.add_flag("-V,--version", state.misc.printVersion)
241242
->description("Print quickshell's version and exit.");
243+
244+
cli.add_flag("--no-duplicate", state.misc.noDuplicate)
245+
->description("Exit immediately if another instance of the given config is running.");
242246
}
243247

244248
{
245-
auto* sub = cli.add_subcommand("log", "Read quickshell logs.\n")
246-
->description("If file is specified, the given file will be read.\n"
247-
"If not, the log of the first launched instance matching"
248-
"the instance selection flags will be read.");
249+
auto* sub = cli.add_subcommand("log", "Print quickshell logs.");
249250

250251
auto* file = sub->add_option("file", state.log.file, "Log file to read.");
251252

@@ -644,6 +645,14 @@ int launchFromCommand(CommandState& cmd, QCoreApplication* coreApplication) {
644645
auto r = locateConfigFile(cmd, configPath);
645646
if (r != 0) return r;
646647

648+
{
649+
InstanceLockInfo info;
650+
if (cmd.misc.noDuplicate && selectInstance(cmd, &info) == 0) {
651+
qCDebug(logBare) << "An instance of this configuration is already running.";
652+
return 0;
653+
}
654+
}
655+
647656
return launch(
648657
{
649658
.configPath = configPath,

0 commit comments

Comments
 (0)