From 861e667570aced1774bf2abab0e8c8f18a27da8a Mon Sep 17 00:00:00 2001 From: Matti Kaupenjohann Date: Thu, 18 Apr 2024 21:13:12 +0200 Subject: [PATCH] Feature: Improve admin needed error msg - Add method isInElevatedGroup - check if the linux user is in plugdev - add logic for admin error check --- OpenBCI_GUI/Extras.pde | 28 ++++++++++++++++++++++++++++ OpenBCI_GUI/OpenBCI_GUI.pde | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/OpenBCI_GUI/Extras.pde b/OpenBCI_GUI/Extras.pde index b6e50c341..c41cfb8a9 100644 --- a/OpenBCI_GUI/Extras.pde +++ b/OpenBCI_GUI/Extras.pde @@ -158,6 +158,34 @@ public boolean isElevationNeeded(String path) { } return result; } +/** +* Determines if user is in elevated group (plugdev). +* +* @return true if user is in group plugdev, false otherwise. + */ +public boolean isInElevatedGroup() { + boolean result = true; + if (isLinux()) { + try { + String command = "groups"; + Process p = Runtime.getRuntime().exec(command); + p.waitFor(); + InputStream stdIn = p.getInputStream(); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stdIn)); + String[] values = bufferedReader.readLine().split(" "); + for (int idx=0; idx