1 { config, lib, pkgs, ... }:
7 enabled = elem "displaylink" config.services.xserver.videoDrivers;
9 evdi = config.boot.kernelPackages.evdi;
11 displaylink = pkgs.displaylink.override {
19 config = mkIf enabled {
21 boot.extraModulePackages = [ evdi ];
22 boot.kernelModules = [ "evdi" ];
24 environment.etc."X11/xorg.conf.d/40-displaylink.conf".text = ''
26 Identifier "DisplayLink"
29 Option "TearFree" "true"
30 Option "AccelMethod" "none"
34 # make the device available
35 services.xserver.displayManager.sessionCommands = ''
36 ${lib.getBin pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource 1 0
39 # Those are taken from displaylink-installer.sh and from Arch Linux AUR package.
41 services.udev.packages = [ displaylink ];
43 powerManagement.powerDownCommands = ''
44 #flush any bytes in pipe
45 while read -n 1 -t 1 SUSPEND_RESULT < /tmp/PmMessagesPort_out; do : ; done;
47 #suspend DisplayLinkManager
48 echo "S" > /tmp/PmMessagesPort_in
50 #wait until suspend of DisplayLinkManager finish
51 if [ -f /tmp/PmMessagesPort_out ]; then
52 #wait until suspend of DisplayLinkManager finish
53 read -n 1 -t 10 SUSPEND_RESULT < /tmp/PmMessagesPort_out
57 powerManagement.resumeCommands = ''
58 #resume DisplayLinkManager
59 echo "R" > /tmp/PmMessagesPort_in
62 systemd.services.dlm = {
63 description = "DisplayLink Manager Service";
64 after = [ "display-manager.service" ];
65 conflicts = [ "getty@tty7.service" ];
68 ExecStart = "${displaylink}/bin/DisplayLinkManager";
71 LogsDirectory = "displaylink";