From 093802343bb5963cc4b3084ecd79c5b86392e360 Mon Sep 17 00:00:00 2001
From: "Sanford Rockowitz (/shared/home/rock/dot_gitconfig)"
 <rockowitz@minsoft.com>
Date: Mon, 29 Jul 2024 13:07:33 -0400
Subject: [PATCH] do not install data/usr/lib/udev/rules.d/60-ddcutil-usb.rules

This file has use only for very uncommon case where a monitor
uses USB to communicate with a display's Virtual Control Panel.

The chkusbmon call has been seen to cause system errors in some
ill-defined cases.

Addresses issues #405, #428, #437
---
 data/Makefile.am                               | 6 ++----
 data/usr/lib/udev/rules.d/60-ddcutil-usb.rules | 9 ---------
 2 files changed, 2 insertions(+), 13 deletions(-)
 delete mode 100644 data/usr/lib/udev/rules.d/60-ddcutil-usb.rules

diff --git a/data/Makefile.am b/data/Makefile.am
index ec3b1ad71..dcfe45951 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,6 +1,6 @@
 # File data/Makefile.am
 
-# Copyright (C) 2016-2023 Sanford Rockowitz <rockowitz@minsoft.com>
+# Copyright (C) 2016-2024 Sanford Rockowitz <rockowitz@minsoft.com>
 # SPDX-License-Identifier: GPL-2.0-or-later
 
 # The proper location for pkgconfig files is ambiguous, and the 
@@ -24,7 +24,6 @@
 # to be kept in sync with where autotools puts the files.
 
 
-
 resfiles = \
 	etc/modprobe.d/nvidia-i2c.conf \
 	etc/udev/rules.d/60-ddcutil-i2c.rules \
@@ -32,8 +31,7 @@ resfiles = \
 	etc/X11/xorg.conf.d/90-nvidia-i2c.conf
 
 rulesfiles = \
-	usr/lib/udev/rules.d/60-ddcutil-i2c.rules \
-	usr/lib/udev/rules.d/60-ddcutil-usb.rules
+	usr/lib/udev/rules.d/60-ddcutil-i2c.rules 
 
 distributed_modulesfiles = \
     usr/lib/modules-load.d/ddcutil.conf
diff --git a/data/usr/lib/udev/rules.d/60-ddcutil-usb.rules b/data/usr/lib/udev/rules.d/60-ddcutil-usb.rules
deleted file mode 100644
index 11bce3ecf..000000000
--- a/data/usr/lib/udev/rules.d/60-ddcutil-usb.rules
+++ /dev/null
@@ -1,9 +0,0 @@
-# Rules for USB attached monitors, which are categorized as User Interface Devices. 
-
-# Use ddcutil to check if a USB Human Interface Device appears to be a monitor.
-# If so, grant the current user access to it.
-# Note this rule may  have to be adjusted to reflect the actual path where ddcutil is installed. 
-# The -v option produces informational messages.  These are lost when the rule is normally executed 
-# by udev, but can be helpful when rules are tested using the "udevadm test" command. 
-SUBSYSTEM=="usbmisc",  KERNEL=="hiddev*", PROGRAM="/usr/bin/ddcutil chkusbmon $env{DEVNAME} -v", TAG+="uaccess"
-
From 5a3b257f783a14e1da80ed8e0101060e93027d0d Mon Sep 17 00:00:00 2001
From: "Sanford Rockowitz (/shared/home/rock/dot_gitconfig)"
 <rockowitz@minsoft.com>
Date: Mon, 12 Aug 2024 17:24:23 -0400
Subject: [PATCH] clear out old installed rules files in /usr/lib/udev/rules.d

addresses leftover 60-ddcutil-usb.rules
---
 data/Makefile.am | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/data/Makefile.am b/data/Makefile.am
index dcfe45951..0bddb5897 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -52,6 +52,8 @@ pkgconfigdir = ${libdir}/pkgconfig
    
 # Target directory (/usr/local/share/ddcutil/data or /usr/share/ddcutil/data):
 ddcutildir = $(datadir)/ddcutil/data
+resdir     = $(datadir)/ddcutil/data 
+
 # Causes files (w/o directory structure) to be installed in target directory:
 
 if !INSTALL_LIB_ONLY_COND
@@ -108,15 +110,25 @@ install-data-local:
 	@echo "udevdir:        ${udevdir}"
 
 # @xxx@ names are not defined, names with $() are 
+
+# use "find ..." instead of "rm -f" as latter tries to delete directory as well
+# rm -f ${DESTDIR}${resdir}/45-ddcutil*
+# rm -f ${DESTDIR}${rulesdir}/60-ddcutil.rules
+# rm -f ${DESTDIR}${rulesdir}/60-ddcutil-usb.rules
+          
 install-data-hook:
 	@echo "(data/install-data-hook)===> Executing rule: install-data-hook"
-if !INSTALL_LIB_ONLY_COND
-	sed  -i "s|/usr|${prefix}|" ${DESTDIR}${rulesdir}/60-ddcutil-usb.rules 
-endif
+# if !INSTALL_LIB_ONLY_COND
+# 	sed  -i "s|/usr|${prefix}|" ${DESTDIR}${rulesdir}/60-ddcutil-usb.rules 
+# endif
 	@echo "Clear out files possibly left over from earlier installation"
-	rm -f ${DESTDIR}${resdir}/45-ddcutil*
-	rm -f ${DESTDIR}${rulesdir}/60-ddcutil.rules
+	find ${DESTDIR}${resdir} -name "45-ddcutil*" -delete
+	find ${DESTDIR}${resdir} -name "60-ddcutil.rules" -delete
+	
 
 uninstall-hook:
 	@echo "(data/uninstall-hook)===> Executing rule: uninstall-hook"
+	@echo "Clear out files possibly left over from earlier installation"
+	find ${DESTDIR}${resdir} -name "45-ddcutil.rules" -delete
+	find ${DESTDIR}${rulesdir} -name "60-ddcutil-usb.rules" -delete
 
