Control: tags -1 patch thanks! Hi,
the attached draft (non-java-programmer) patch implements the feature per user based. Best regards, Andi
>From ed0ec33096a94b183f235e0c3da3426faea9203d Mon Sep 17 00:00:00 2001 From: "Andreas B. Mundt" <a...@debian.org> Date: Sun, 24 Sep 2023 18:36:57 +0200 Subject: [PATCH] Add 'ignore and remember' button and skip check eventually. --- .../fixes/Enhance-permission-handling.patch | 2 +- debian/permission-checker/arduinopc.java | 26 ++++++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/debian/patches/fixes/Enhance-permission-handling.patch b/debian/patches/fixes/Enhance-permission-handling.patch index 59aef01..0e57548 100644 --- a/debian/patches/fixes/Enhance-permission-handling.patch +++ b/debian/patches/fixes/Enhance-permission-handling.patch @@ -17,7 +17,7 @@ index f70c650..e31ab34 100755 -APPDIR="$(dirname -- "$(readlink -f -- "${0}")" )" +APPDIR=/usr/share/arduino + -+if [[ `id -u` -ne 0 ]]; then ++if [[ `id -u` -ne 0 ]] && [[ ! -e ~/.arduino15/ignore-dialout-group ]] ; then +# for group in dialout tty; do + for group in dialout; do + if ! groups | grep -q "\b$group\b"; then diff --git a/debian/permission-checker/arduinopc.java b/debian/permission-checker/arduinopc.java index ad891c3..d50583a 100644 --- a/debian/permission-checker/arduinopc.java +++ b/debian/permission-checker/arduinopc.java @@ -29,6 +29,8 @@ import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.SwingUtilities; +import java.io.File; +import java.io.IOException; public class arduinopc extends JFrame { @@ -43,7 +45,7 @@ public class arduinopc extends JFrame { // panel.setLayout(null); - JButton ignoreButton = new JButton("Ignore"); + JButton ignoreButton = new JButton("Ignore (for now)"); //ignoreButton.setBounds(50, 60, 80, 30); ignoreButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { @@ -51,6 +53,23 @@ public class arduinopc extends JFrame { } }); + JButton ignoreRememberButton = new JButton("Ignore (remember)"); + ignoreRememberButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + String stampFilePath = System.getProperty("user.home") + + "/.arduino15/ignore-dialout-group"; + try { + File stamp = new File(stampFilePath); + stamp.createNewFile(); + System.out.printf("Created '%s'.\n", stampFilePath); + } catch(IOException e) { + System.out.printf("Creating '%s' failed.\n", stampFilePath); + e.printStackTrace(); + } + System.exit(0); + } + }); + JButton addButton = new JButton("Add"); //addButton.setBounds(150, 60, 80, 30); addButton.addActionListener(new ActionListener() { @@ -61,7 +80,7 @@ public class arduinopc extends JFrame { //JLabel label = new JLabel("<html>You need to be a member of the \"dailout\"<br>group to upload code to an Arduino<br>microcontroller over the USB or<br>serial ports.<br></html>"); //label.setBounds(10,10,300,100); - panel.add(new JLabel("<html>You need to be added to the \"dialout\"<br>group to upload code to an Arduino<br>microcontroller over the USB or<br>serial ports.<br><br>Click \"Add\" below to be added.<br><br>You must log out and log in again<br>before any group changes<br>will take effect.</html>", JLabel.CENTER)); + panel.add(new JLabel("<html>You need to be added to the \"dialout\" group to upload code<br>to an Arduino microcontroller over the USB or serial ports.<br><br>Click \"Add\" below to be added. You must log out and log in<br>again before any group changes will take effect.<br><br>If access is provided by other means, click \"Ignore\".<br><br></html>", JLabel.CENTER)); //label.setFont(new Font("Georgia", Font.PLAIN, 14)); //label.setForeground(new Color(50, 50, 25)); //label.setOpaque(true); @@ -69,12 +88,13 @@ public class arduinopc extends JFrame { //panel.add(label);//, BorderLayout.CENTER); panel.add(ignoreButton); + panel.add(ignoreRememberButton); panel.add(addButton); setTitle("Arduino Permission Checker"); - setSize(300, 250); + setSize(380, 220); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); } -- 2.30.2