Created
June 14, 2017 21:14
-
-
Save jefferymiller/9d8cae7363ee584a930b3fc5798e6592 to your computer and use it in GitHub Desktop.
displaylink 1.3.52 udev rule and helper script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2016 DisplayLink (UK) Ltd. | |
# File autogenerated by udev-installer.sh script | |
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTR{idVendor}=="17e9", IMPORT{builtin}="usb_id", ENV{DISPLAYLINK_DEVNAME}="$env{DEVNAME}", ENV{DISPLAYLINK_DEVICE_ID}="$env{ID_BUS}-$env{BUSNUM}-$env{DEVNUM}-$env{ID_SERIAL}", ENV{REMOVE_CMD}="/opt/displaylink/udev.sh $root $env{DISPLAYLINK_DEVICE_ID} $env{DISPLAYLINK_DEVNAME}" | |
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTRS{idVendor}=="17e9", ATTR{bInterfaceClass}=="ff", ATTR{bInterfaceProtocol}=="03", IMPORT{parent}="DISPLAYLINK*", RUN+="/opt/displaylink/udev.sh $root $env{DISPLAYLINK_DEVICE_ID} $env{DISPLAYLINK_DEVNAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright (c) 2016 DisplayLink (UK) Ltd. | |
# File autogenerated by udev-installer.sh script | |
get_displaylink_dev_count() | |
{ | |
cat /sys/bus/usb/devices/*/idVendor | grep 17e9 | wc -l | |
} | |
get_displaylink_symlink_count() | |
{ | |
root=$1 | |
if [ ! -d "$root/displaylink/by-id" ]; then | |
echo "0" | |
return | |
fi | |
for f in $(find $root/displaylink/by-id -type l -exec realpath {} \; 2> /dev/null); do | |
test -c $f && echo $f; | |
done | wc -l | |
} | |
start_displaylink() | |
{ | |
if [ "$(get_displaylink_dev_count)" != "0" ]; then | |
start_service | |
fi | |
} | |
stop_displaylink() | |
{ | |
root=$1 | |
if [ "$(get_displaylink_symlink_count $root)" = "0" ]; then | |
stop_service | |
fi | |
} | |
create_displaylink_symlink() | |
{ | |
root=$1 | |
device_id=$2 | |
devnode=$3 | |
mkdir -p $root/displaylink/by-id | |
ln -sf $devnode $root/displaylink/by-id/$device_id | |
} | |
unlink_displaylink_symlink() | |
{ | |
root=$1 | |
device_id=$2 | |
unlink $root/displaylink/by-id/$device_id 2> /dev/null | |
(cd $root; rmdir -p --ignore-fail-on-non-empty displaylink/by-id) | |
} | |
main() | |
{ | |
action=$1 | |
root=$2 | |
device_id=$3 | |
devnode=$4 | |
if [ "$action" = "add" ]; then | |
create_displaylink_symlink $root $device_id $devnode | |
start_displaylink | |
elif [ "$action" = "remove" ]; then | |
unlink_displaylink_symlink "$root" "$device_id" | |
stop_displaylink "$root" | |
fi | |
} | |
start_service() | |
{ | |
start dlm | |
} | |
stop_service() | |
{ | |
stop dlm | |
} | |
main $ACTION $1 $2 $3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment