summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/ejabberd/default.nix11
-rw-r--r--modules/lid-handler.nix (renamed from modules/lidControl.nix)29
-rw-r--r--modules/org.freedesktop.machine1.host-shell.nix28
3 files changed, 48 insertions, 20 deletions
diff --git a/modules/ejabberd/default.nix b/modules/ejabberd/default.nix
index f2da590..9607741 100644
--- a/modules/ejabberd/default.nix
+++ b/modules/ejabberd/default.nix
@@ -142,6 +142,17 @@ in {
ExecStartPre = [
"${pkgs.coreutils}/bin/ln -s \${CREDENTIALS_DIRECTORY} /tmp/credentials"
"${gen-dhparam} ${cfg.stateDir}/dhfile"
+ (pkgs.writeDash "ejabberd-ensure-PREVIOUS.LOG" ''
+ set -efu
+ cd ${cfg.stateDir}
+ if ! test -e PREVIOUS.LOG; then
+ if test -f LATEST.LOG; then
+ ${pkgs.coreutils}/bin/ln LATEST.LOG PREVIOUS.LOG
+ else
+ ${pkgs.coreutils}/bin/touch PREVIOUS.LOG
+ fi
+ fi
+ '')
];
ExecStart = "${cfg.pkgs.ejabberd}/bin/ejabberdctl foreground";
ExecStop = [
diff --git a/modules/lidControl.nix b/modules/lid-handler.nix
index a35e178..d89aced 100644
--- a/modules/lidControl.nix
+++ b/modules/lid-handler.nix
@@ -1,13 +1,13 @@
{ config, lib, pkgs, ... }: {
options = {
- tv.lidControl.enable = lib.mkEnableOption "tv.lidControl";
+ hrm.lid-handler.enable = lib.mkEnableOption "hrm.lid-handler";
};
config = let
- cfg = config.tv.lidControl;
+ cfg = config.hrm.lid-handler;
in lib.mkIf cfg.enable {
services.acpid.enable = true;
services.acpid.lidEventCommands = /* sh */ ''
- set -- $1
+ lid_state=$(${pkgs.gawk}/bin/awk '{print$2}' /proc/acpi/button/lid/*/state)
# usage: vt_is_xserver NUMBER
vt_is_xserver() {
@@ -27,18 +27,31 @@
--uid=$owner \
"$@"
}
- case $3 in
+ case $lid_state in
open)
run_on_display ${pkgs.xorg.xset}/bin/xset dpms force on
;;
- close)
+ closed)
run_on_display ${pkgs.xorg.xset}/bin/xset dpms force off
;;
esac
+ else
+ case $lid_state in
+ open)
+ ${pkgs.brightnessctl}/bin/brightnessctl --restore >/dev/null 2>&1
+ ;;
+ closed)
+ brightness=$(${pkgs.brightnessctl}/bin/brightnessctl --quiet get)
+ if test "$brightness" -gt 0; then
+ ${pkgs.brightnessctl}/bin/brightnessctl --save >/dev/null 2>&1
+ ${pkgs.brightnessctl}/bin/brightnessctl --quiet set 0
+ fi
+ ;;
+ esac
fi
'';
- services.logind.lidSwitch = "ignore";
- services.logind.lidSwitchDocked = "ignore";
- services.logind.lidSwitchExternalPower = "ignore";
+ services.logind.settings.Login.HandleLidSwitch = "ignore";
+ services.logind.settings.Login.HandleLidSwitchDocked = "ignore";
+ services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore";
};
}
diff --git a/modules/org.freedesktop.machine1.host-shell.nix b/modules/org.freedesktop.machine1.host-shell.nix
index 73825a5..3491453 100644
--- a/modules/org.freedesktop.machine1.host-shell.nix
+++ b/modules/org.freedesktop.machine1.host-shell.nix
@@ -1,4 +1,4 @@
-{ config, lib, mylib, ... }: {
+{ config, lib, mylib, pkgs, ... }: {
options.org.freedesktop.machine1.host-shell.access = lib.mkOption {
default = {};
type =
@@ -12,17 +12,21 @@
(name: value: [name] ++ lib.attrNames value)
x)));
};
- config.security.polkit.extraConfig = let
+ config.environment.etc."polkit-1/rules.d/30-hrm-access.rules" = let
cfg = config.org.freedesktop.machine1.host-shell;
+ in {
enable = cfg.access != {};
- in lib.optionalString enable /* js */ ''
- polkit.addRule(function () {
- const access = ${builtins.toJSON cfg.access};
- return function(action, subject) {
- if (action.id === "org.freedesktop.machine1.host-shell"
- && (access[subject.user]||{})[action.lookup("user")])
- return polkit.Result.YES;
- }
- }());
- '';
+ source = pkgs.writePolkitRules "30-hrm-access.rules" /* js */ ''
+ polkit.addRule(function () {
+ const access = ${builtins.toJSON cfg.access};
+ return function (action, subject) {
+ if (action.id === "org.freedesktop.machine1.host-shell") {
+ if ((access[subject.user]||{})[action.lookup("user")]) {
+ return polkit.Result.YES;
+ }
+ }
+ }
+ }());
+ '';
+ };
}