-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.nix
52 lines (46 loc) · 1.24 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.thinkpad-dock;
acpiEvent = pkgs.callPackage ./acpi_event.nix {
inherit (cfg) environment dockEvent undockEvent;
};
in {
options.hardware.thinkpad-dock = {
enable = mkEnableOption "Register ThinkPad ACPI event handler for dock";
environment = mkOption {
default = "";
example = ''
export DISPLAY=:0
export XAUTHORITY=/home/user/.Xauthority
'';
type = types.str;
description = "Bash script for environment variables.";
};
dockEvent = mkOption {
default = "";
example = ''
$\{pkgs.xorg.xrandr\}/bin/xrandr --output DP-2-1 --mode 1920x1080 --right-of eDP-1
'';
type = types.str;
description = "Bash script to be executed on docking.";
};
undockEvent = mkOption {
default = "";
example = ''
$\{pkgs.xorg.xrandr\}/bin/xrandr --output DP-2-1 --off
'';
type = types.str;
description = "Bash script to be executed on undocking.";
};
};
config = mkIf cfg.enable {
services.acpid = {
enable = true;
handlers.thinkpadDock = {
event = "ibm/hotkey";
action = builtins.readFile acpiEvent;
};
};
};
}