1 { config, lib, pkgs, ... }:
4 enabled = lib.elem "displaylink" config.services.xserver.videoDrivers;
6 evdi = config.boot.kernelPackages.evdi;
8 displaylink = pkgs.displaylink.override {
16 config = lib.mkIf enabled {
18 boot.extraModulePackages = [ evdi ];
19 boot.kernelModules = [ "evdi" ];
21 environment.etc."X11/xorg.conf.d/40-displaylink.conf".text = ''
23 Identifier "DisplayLink"
26 Option "TearFree" "true"
27 Option "AccelMethod" "none"
31 # make the device available
32 services.xserver.displayManager.sessionCommands = ''
33 ${lib.getBin pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource 1 0
36 # Those are taken from displaylink-installer.sh and from Arch Linux AUR package.
38 services.udev.packages = [ displaylink ];
40 powerManagement.powerDownCommands = ''
41 #flush any bytes in pipe
42 while read -n 1 -t 1 SUSPEND_RESULT < /tmp/PmMessagesPort_out; do : ; done;
44 #suspend DisplayLinkManager
45 echo "S" > /tmp/PmMessagesPort_in
47 #wait until suspend of DisplayLinkManager finish
48 if [ -f /tmp/PmMessagesPort_out ]; then
49 #wait until suspend of DisplayLinkManager finish
50 read -n 1 -t 10 SUSPEND_RESULT < /tmp/PmMessagesPort_out
54 powerManagement.resumeCommands = ''
55 #resume DisplayLinkManager
56 echo "R" > /tmp/PmMessagesPort_in
59 systemd.services.dlm = {
60 description = "DisplayLink Manager Service";
61 after = [ "display-manager.service" ];
62 conflicts = [ "getty@tty7.service" ];
65 ExecStart = "${displaylink}/bin/DisplayLinkManager";
68 LogsDirectory = "displaylink";