2017-05-01 14:23:41 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2016-08-27 18:55:56 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
enabled = elem "displaylink" config.services.xserver.videoDrivers;
|
|
|
|
|
2017-05-01 14:23:41 +02:00
|
|
|
evdi = config.boot.kernelPackages.evdi;
|
|
|
|
|
|
|
|
displaylink = pkgs.displaylink.override {
|
|
|
|
inherit evdi;
|
|
|
|
};
|
2016-08-27 18:55:56 +02:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
config = mkIf enabled {
|
|
|
|
|
2017-05-01 14:23:41 +02:00
|
|
|
boot.extraModulePackages = [ evdi ];
|
2019-11-01 05:48:13 +01:00
|
|
|
boot.kernelModules = [ "evdi" ];
|
|
|
|
|
|
|
|
environment.etc."X11/xorg.conf.d/40-displaylink.conf".text = ''
|
|
|
|
Section "OutputClass"
|
|
|
|
Identifier "DisplayLink"
|
|
|
|
MatchDriver "evdi"
|
|
|
|
Driver "modesetting"
|
|
|
|
Option "AccelMethod" "none"
|
|
|
|
EndSection
|
|
|
|
'';
|
|
|
|
|
|
|
|
# make the device available
|
|
|
|
services.xserver.displayManager.sessionCommands = ''
|
|
|
|
${lib.getBin pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource 1 0
|
|
|
|
'';
|
2016-08-27 18:55:56 +02:00
|
|
|
|
|
|
|
# Those are taken from displaylink-installer.sh and from Arch Linux AUR package.
|
|
|
|
|
2017-05-01 14:23:41 +02:00
|
|
|
services.udev.packages = [ displaylink ];
|
2016-08-27 18:55:56 +02:00
|
|
|
|
|
|
|
powerManagement.powerDownCommands = ''
|
|
|
|
#flush any bytes in pipe
|
|
|
|
while read -n 1 -t 1 SUSPEND_RESULT < /tmp/PmMessagesPort_out; do : ; done;
|
|
|
|
|
|
|
|
#suspend DisplayLinkManager
|
|
|
|
echo "S" > /tmp/PmMessagesPort_in
|
|
|
|
|
|
|
|
#wait until suspend of DisplayLinkManager finish
|
2017-05-01 14:23:41 +02:00
|
|
|
if [ -f /tmp/PmMessagesPort_out ]; then
|
|
|
|
#wait until suspend of DisplayLinkManager finish
|
|
|
|
read -n 1 -t 10 SUSPEND_RESULT < /tmp/PmMessagesPort_out
|
|
|
|
fi
|
2016-08-27 18:55:56 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
powerManagement.resumeCommands = ''
|
|
|
|
#resume DisplayLinkManager
|
|
|
|
echo "R" > /tmp/PmMessagesPort_in
|
|
|
|
'';
|
|
|
|
|
2017-05-01 14:23:41 +02:00
|
|
|
systemd.services.dlm = {
|
2016-08-27 18:55:56 +02:00
|
|
|
description = "DisplayLink Manager Service";
|
|
|
|
after = [ "display-manager.service" ];
|
2017-05-01 14:23:41 +02:00
|
|
|
conflicts = [ "getty@tty7.service" ];
|
2016-08-27 18:55:56 +02:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${displaylink}/bin/DisplayLinkManager";
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 5;
|
2019-11-01 05:48:13 +01:00
|
|
|
LogsDirectory = "displaylink";
|
2016-08-27 18:55:56 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|