feat: work QOL features (lid turn off etc.)

This commit is contained in:
Swarsel 2024-09-04 16:16:30 +02:00
parent 23e1f73ce9
commit 74eabad262
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
12 changed files with 667 additions and 544 deletions

View file

@ -0,0 +1,26 @@
{ config, pkgs, ... }:
{
services.logind = {
lidSwitch = "suspend";
lidSwitchDocked = "ignore";
};
services.acpid = {
enable = true;
lidEventCommands =
''
export PATH=$PATH:/run/current-system/sw/bin
export WAYLAND_DISPLAY=wayland-1
export XDG_RUNTIME_DIR=/run/user/1000
export SWAYSOCK=$(ls /run/user/1000/sway-ipc.* | head -n 1)
LID_STATE=$(cat /proc/acpi/button/lid/*/state | grep -q closed && echo "closed" || echo "open")
DOCKED=$(swaymsg -t get_outputs | grep -q 'HDMI\|DP' && echo "docked" || echo "undocked")
if [ "$LID_STATE" == "closed" ] && [ "$DOCKED" == "docked" ]; then
swaymsg output eDP-2 disable
else
swaymsg output eDP-2 enable
fi
'';
};
}