diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index ab5540cd..ee8f7312 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -572,21 +572,27 @@ public class AppController implements Initializable { } public void installUdevRules(ActionEvent event) { - Hwi.EnumerateService enumerateService = new Hwi.EnumerateService(null); - enumerateService.setOnSucceeded(workerStateEvent -> { - Platform.runLater(this::showInstallUdevMessage); - }); - enumerateService.setOnFailed(workerStateEvent -> { - Platform.runLater(this::showInstallUdevMessage); - }); - enumerateService.start(); - } + String commands = """ + sudo install -m 644 /opt/sparrow/lib/runtime/conf/udev/*.rules /etc/udev/rules.d + sudo udevadm control --reload + sudo udevadm trigger + sudo groupadd -f plugdev + sudo usermod -aG plugdev `whoami` + """; + 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("sudo " + Config.get().getHwi().getAbsolutePath() + " installudevrules", false); + TextAreaDialog dialog = new TextAreaDialog(commands, false); dialog.initOwner(rootStack.getScene().getWindow()); - 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.setTitle("Install udev Rules"); + 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(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Config.java b/src/main/java/com/sparrowwallet/sparrow/io/Config.java index cba610fe..3ae6dfb6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Config.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Config.java @@ -54,7 +54,6 @@ public class Config { private List recentWalletFiles; private Integer keyDerivationPeriod; private long dustAttackThreshold = DUST_ATTACK_THRESHOLD_SATS; - private File hwi; private int enumerateHwPeriod = ENUMERATE_HW_PERIOD_SECS; private QRDensity qrDensity; private Boolean hdCapture; @@ -371,15 +370,6 @@ public class Config { return dustAttackThreshold; } - public File getHwi() { - return hwi; - } - - public void setHwi(File hwi) { - this.hwi = hwi; - flush(); - } - public int getEnumerateHwPeriod() { return enumerateHwPeriod; }