Skip to content

Commit

Permalink
- smoother running
Browse files Browse the repository at this point in the history
  • Loading branch information
robson-alcantara committed Mar 14, 2019
1 parent a17fd4b commit 1034ebd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
29 changes: 20 additions & 9 deletions src/cpupowergui/controller/CPUPowerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,6 @@ public void setGovernor() {
String command = "pkexec sed -i 's/^GOVERNOR=.*/GOVERNOR=\"" + governorString + "\"/' /etc/init.d/cpufrequtils";
Process pr = rt.exec(new String[] { "bash", "-c", command});

// command = "pkexec grep -v '#' /etc/init.d/cpufrequtils | awk -F \"=\" '/GOVERNOR=/ {print $2;}'";
// pr = rt.exec(new String[] { "bash", "-c", command});

if( governor != Governor.ONDEMAND ) {
command = "pkexec systemctl disable ondemand";
pr = rt.exec(new String[] { "bash", "-c", command});
}

String output;

final ProcessResultReader stderr = new ProcessResultReader(pr.getErrorStream(), "STDERR");
Expand All @@ -171,7 +163,26 @@ public void setGovernor() {
final ProcessResultReader stdout = new ProcessResultReader(pr.getErrorStream(), "STDOUT");
stdout.run();
output = stdout.toString();
System.out.println(output);
System.out.println(output);

// command = "pkexec grep -v '#' /etc/init.d/cpufrequtils | awk -F \"=\" '/GOVERNOR=/ {print $2;}'";
// pr = rt.exec(new String[] { "bash", "-c", command});

if( governor != Governor.ONDEMAND ) {
command = "pkexec systemctl disable ondemand";
pr = rt.exec(new String[] { "bash", "-c", command});

final ProcessResultReader stderr2 = new ProcessResultReader(pr.getErrorStream(), "STDERR");
stderr2.run();
output = stderr2.toString();
System.out.println(output);

final ProcessResultReader stdout2 = new ProcessResultReader(pr.getErrorStream(), "STDOUT");
stdout2.run();
output = stdout2.toString();
System.out.println(output);
}

JOptionPane.showMessageDialog(cpuPowerJFrame, "Governor permanently altered","Message",JOptionPane.INFORMATION_MESSAGE);
} catch (IOException ex) {
Logger.getLogger(CPUPowerController.class.getName()).log(Level.SEVERE, null, ex);
Expand Down
2 changes: 1 addition & 1 deletion src/cpupowergui/view/CPUPowerJFrame.form
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
</Component>
<Component class="javax.swing.JCheckBox" name="jCheckBox1">
<Properties>
<Property name="text" type="java.lang.String" value="fixed"/>
<Property name="text" type="java.lang.String" value="persistent"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
Expand Down
2 changes: 1 addition & 1 deletion src/cpupowergui/view/CPUPowerJFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void initComponents() {
buttonGroup1.add(jRadioButton5);
jRadioButton5.setText("userspace");

jCheckBox1.setText("fixed");
jCheckBox1.setText("persistent");

jButton1.setText("reconfigure");
jButton1.addActionListener(new java.awt.event.ActionListener() {
Expand Down

0 comments on commit 1034ebd

Please sign in to comment.