update install udev rules dialog

This commit is contained in:
Craig Raw 2025-01-21 13:55:45 +02:00
parent 13bd05853c
commit 2b145cb9cc
2 changed files with 19 additions and 23 deletions

View file

@ -572,21 +572,27 @@ public class AppController implements Initializable {
} }
public void installUdevRules(ActionEvent event) { public void installUdevRules(ActionEvent event) {
Hwi.EnumerateService enumerateService = new Hwi.EnumerateService(null); String commands = """
enumerateService.setOnSucceeded(workerStateEvent -> { sudo install -m 644 /opt/sparrow/lib/runtime/conf/udev/*.rules /etc/udev/rules.d
Platform.runLater(this::showInstallUdevMessage); sudo udevadm control --reload
}); sudo udevadm trigger
enumerateService.setOnFailed(workerStateEvent -> { sudo groupadd -f plugdev
Platform.runLater(this::showInstallUdevMessage); sudo usermod -aG plugdev `whoami`
}); """;
enumerateService.start(); String home = System.getProperty(JPACKAGE_APP_PATH);
} if(home != null && !home.startsWith("/opt/sparrow") && home.endsWith("bin/Sparrow")) {
home = home.replace("bin/Sparrow", "");
commands = commands.replace("/opt/sparrow/", home);
}
public void showInstallUdevMessage() { TextAreaDialog dialog = new TextAreaDialog(commands, false);
TextAreaDialog dialog = new TextAreaDialog("sudo " + Config.get().getHwi().getAbsolutePath() + " installudevrules", false);
dialog.initOwner(rootStack.getScene().getWindow()); dialog.initOwner(rootStack.getScene().getWindow());
dialog.setTitle("Install Udev Rules"); dialog.setTitle("Install udev Rules");
dialog.getDialogPane().setHeaderText("Installing udev rules ensures devices can connect over USB.\nThis command requires root privileges.\nOpen a shell and enter the following:"); dialog.getDialogPane().setHeaderText("""
Installing udev rules ensures devices can connect over USB.
These commands require root privileges.
Open a shell and enter the following.
""");
dialog.showAndWait(); dialog.showAndWait();
} }

View file

@ -54,7 +54,6 @@ public class Config {
private List<File> recentWalletFiles; private List<File> recentWalletFiles;
private Integer keyDerivationPeriod; private Integer keyDerivationPeriod;
private long dustAttackThreshold = DUST_ATTACK_THRESHOLD_SATS; private long dustAttackThreshold = DUST_ATTACK_THRESHOLD_SATS;
private File hwi;
private int enumerateHwPeriod = ENUMERATE_HW_PERIOD_SECS; private int enumerateHwPeriod = ENUMERATE_HW_PERIOD_SECS;
private QRDensity qrDensity; private QRDensity qrDensity;
private Boolean hdCapture; private Boolean hdCapture;
@ -371,15 +370,6 @@ public class Config {
return dustAttackThreshold; return dustAttackThreshold;
} }
public File getHwi() {
return hwi;
}
public void setHwi(File hwi) {
this.hwi = hwi;
flush();
}
public int getEnumerateHwPeriod() { public int getEnumerateHwPeriod() {
return enumerateHwPeriod; return enumerateHwPeriod;
} }