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 ];
|
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" ];
|
|
|
|
path = [ pkgs.kmod ];
|
2016-08-27 18:55:56 +02:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${displaylink}/bin/DisplayLinkManager";
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = 5;
|
|
|
|
};
|
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p /var/log/displaylink
|
2017-05-01 14:23:41 +02:00
|
|
|
modprobe evdi
|
2016-08-27 18:55:56 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|