Skip to content

Instantly share code, notes, and snippets.

@emilcarr
Last active June 12, 2024 12:06
Show Gist options
  • Save emilcarr/795a470feb89d3777479e11b25f2931e to your computer and use it in GitHub Desktop.
Save emilcarr/795a470feb89d3777479e11b25f2931e to your computer and use it in GitHub Desktop.
SUBSYSTEM=="i2c-dev", ACTION=="add",\
ATTR{name}=="NVIDIA i2c adapter*",\
TAG+="ddcci",\
TAG+="systemd",\
ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
[Unit]
Description=DDCCI Device auto-attachment (needed for NVIDIA)
Before=shutdown.target
Conflicts=shutdown.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo Attempting attach ddcci to %i && success=0 && i=0 && id=$(echo %i | cut -d "-" -f 2) && while ((success < 1)) && ((i++ < 5)); do /usr/bin/ddcutil getvcp 10 -b $id && { success=1 && echo ddcci 0x37 > /sys/bus/i2c/devices/%i/new_device && echo "ddcci attached to %i"; } || sleep 5; done'
Restart=no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment