Skip to content

Commit d0bc09f

Browse files
committed
add isSupported method
1 parent 5568025 commit d0bc09f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/java/org/cryptomator/linux/sidebar/NautilusSidebarService.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.cryptomator.linux.sidebar;
22

3+
import org.cryptomator.integrations.common.CheckAvailability;
34
import org.cryptomator.integrations.sidebar.SidebarService;
45
import org.cryptomator.integrations.sidebar.SidebarServiceException;
56

@@ -9,9 +10,11 @@
910
import java.nio.file.Path;
1011
import java.nio.file.StandardCopyOption;
1112
import java.nio.file.StandardOpenOption;
13+
import java.util.concurrent.TimeUnit;
1214
import java.util.concurrent.locks.Lock;
1315
import java.util.concurrent.locks.ReentrantReadWriteLock;
1416

17+
@CheckAvailability
1518
public class NautilusSidebarService implements SidebarService {
1619

1720
private static final int MAX_FILE_SIZE = 4096;
@@ -72,4 +75,17 @@ public void remove() throws SidebarServiceException {
7275
}
7376
}
7477
}
78+
79+
@CheckAvailability
80+
public static boolean isSupported() {
81+
try {
82+
var nautilusExistsProc = new ProcessBuilder().command("test", "`command -v nautilus`").start();
83+
if (nautilusExistsProc.waitFor(5000, TimeUnit.MILLISECONDS)) {
84+
return nautilusExistsProc.exitValue() == 0;
85+
}
86+
} catch (IOException | InterruptedException e) {
87+
//NO-OP
88+
}
89+
return false;
90+
}
7591
}

0 commit comments

Comments
 (0)