// Path: src/main/java/org/jutils/jhardware/info/display/AbstractDisplayInfo.java
// public abstract class AbstractDisplayInfo implements HardwareInfo { 
// 
//     /**
//      *
//      * @return
//      */
//     @Override
//     public DisplayInfo getInfo() {
//         return buildFromDataMap(parseInfo());
//     }
//     
//     protected abstract Map<String, String> parseInfo();
//     
//     protected DisplayInfo buildFromDataMap(Map<String, String> dataMap) {
//         DisplayInfo info = new DisplayInfo();
//         
//         List<Display> displayList = new ArrayList<>();
//         if (dataMap != null && !dataMap.isEmpty()) {
//             int numOfDisplays = Integer.parseInt(dataMap.get("numOfDisplays"));
//             for (int i = 0; i < numOfDisplays; i++) {
//                 Display display = new Display();
//                 
//                 display.setName(dataMap.get("name_" + i));
//                 display.setCurrentResolution(dataMap.get("current_res_" + i));
//                 display.setRefreshRate(dataMap.get("current_refresh_rate_" + i));                
//                 display.setSupportedResolutions(dataMap.get("available_res_" + i).split(";"));
//                 
//                 displayList.add(display);
//             }
//         }
//         info.setDisplayDevices(displayList);
//         
//         return info;
//     }
// }
// 
// Path: src/main/java/org/jutils/jhardware/util/HardwareInfoUtils.java
// public class HardwareInfoUtils {
// 
//     private static final String CRLF = "\r\n";
// 
//     private static final String NOT_FOUND = "NOT_FOUND";
// 
//     private HardwareInfoUtils() {
//         //Hide constructor
//     }
// 
//     public static Stream<String> readFile(String filePath) {
//         Path path = Paths.get(filePath);
// 
//         try {
//             return Files.lines(path);
//         } catch (IOException ioEx) {
//             Logger.getLogger(HardwareInfoUtils.class.getName()).log(Level.SEVERE, null, ioEx);
//             return Stream.empty();
//         }
//     }
// 
//     public static String getSingleValueFromFile(String filePath) {
//         try (Stream<String> streamProcessorInfo = readFile(filePath)) {
//             return streamProcessorInfo.findFirst().get();
//         }
//     }
// 
//     public static String executeCommand(String... command) {
//         String commandOutput = null;
// 
//         try {
//             ProcessBuilder processBuilder = new ProcessBuilder(command);
//             processBuilder.redirectErrorStream(true); // redirect error stream to output stream
// 
//             commandOutput = readData(processBuilder.start());
//         } catch (IOException ex) {
//             Logger.getLogger(HardwareInfoUtils.class.getName()).log(Level.SEVERE, null, ex);
//         }
// 
//         return commandOutput;
//     }
// 
//     private static String readData(Process process) {
//         StringBuilder commandOutput = new StringBuilder();
//         BufferedReader processOutput = null;
// 
//         try {
//              processOutput = new BufferedReader(new InputStreamReader(process.getInputStream()));
// 
//             String line;
//             while ((line = processOutput.readLine()) != null) {
//                 if (!line.isEmpty()) {
//                     commandOutput.append(line).append(CRLF);
//                 }
//             }
//         } catch (IOException ex) {
//             Logger.getLogger(HardwareInfoUtils.class.getName()).log(Level.SEVERE, null, ex);
//         } finally {
//             try {
//                 if (processOutput != null) {
//                     processOutput.close();
//                 }
//             } catch (IOException ioe) {
//                 Logger.getLogger(HardwareInfoUtils.class.getName()).log(Level.SEVERE, null, ioe);
//             }
//         }
// 
//         return commandOutput.toString();
//     }
// 
//     public static boolean isSudo() {
//         return executeCommand("sudo", "-n", "true").length() == 0;
//     }
// 
//     public static String toCamelCase(String s) {
//         String[] parts = s.split("_");
//         String camelCaseString = "";
//         for (String part : parts) {
//             camelCaseString = camelCaseString + toProperCase(part);
//         }
//         return camelCaseString;
//     }
// 
//     private static String toProperCase(String s) {
//         return s.substring(0, 1).toUpperCase()
//                 + s.substring(1).toLowerCase();
//     }
// 
//     public static String removeAllSpaces(String s) {
//         return s.replaceAll("\\s+", "");
//     }
// 
//     public static String extractText(String text, String regex) {
//         if (text.trim().isEmpty()) {
//             return NOT_FOUND;
//         }
// 
//         final Pattern pattern = Pattern.compile(regex);
//         final Matcher matcher = pattern.matcher(text);
// 
//         matcher.find();
//         if (matcher.groupCount() > 0) {
//             return matcher.group(1);
//         }
//         return NOT_FOUND;
//     }
// }


import java.util.Map;
import org.jutils.jhardware.info.display.AbstractDisplayInfo;
import org.jutils.jhardware.util.HardwareInfoUtils;
import java.util.HashMap;
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jutils.jhardware.info.display.unix;


/**
 * Information related to Displays
 *
 * @author Javier Garcia Alonso
 */
public final class UnixDisplayInfo extends AbstractDisplayInfo {

    private static final String XRANDR_COMMAND = "xrandr";
    private static final String XRANDR_PARAM = "-q";

    private static String getDisplayData() {
// Path: src/main/java/org/jutils/jhardware/info/display/AbstractDisplayInfo.java
// public abstract class AbstractDisplayInfo implements HardwareInfo { 
// 
//     /**
//      *
//      * @return
//      */
//     @Override
//     public DisplayInfo getInfo() {
//         return buildFromDataMap(parseInfo());
//     }
//     
//     protected abstract Map<String, String> parseInfo();
//     
//     protected DisplayInfo buildFromDataMap(Map<String, String> dataMap) {
//         DisplayInfo info = new DisplayInfo();
//         
//         List<Display> displayList = new ArrayList<>();
//         if (dataMap != null && !dataMap.isEmpty()) {
//             int numOfDisplays = Integer.parseInt(dataMap.get("numOfDisplays"));
//             for (int i = 0; i < numOfDisplays; i++) {
//                 Display display = new Display();
//                 
//                 display.setName(dataMap.get("name_" + i));
//                 display.setCurrentResolution(dataMap.get("current_res_" + i));
//                 display.setRefreshRate(dataMap.get("current_refresh_rate_" + i));                
//                 display.setSupportedResolutions(dataMap.get("available_res_" + i).split(";"));
//                 
//                 displayList.add(display);
//             }
//         }
//         info.setDisplayDevices(displayList);
//         
//         return info;
//     }
// }
// 
// Path: src/main/java/org/jutils/jhardware/util/HardwareInfoUtils.java
// public class HardwareInfoUtils {
// 
//     private static final String CRLF = "\r\n";
// 
//     private static final String NOT_FOUND = "NOT_FOUND";
// 
//     private HardwareInfoUtils() {
//         //Hide constructor
//     }
// 
//     public static Stream<String> readFile(String filePath) {
//         Path path = Paths.get(filePath);
// 
//         try {
//             return Files.lines(path);
//         } catch (IOException ioEx) {
//             Logger.getLogger(HardwareInfoUtils.class.getName()).log(Level.SEVERE, null, ioEx);
//             return Stream.empty();
//         }
//     }
// 
//     public static String getSingleValueFromFile(String filePath) {
//         try (Stream<String> streamProcessorInfo = readFile(filePath)) {
//             return streamProcessorInfo.findFirst().get();
//         }
//     }
// 
//     public static String executeCommand(String... command) {
//         String commandOutput = null;
// 
//         try {
//             ProcessBuilder processBuilder = new ProcessBuilder(command);
//             processBuilder.redirectErrorStream(true); // redirect error stream to output stream
// 
//             commandOutput = readData(processBuilder.start());
//         } catch (IOException ex) {
//             Logger.getLogger(HardwareInfoUtils.class.getName()).log(Level.SEVERE, null, ex);
//         }
// 
//         return commandOutput;
//     }
// 
//     private static String readData(Process process) {
//         StringBuilder commandOutput = new StringBuilder();
//         BufferedReader processOutput = null;
// 
//         try {
//              processOutput = new BufferedReader(new InputStreamReader(process.getInputStream()));
// 
//             String line;
//             while ((line = processOutput.readLine()) != null) {
//                 if (!line.isEmpty()) {
//                     commandOutput.append(line).append(CRLF);
//                 }
//             }
//         } catch (IOException ex) {
//             Logger.getLogger(HardwareInfoUtils.class.getName()).log(Level.SEVERE, null, ex);
//         } finally {
//             try {
//                 if (processOutput != null) {
//                     processOutput.close();
//                 }
//             } catch (IOException ioe) {
//                 Logger.getLogger(HardwareInfoUtils.class.getName()).log(Level.SEVERE, null, ioe);
//             }
//         }
// 
//         return commandOutput.toString();
//     }
// 
//     public static boolean isSudo() {
//         return executeCommand("sudo", "-n", "true").length() == 0;
//     }
// 
//     public static String toCamelCase(String s) {
//         String[] parts = s.split("_");
//         String camelCaseString = "";
//         for (String part : parts) {
//             camelCaseString = camelCaseString + toProperCase(part);
//         }
//         return camelCaseString;
//     }
// 
//     private static String toProperCase(String s) {
//         return s.substring(0, 1).toUpperCase()
//                 + s.substring(1).toLowerCase();
//     }
// 
//     public static String removeAllSpaces(String s) {
//         return s.replaceAll("\\s+", "");
//     }
// 
//     public static String extractText(String text, String regex) {
//         if (text.trim().isEmpty()) {
//             return NOT_FOUND;
//         }
// 
//         final Pattern pattern = Pattern.compile(regex);
//         final Matcher matcher = pattern.matcher(text);
// 
//         matcher.find();
//         if (matcher.groupCount() > 0) {
//             return matcher.group(1);
//         }
//         return NOT_FOUND;
//     }
// }


// Path: src/main/java/org/jutils/jhardware/info/display/unix/UnixDisplayInfo.java
import java.util.Map;
import org.jutils.jhardware.info.display.AbstractDisplayInfo;
import org.jutils.jhardware.util.HardwareInfoUtils;
import java.util.HashMap;

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jutils.jhardware.info.display.unix;


/**
 * Information related to Displays
 *
 * @author Javier Garcia Alonso
 */
public final class UnixDisplayInfo extends AbstractDisplayInfo {

    private static final String XRANDR_COMMAND = "xrandr";
    private static final String XRANDR_PARAM = "-q";

    private static String getDisplayData() {
        return HardwareInfoUtils.executeCommand(XRANDR_COMMAND, XRANDR_PARAM);        