// Path: src/org/sleeksnap/util/StreamUtils.java
// public class StreamUtils {
// 
// 	/**
// 	 * Read all of the data from an InputStream into a string
// 	 * @param inputStream
// 	 * 			The stream to read from
// 	 * @return
// 	 * 			The data, lines separated by \n
// 	 * @throws IOException
// 	 * 			If a problem occurred while reading
// 	 */
// 	public static String readContents(InputStream inputStream)
// 			throws IOException {
// 		StringBuilder contents = new StringBuilder();
// 		BufferedReader reader = new BufferedReader(new InputStreamReader(
// 				inputStream));
// 		try {
// 			String line;
// 			while ((line = reader.readLine()) != null) {
// 				contents.append(line).append("\n");
// 			}
// 		} finally {
// 			reader.close();
// 		}
// 		return contents.toString().trim();
// 	}
// 	
// 	public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
// 		int read;
// 		byte[] buf = new byte[1024];
// 		while((read = inputStream.read(buf, 0, buf.length)) != -1) {
// 			outputStream.write(buf, 0, read);
// 		}
// 	}
// }
// 
// Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
// 	
// 	/**
// 	 * The window name
// 	 */
// 	private String name;
// 
// 	/**
// 	 * The window's bounds
// 	 */
// 	private Rectangle bounds;
// 
// 	public ActiveWindow(String name, Rectangle bounds) {
// 		this.name = name;
// 		this.bounds = bounds;
// 	}
// 
// 	/**
// 	 * Get the window's bounds as a rectangle
// 	 * @return
// 	 * 		A rectangle containing the window's bounds
// 	 */
// 	public Rectangle getBounds() {
// 		return bounds;
// 	}
// 
// 	/**
// 	 * Get the window name
// 	 * @return
// 	 * 		The window name
// 	 */
// 	public String getName() {
// 		return name;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// 				+ bounds.width + ",height=" + bounds.height + "]";
// 	}
// }
// 
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
// 
// 	/**
// 	 * Get the active window
// 	 * 
// 	 * @return The active desktop window
// 	 * @throws Exception
// 	 *             If we failed to get the window
// 	 */
// 	public ActiveWindow getActiveWindow() throws Exception;
// }


import java.awt.Rectangle;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sleeksnap.util.StreamUtils;
import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil;
			throw new Exception("XWinInfo did not provide location info!");
		}
		int x = Integer.parseInt(matcher.group(1));
		int y = Integer.parseInt(matcher.group(2));
		matcher = pattern.matcher(resp);
		if (!matcher.find()) {
			throw new Exception("XWinInfo did not provide size info!");
		}
		int width = Integer.parseInt(matcher.group(1));
		int height = Integer.parseInt(matcher.group(2));
		// Return a new ActiveWindow object
		return new ActiveWindow(name, new Rectangle(x, y, width, height));
	}

	/**
	 * Execute a command and get the response
	 * 
	 * @param cmdline
	 *            The command to be run
	 * @return The output of the comman
	 * @throws IOException
	 *             If an error occurred while reading from the process
	 * @throws InterruptedException
	 *             If the process is interrupted while waiting
	 */
	public static String runProcess(String cmdline) throws IOException,
			InterruptedException {
		Process p = Runtime.getRuntime().exec(cmdline);
		p.waitFor();
		try {
// Path: src/org/sleeksnap/util/StreamUtils.java
// public class StreamUtils {
// 
// 	/**
// 	 * Read all of the data from an InputStream into a string
// 	 * @param inputStream
// 	 * 			The stream to read from
// 	 * @return
// 	 * 			The data, lines separated by \n
// 	 * @throws IOException
// 	 * 			If a problem occurred while reading
// 	 */
// 	public static String readContents(InputStream inputStream)
// 			throws IOException {
// 		StringBuilder contents = new StringBuilder();
// 		BufferedReader reader = new BufferedReader(new InputStreamReader(
// 				inputStream));
// 		try {
// 			String line;
// 			while ((line = reader.readLine()) != null) {
// 				contents.append(line).append("\n");
// 			}
// 		} finally {
// 			reader.close();
// 		}
// 		return contents.toString().trim();
// 	}
// 	
// 	public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
// 		int read;
// 		byte[] buf = new byte[1024];
// 		while((read = inputStream.read(buf, 0, buf.length)) != -1) {
// 			outputStream.write(buf, 0, read);
// 		}
// 	}
// }
// 
// Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
// 	
// 	/**
// 	 * The window name
// 	 */
// 	private String name;
// 
// 	/**
// 	 * The window's bounds
// 	 */
// 	private Rectangle bounds;
// 
// 	public ActiveWindow(String name, Rectangle bounds) {
// 		this.name = name;
// 		this.bounds = bounds;
// 	}
// 
// 	/**
// 	 * Get the window's bounds as a rectangle
// 	 * @return
// 	 * 		A rectangle containing the window's bounds
// 	 */
// 	public Rectangle getBounds() {
// 		return bounds;
// 	}
// 
// 	/**
// 	 * Get the window name
// 	 * @return
// 	 * 		The window name
// 	 */
// 	public String getName() {
// 		return name;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// 				+ bounds.width + ",height=" + bounds.height + "]";
// 	}
// }
// 
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
// 
// 	/**
// 	 * Get the active window
// 	 * 
// 	 * @return The active desktop window
// 	 * @throws Exception
// 	 *             If we failed to get the window
// 	 */
// 	public ActiveWindow getActiveWindow() throws Exception;
// }


// Path: src/org/sleeksnap/util/active/linux/XPropWindowUtil.java
import java.awt.Rectangle;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sleeksnap.util.StreamUtils;
import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil;

			throw new Exception("XWinInfo did not provide location info!");
		}
		int x = Integer.parseInt(matcher.group(1));
		int y = Integer.parseInt(matcher.group(2));
		matcher = pattern.matcher(resp);
		if (!matcher.find()) {
			throw new Exception("XWinInfo did not provide size info!");
		}
		int width = Integer.parseInt(matcher.group(1));
		int height = Integer.parseInt(matcher.group(2));
		// Return a new ActiveWindow object
		return new ActiveWindow(name, new Rectangle(x, y, width, height));
	}

	/**
	 * Execute a command and get the response
	 * 
	 * @param cmdline
	 *            The command to be run
	 * @return The output of the comman
	 * @throws IOException
	 *             If an error occurred while reading from the process
	 * @throws InterruptedException
	 *             If the process is interrupted while waiting
	 */
	public static String runProcess(String cmdline) throws IOException,
			InterruptedException {
		Process p = Runtime.getRuntime().exec(cmdline);
		p.waitFor();
		try {
			return StreamUtils.readContents(p.getInputStream());