dotfiles/hm/brightness/default.nix

58 lines
1.6 KiB
Nix

# Light theme during the day, dark theme during the night (not automatic)
{
pkgs,
lib,
config,
...
}:
let
phases = [
{
command = "jour";
specialisation = null;
}
{
command = "crepuscule";
specialisation = "dark";
}
{
command = "nuit";
specialisation = "dark";
}
];
mod = config.wayland.windowManager.sway.config.modifier;
in
{
config = {
home.packages =
(map (
phase:
(pkgs.writeShellScriptBin phase.command ''
switch="/nix/var/nix/profiles/system${
lib.strings.optionalString (phase.specialisation != null) "/specialisation/${phase.specialisation}"
}/bin/switch-to-configuration"
if [ -x "$switch" ]
then
sudo "$switch" test &
fi
${builtins.getAttr phase.command config.frogeye.desktop.phasesCommands}
wait
# Boot does not have to be set immediately and can result to lock issues with test,
# so it is run at the end
if [ -x "$switch" ]
then
sudo "$switch" boot
fi
'')
) phases)
++ (with pkgs; [
brightnessctl
]);
wayland.windowManager.sway.config.keybindings = lib.mkOptionDefault {
XF86MonBrightnessUp = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
XF86MonBrightnessDown = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
"${mod}+F6" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 1%-";
"${mod}+F7" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +1%";
};
};
}