Skip to content

Commit 2df5ea7

Browse files
committed
Find the right one from multiple KeePassXC processes
1 parent ccc8616 commit 2df5ea7

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/main/java/org/keepassxc/KindOfKeePassXC.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,44 @@ public class KindOfKeePassXC {
99
private static final Logger LOG = LoggerFactory.getLogger(KindOfKeePassXC.class);
1010

1111
public static Optional<KeePassXCType> determineType() {
12+
///home/<user>/Downloads/KeePassXC-2.7.4-x86_64.AppImage
1213
var processHandle = ProcessHandle.allProcesses()
13-
.filter(ph -> ph.info().command().isPresent() && ph.info().command().get().contains("KeePassXC"))
14+
.filter(ph -> ph.info().command().isPresent() && ph.info().command().get().contains("KeePassXC")
15+
&& ph.info().command().get().contains("AppImage"))
1416
.findFirst();
1517

16-
///home/<user>/Downloads/KeePassXC-2.7.4-x86_64.AppImage
17-
if (processHandle.isPresent() && processHandle.get().info().command().get().contains("AppImage")) {
18+
if (processHandle.isPresent()) {
1819
LOG.debug("Found running KeePassXC AppImage");
1920
return Optional.of(KeePassXCType.AppImage);
2021
}
2122

23+
///usr/bin/bwrap --args 38 keepassxc-wrapper
2224
processHandle = ProcessHandle.allProcesses()
23-
.filter(ph -> ph.info().commandLine().isPresent() && ph.info().commandLine().get().contains("keepassxc"))
25+
.filter(ph -> ph.info().commandLine().isPresent() && ph.info().commandLine().get().contains("keepassxc")
26+
&& ph.info().commandLine().get().contains("bwrap"))
2427
.findFirst();
2528

26-
///usr/bin/bwrap --args 38 keepassxc-wrapper
27-
if (processHandle.isPresent() && processHandle.get().info().commandLine().get().contains("bwrap")) {
29+
if (processHandle.isPresent()) {
2830
LOG.debug("Found running KeePassXC installed via Flatpak");
2931
return Optional.of(KeePassXCType.Flatpak);
3032
}
3133

3234
///snap/keepassxc/1645/usr/bin/keepassxc
33-
if (processHandle.isPresent() && processHandle.get().info().commandLine().get().contains("snap")) {
35+
processHandle = ProcessHandle.allProcesses()
36+
.filter(ph -> ph.info().commandLine().isPresent() && ph.info().commandLine().get().contains("keepassxc")
37+
&& ph.info().commandLine().get().contains("snap"))
38+
.findFirst();
39+
40+
if (processHandle.isPresent()) {
3441
LOG.debug("Found running KeePassXC installed via Snap");
3542
return Optional.of(KeePassXCType.Snap);
3643
}
3744

3845
///usr/bin/keepassxc, gets started as "keepassxc"
46+
processHandle = ProcessHandle.allProcesses()
47+
.filter(ph -> ph.info().commandLine().isPresent() && ph.info().commandLine().get().contains("keepassxc"))
48+
.findFirst();
49+
3950
if (processHandle.isPresent()) {
4051
LOG.debug("Found running KeePassXC installed from repository");
4152
return Optional.of(KeePassXCType.Repo);

0 commit comments

Comments
 (0)