2015-08-23 00:48:35 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
# stuff for the main laptop
|
|
|
|
# this is pretty much nice-to-have and does
|
|
|
|
# not fit into base-gui
|
2016-02-11 16:06:50 +00:00
|
|
|
# TODO split generic desktop stuff and laptop-specifics like lidswitching
|
2015-08-23 00:48:35 +00:00
|
|
|
|
2016-10-20 18:54:38 +00:00
|
|
|
with import <stockholm/lib>;
|
2016-08-02 13:40:41 +00:00
|
|
|
let
|
|
|
|
window-manager = "awesome";
|
|
|
|
user = config.krebs.build.user.name;
|
|
|
|
in {
|
2015-12-13 12:52:15 +00:00
|
|
|
imports = [
|
2017-05-12 09:29:46 +00:00
|
|
|
./gui/base.nix
|
2015-12-13 12:52:15 +00:00
|
|
|
./fetchWallpaper.nix
|
2015-12-16 11:29:24 +00:00
|
|
|
./zsh-user.nix
|
2017-03-01 14:50:58 +00:00
|
|
|
./tools/core.nix
|
|
|
|
./tools/core-gui.nix
|
2018-04-04 12:44:06 +00:00
|
|
|
./gui/automatic-diskmount.nix
|
2015-12-13 12:52:15 +00:00
|
|
|
];
|
2016-02-18 07:37:40 +00:00
|
|
|
|
|
|
|
users.users.${config.krebs.build.user.name}.extraGroups = [ "dialout" ];
|
|
|
|
|
2016-08-02 09:50:16 +00:00
|
|
|
krebs.power-action = let
|
2016-08-02 13:40:41 +00:00
|
|
|
#speak = "XDG_RUNTIME_DIR=/run/user/$(id -u) ${pkgs.espeak}/bin/espeak"; # when run as user
|
|
|
|
speak = "${pkgs.espeak}/bin/espeak"; # systemwide pulse
|
|
|
|
whisper = text: ''${speak} -v +whisper -s 110 "${text}"'';
|
|
|
|
|
|
|
|
note = pkgs.writeDash "note-as-user" ''
|
|
|
|
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(${pkgs.procps}/bin/pgrep -u ${user} ${window-manager})/environ)"
|
|
|
|
${pkgs.libnotify}/bin/notify-send "$@";
|
|
|
|
'';
|
2016-08-02 09:50:16 +00:00
|
|
|
in {
|
|
|
|
enable = true;
|
2016-08-02 13:40:41 +00:00
|
|
|
inherit user;
|
2016-08-02 09:50:16 +00:00
|
|
|
plans.low-battery = {
|
|
|
|
upperLimit = 25;
|
|
|
|
lowerLimit = 15;
|
|
|
|
charging = false;
|
2016-08-02 13:40:41 +00:00
|
|
|
action = pkgs.writeDash "low-speak" ''
|
|
|
|
${whisper "power level low, please plug me in"}
|
|
|
|
'';
|
2016-08-02 09:50:16 +00:00
|
|
|
};
|
|
|
|
plans.nag-harder = {
|
|
|
|
upperLimit = 15;
|
|
|
|
lowerLimit = 5;
|
2016-08-02 13:40:41 +00:00
|
|
|
charging = false;
|
2016-08-02 09:50:16 +00:00
|
|
|
action = pkgs.writeDash "crit-speak" ''
|
2016-08-02 13:40:41 +00:00
|
|
|
${note} Battery -u critical -t 60000 "Power level critical, do something!"
|
2016-08-02 09:50:16 +00:00
|
|
|
${whisper "Power level critical, do something"}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
plans.last-chance = {
|
|
|
|
upperLimit = 5;
|
|
|
|
lowerLimit = 3;
|
|
|
|
charging = false;
|
|
|
|
action = pkgs.writeDash "suspend-wrapper" ''
|
|
|
|
${note} Battery -u crit "You've had your chance, suspend in 5 seconds"
|
|
|
|
${concatMapStringsSep "\n" (i: ''
|
|
|
|
${note} -u critical -t 1000 ${toString i}
|
|
|
|
${speak} ${toString i} &
|
|
|
|
sleep 1
|
|
|
|
'')
|
|
|
|
[ 5 4 3 2 1 ]}
|
2017-03-01 14:50:58 +00:00
|
|
|
/var/run/wrappers/bin/sudo ${pkgs.systemd}/bin/systemctl suspend
|
2016-08-02 09:50:16 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2016-08-02 13:40:41 +00:00
|
|
|
security.sudo.extraConfig = "${config.krebs.power-action.user} ALL= (root) NOPASSWD: ${pkgs.systemd}/bin/systemctl suspend";
|
2015-08-23 00:48:35 +00:00
|
|
|
|
|
|
|
services.redshift = {
|
|
|
|
enable = true;
|
|
|
|
latitude = "48.7";
|
|
|
|
longitude = "9.1";
|
|
|
|
};
|
2016-12-24 22:43:06 +00:00
|
|
|
systemd.services.look-up = {
|
|
|
|
startAt = "*:30";
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart= pkgs.writeDash "look-up" ''
|
|
|
|
set -x
|
|
|
|
eval "export '$(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(${pkgs.procps}/bin/pgrep -u ${user} ${window-manager})/environ)'"
|
|
|
|
${pkgs.libnotify}/bin/notify-send -u critical -t 9999999 'look up once in a while'
|
|
|
|
'';
|
|
|
|
User = user;
|
|
|
|
};
|
|
|
|
};
|
2015-08-23 00:48:35 +00:00
|
|
|
}
|