USB mouse reconnects constantly with spamming on console

BTW "awk -F: '/mouse/i ..." doesn't work with my FreeBSD's awk.
Anyway I found a little bit better approach:
1. edit /etc/devd.conf
Code:
...
notify 100 {
        match "system"          "USB";
        match "subsystem"       "DEVICE";
        match "type"            "ATTACH";
        match "vendor"          "0x046d";                 #<- edit according to
        match "product"         "0xc077";                 #your needs
        action "usbconfig -d $cdev power_off";
};
...

2. edit .profile
Code:
...
export UGEN=$(usbconfig | awk -F: '{ if (tolower($0) ~ /mouse.+pwr=off/) print $1 }')
...

3. edit .xinitrc
Code:
...
if [ "$UGEN" ]; then
        usbconfig -d "$UGEN" power_on
fi
...

4. I use bspwm as my main WM, so i use some scripts to manage different tasks.
One of those scripts is being called upon logout, what I've changed here -
usbconfig -d "$UGEN" power_off
Code:
#!/bin/sh

command="$1"

run() {
        if pgrep -xq "$command"; then
                bspc desktop -f "$desktop"
        else
                exec "$command"
        fi
}

case "$command" in
        librewolf)      desktop='^2'; run "$command"                                    ;;
        reload)         pkill -f barrc; bspc wm -r; pkill -SIGUSR1 sxhkd                ;;
        logout)         pkill -f barrc; bspc quit; usbconfig -d "$UGEN" power_off       ;;
        reboot)         pkill -f barrc; bspc quit; shutdown -rq now                     ;;
        poweroff)       pkill -f barrc; bspc quit; shutdown -pq now                     ;;
        *)              exit 1                                                          ;;
esac

5. And I've set /usr/sbin/usbconfig to 4554, to eliminate doas calls.
Code:
-r-sr-xr--  1 root operator   30K 19 янв.  13:32 /usr/sbin/usbconfig
 
Back
Top