Class Lpstat

java.lang.Object
oshi.util.driver.unix.Lpstat

@ThreadSafe public final class Lpstat extends Object
Utility to parse printer information from lpstat and lpoptions commands. Shared fallback path for both JNA and FFM implementations when libcups is unavailable.
  • Method Details

    • queryDefaultPrinter

      public static String queryDefaultPrinter()
      Query the default printer name.
      Returns:
      the default printer name, or empty string if none
    • queryPortMap

      public static Map<String,String> queryPortMap()
      Query the port (device URI) map for all printers.
      Returns:
      map of printer name to device URI
    • queryDescriptionMap

      public static Map<String,String> queryDescriptionMap()
      Query the description map for all printers.
      Returns:
      map of printer name to description
    • queryDriver

      public static String queryDriver(String printerName)
      Query the driver name for a specific printer.
      Parameters:
      printerName - the printer name
      Returns:
      the driver (make-and-model) string, or empty string if unknown
    • parseStatus

      public static Printer.PrinterStatus parseStatus(String line)
      Parse the printer status from an lpstat -p line.
      Parameters:
      line - a single line from lpstat -p
      Returns:
      the parsed status
    • parseStatusReason

      public static String parseStatusReason(String line)
      Parse the status reason from an lpstat -p line.
      Parameters:
      line - a single line from lpstat -p
      Returns:
      the reason string, or empty string if none
    • isLocalUri

      public static boolean isLocalUri(String uri)
      Determine if a device URI represents a local printer.
      Parameters:
      uri - the device URI
      Returns:
      true if the URI indicates a local printer