Brightness control
This commit is contained in:
@@ -40,6 +40,7 @@ in
|
||||
samfelag.modules = {
|
||||
|
||||
system.audio.enable = true;
|
||||
system.brightness.enable = true;
|
||||
system.kanata.enable = true;
|
||||
|
||||
desktop = {
|
||||
|
||||
@@ -12,6 +12,10 @@ in
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
# environment.systemPackages = with pkgs; [
|
||||
# hypridle
|
||||
# ];
|
||||
|
||||
hm.programs.hyprlock = {
|
||||
enable = true;
|
||||
settings = {
|
||||
@@ -37,8 +41,8 @@ in
|
||||
fade_on_empty = "false";
|
||||
placeholder_text = "";
|
||||
|
||||
outer_color = "rgba(${hexToRGBString config.colorScheme.palette.base02},0.9)";
|
||||
inner_color = "rgba(${hexToRGBString config.colorScheme.palette.base00},0.9)";
|
||||
outer_color = "rgba(${hexToRGBString config.colorScheme.palette.base02},1.0)";
|
||||
inner_color = "rgba(${hexToRGBString config.colorScheme.palette.base00},1.0)";
|
||||
font_color = "rgba(${hexToRGBString config.colorScheme.palette.base05},1.0)";
|
||||
|
||||
check_color = "rgba(${hexToRGBString config.colorScheme.palette.base07},1.0)";
|
||||
@@ -61,6 +65,51 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
hm.services.hypridle = {
|
||||
enable = true;
|
||||
settings = {
|
||||
general = {
|
||||
lock_cmd = "pidof hyprlock || hyprlock"; # avoid starting multiple hyprlock instances.
|
||||
before_sleep_cmd = "loginctl lock-session"; # lock before suspend.
|
||||
after_sleep_cmd = "hyprctl dispatch dpms on"; # to avoid having to press a key twice to turn on the display.
|
||||
};
|
||||
|
||||
listener = [
|
||||
{
|
||||
timeout = 90;
|
||||
on-timeout = "brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor.
|
||||
on-resume = "brightnessctl -r"; # monitor backlight restore.
|
||||
}
|
||||
|
||||
{
|
||||
timeout = 90;
|
||||
on-timeout = "brightnessctl -sd platform::kbd_backlight set 0"; # turn off keyboard backlight.
|
||||
on-resume = "brightnessctl -rd platform::kbd_backlight"; # turn on keyboard backlight.
|
||||
}
|
||||
|
||||
{
|
||||
timeout = 300; # 5min
|
||||
on-timeout = "loginctl lock-session"; # lock screen when timeout has passed
|
||||
}
|
||||
|
||||
{
|
||||
timeout = 330; # 5.5min
|
||||
on-timeout = "hyprctl dispatch dpms off"; # screen off when timeout has passed
|
||||
on-resume = "hyprctl dispatch dpms on"; # screen on when activity is detected after timeout has fired.
|
||||
}
|
||||
|
||||
{
|
||||
timeout = 1800; # 30min
|
||||
on-timeout = "systemctl suspend"; # suspend pc
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# - Execute on startup -----------------------
|
||||
# hm.wayland.windowManager.hyprland.settings.exec-once = [
|
||||
# "hypridle"
|
||||
# ];
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
42
modules/system/brightness.nix
Normal file
42
modules/system/brightness.nix
Normal file
@@ -0,0 +1,42 @@
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.samfelag.modules.system.brightness;
|
||||
hyprCfg = config.samfelag.modules.desktop.wm.hyprland;
|
||||
in
|
||||
{
|
||||
options.samfelag.modules.system.brightness = {
|
||||
enable = mkEnableOption "Brightness support";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
brightnessctl
|
||||
];
|
||||
|
||||
# - Hyprland keybindings ---------------------
|
||||
hm.wayland.windowManager.hyprland.settings = lib.mkIf hyprCfg.enable {
|
||||
bind = [
|
||||
# Brightness control
|
||||
", XF86MonBrightnessUp, exec, brightnessctl set +5%"
|
||||
", XF86MonBrightnessDown, exec, brightnessctl set -5%"
|
||||
|
||||
# Keyboard brightness control
|
||||
"${hyprCfg.mod}, XF86MonBrightnessUp, exec, brightnessctl -d platform::kbd_backlight set +1"
|
||||
"${hyprCfg.mod}, XF86MonBrightnessDown, exec, brightnessctl -d platform::kbd_backlight set -1"
|
||||
];
|
||||
|
||||
binde = [
|
||||
# Brightness control (keep button pressed)
|
||||
", XF86MonBrightnessUp, exec, brightnessctl set +5%"
|
||||
", XF86MonBrightnessDown, exec, brightnessctl set 5%-"
|
||||
|
||||
# Keyboard brightness control (keep button pressed)
|
||||
"${hyprCfg.mod}, XF86MonBrightnessUp, exec, brightnessctl -d platform::kbd_backlight set +1"
|
||||
"${hyprCfg.mod}, XF86MonBrightnessDown, exec, brightnessctl -d platform::kbd_backlight set 1-"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user