Java Code Examples for com.intellij.openapi.util.SystemInfo#hasXdgOpen()

The following examples show how to use com.intellij.openapi.util.SystemInfo#hasXdgOpen() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeFileType.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static boolean openAssociatedApplication(@Nonnull final VirtualFile file) {
  final List<String> commands = new ArrayList<>();
  if (SystemInfo.isWindows) {
    commands.add("rundll32.exe");
    commands.add("url.dll,FileProtocolHandler");
  }
  else if (SystemInfo.isMac) {
    commands.add("/usr/bin/open");
  }
  else if (SystemInfo.hasXdgOpen()) {
    commands.add("xdg-open");
  }
  else {
    return false;
  }
  commands.add(file.getPath());

  try {
    new GeneralCommandLine(commands).createProcess();
    return true;
  }
  catch (Exception e) {
    return false;
  }
}
 
Example 2
Source File: BrowserLauncherAppless.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static List<String> getDefaultBrowserCommand() {
  if (SystemInfo.isWindows) {
    return Arrays.asList(ExecUtil.getWindowsShellName(), "/c", "start", GeneralCommandLine.inescapableQuote(""));
  }
  else if (SystemInfo.isMac) {
    return Collections.singletonList(ExecUtil.getOpenCommandPath());
  }
  else if (SystemInfo.isUnix && SystemInfo.hasXdgOpen()) {
    return Collections.singletonList("xdg-open");
  }
  else {
    return null;
  }
}
 
Example 3
Source File: BrowserLauncherAppless.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean canUseSystemDefaultBrowserPolicy() {
  return isDesktopActionSupported(Desktop.Action.BROWSE) || SystemInfo.isMac || SystemInfo.isWindows || SystemInfo.isUnix && SystemInfo.hasXdgOpen();
}
 
Example 4
Source File: CreateDesktopEntryAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean isAvailable() {
  return SystemInfo.isUnix && SystemInfo.hasXdgOpen();
}