diff options
author | Nikolay Amiantov <ab@fmap.me> | 2016-08-27 19:55:56 +0300 |
---|---|---|
committer | Nikolay Amiantov <ab@fmap.me> | 2016-09-13 00:30:35 +0300 |
commit | bc493ccfcc9e1308b32eabe335b8ef31626a949e (patch) | |
tree | 7c37ccb13e7fff89f4d6e0a303c5028d369ede88 /nixos/modules/hardware | |
parent | fbf6a97b04bba5f36a3caf26f54034324397f15a (diff) |
displaylink service: init
Diffstat (limited to 'nixos/modules/hardware')
-rw-r--r-- | nixos/modules/hardware/video/displaylink.nix | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/nixos/modules/hardware/video/displaylink.nix b/nixos/modules/hardware/video/displaylink.nix new file mode 100644 index 0000000000000..2a9382f39410c --- /dev/null +++ b/nixos/modules/hardware/video/displaylink.nix @@ -0,0 +1,61 @@ +{ config, lib, ... }: + +with lib; + +let + + enabled = elem "displaylink" config.services.xserver.videoDrivers; + + displaylink = config.boot.kernelPackages.displaylink; + +in + +{ + + config = mkIf enabled { + + boot.extraModulePackages = [ displaylink ]; + + boot.kernelModules = [ "evdi" ]; + + # Those are taken from displaylink-installer.sh and from Arch Linux AUR package. + + services.udev.extraRules = '' + ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="17e9", ATTR{bNumInterfaces}=="*5", TAG+="uaccess" + ''; + + 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 + read -n 1 -t 10 SUSPEND_RESULT < /tmp/PmMessagesPort_out + ''; + + powerManagement.resumeCommands = '' + #resume DisplayLinkManager + echo "R" > /tmp/PmMessagesPort_in + ''; + + systemd.services.displaylink = { + description = "DisplayLink Manager Service"; + after = [ "display-manager.service" ]; + wantedBy = [ "graphical.target" ]; + + serviceConfig = { + ExecStart = "${displaylink}/bin/DisplayLinkManager"; + Restart = "always"; + RestartSec = 5; + }; + + preStart = '' + mkdir -p /var/log/displaylink + ''; + }; + + }; + +} |