summaryrefslogtreecommitdiffstats
path: root/tv/3modules/lidControl.nix
diff options
context:
space:
mode:
authorlassulus <git@lassul.us>2023-09-14 12:18:45 +0200
committerlassulus <git@lassul.us>2023-09-14 12:18:45 +0200
commit4820fc27cdc44a12b57d52c5fb7a932407d765a1 (patch)
tree3a31e612fe6141c1079a7fee37db1bb80486ac33 /tv/3modules/lidControl.nix
parentd5305cdab1eadfe972ae0d1adc94192bb62ca6bc (diff)
parent1e03553fe6058d06c00a6c92e0ef486282057595 (diff)
Merge remote-tracking branch 'ni/master'
Diffstat (limited to 'tv/3modules/lidControl.nix')
-rw-r--r--tv/3modules/lidControl.nix45
1 files changed, 0 insertions, 45 deletions
diff --git a/tv/3modules/lidControl.nix b/tv/3modules/lidControl.nix
deleted file mode 100644
index 6a48da18..00000000
--- a/tv/3modules/lidControl.nix
+++ /dev/null
@@ -1,45 +0,0 @@
-with import ./lib;
-{ config, pkgs, ... }: {
- options = {
- tv.lidControl.enable = mkEnableOption "tv.lidControl";
- };
- config = let
- cfg = config.tv.lidControl;
- in mkIf cfg.enable {
- services.acpid.enable = true;
- services.acpid.lidEventCommands = /* sh */ ''
- set -- $1
-
- # usage: vt_is_xserver NUMBER
- vt_is_xserver() {
- ${pkgs.iproute}/bin/ss -lp src unix:/tmp/.X11-unix/X* |
- ${pkgs.gnused}/bin/sed -n 's|.*/tmp/.X11-unix/X\([0-9]\+\)\>.*|\1|p' |
- ${pkgs.gnugrep}/bin/grep -Fqx "$1"
- }
-
- console=$(${pkgs.kbd}/bin/fgconsole)
-
- if vt_is_xserver "$console"; then
- # usage: run_on_display COMMAND [ARG...]
- run_on_display() {
- owner=$(${pkgs.coreutils}/bin/stat -c %u /tmp/.X11-unix/X$console)
- ${pkgs.systemd}/bin/systemd-run -GPq \
- -E DISPLAY=:$console \
- --uid=$owner \
- "$@"
- }
- case $3 in
- open)
- run_on_display ${pkgs.xorg.xset}/bin/xset dpms force on
- ;;
- close)
- run_on_display ${pkgs.xorg.xset}/bin/xset dpms force off
- ;;
- esac
- fi
- '';
- services.logind.lidSwitch = "ignore";
- services.logind.lidSwitchDocked = "ignore";
- services.logind.lidSwitchExternalPower = "ignore";
- };
-}