I have getRuntime().exec() calls in my program; however, two of them will not work:
public static final ROTCW = "xrandr -o left"
public static final CALCW1 = "xinput --set-prop 11 \"Evdev Axis Inversion\" 0 1"
public static final CALCW2 = "xinput --set-prop 11 \"Evdev Axes Swap\" 1";
public void actionPerformed(ActionEvent e)
{
try {
Runtime.getRuntime().exec(ROTCW);
Runtime.getRuntime().exec(CALCW1);
Runtime.getRuntime().exec(CALCW2);}
catch (IOException ioe){ ioe.printStackTrace();}
}});
ROTCW definitely works (the screen rotates cw), but it does not calibrate (CALCW). Typing the CALCWs manually in the same terminal tab as the one I started the program with does not work, but typing it into a new terminal tab/window does work.
Why does this happen, and what fixes it?
You could implement the &&
logic directly in Java:
public static final String
ROTCW = "xrandr -o left",
CALCW1[] = {"xinput", "--set-prop", "11", "\"Evdev Axis Inversion\"", "0", "1"},
CALCW2[] = {"xinput", "--set-prop", "11", "\"Evdev Axes Swap\"", "1"};
public void actionPerformed(ActionEvent e)
{
try {
Runtime.getRuntime().exec(ROTCW).waitFor();
Process p = Runtime.getRuntime().exec(CALCW1);
p.waitFor();
if( p.exitValue() != 0 ) Runtime.getRuntime().exec(CALCW2);
}
catch (IOException ioe){ ioe.printStackTrace();}
}});