fixup power config

This commit is contained in:
Grimmauld 2024-05-02 15:04:38 +02:00
parent 388a6da603
commit ecfbf9a557
Signed by: Grimmauld
GPG Key ID: C2946668769F91FB
7 changed files with 89 additions and 57 deletions

View File

@ -48,7 +48,8 @@ let
+ (optionalString (value.pos != null) " position ${value.pos}")
)
cfg.screens;
in ''
in
''
for pid in $(${pkgs.procps}/bin/pgrep sway -x)
do
uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid))
@ -111,6 +112,12 @@ in
sway_conf = lib.concatLines (
(build_conf cfg.sway.config)
++ lib.optional cfg.sway.bar.enable bar_config
++ (lib.mapAttrsToList
(name: value:
"output ${value.id} mode ${value.mode}"
+ (lib.optionalString (value.pos != null) " position ${value.pos}")
)
cfg.screens)
);
conf_path = "sway.conf";

View File

@ -1,6 +1,6 @@
{
imports = [
./laptop.nix
# ./tlp.nix
./tlp.nix
];
}

View File

@ -3,7 +3,7 @@ let
cfg = config.grimmShared;
inherit (lib) optionals optional optionalString concatLines getExe;
inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower;
enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms) && false;
enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms);
powersave = with pkgs; writeShellScriptBin "powersave-mode" (concatLines ([
"${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed
@ -20,6 +20,10 @@ let
"${getExe x86_energy_perf_policy} 0" # performance preference
"${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo
] ++ optional cfg.sway.enable "init-screens-max"));
auto = let inherit (pkgs) tlp; in pkgs.writeShellScriptBin "auto-mode" ''
${tlp}/bin/run-on-ac ${getExe performance}
${tlp}/bin/run-on-bat ${getExe powersave}
'';
in
{
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) {
@ -30,10 +34,16 @@ in
cpupower
powersave
performance
auto
] ++ optionals graphical [
tlpui
] ++ optional enable_perf_policy x86_energy_perf_policy;
services.acpid = {
enable = true;
acEventCommands = getExe auto;
};
powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power";
powerManagement.cpuFreqGovernor = lib.mkDefault "normal";

View File

@ -1,9 +1,11 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: let
{ config, lib, pkgs, modulesPath, ... }:
let
cpus = "12";
in {
in
{
imports =
[
(modulesPath + "/installer/scan/not-detected.nix")

View File

@ -32,7 +32,8 @@ in
config = with pkgs; let
inherit (lib) getExe;
in {
in
{
definitions = {
mod = "Mod4";
left = "h";
@ -153,21 +154,33 @@ in
XF86MonBrightnessDown = "exec ${getExe brightnessctl} s 10-%";
XF86Explorer = "exec $term --command ${getExe ranger}";
XF86Search = "exec ${getExe searchclip}";
XF86HomePage = let open = pkgs.writeShellScriptBin "open_or_switch_browser" ''
XF86HomePage =
let
open = pkgs.writeShellScriptBin "open_or_switch_browser" ''
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
swaymsg [app_id="$browser"] focus || deskwhich $browser | xargs gio launch
''; in "exec ${getExe open}";
XF86Tools = let open = pkgs.writeShellScriptBin "open_or_switch_spotify" ''
'';
in
"exec ${getExe open}";
XF86Tools =
let
open = pkgs.writeShellScriptBin "open_or_switch_spotify" ''
# FIXME: spotify is being weird
while IFS= read -r pid; do
swaymsg [pid=$pid] focus && exit 0
done <<< $(pgrep spotify -u "$(whoami)")
deskwhich spotify | xargs gio launch
''; in "exec ${getExe open}"; # for some reason tools = audio media on my keyboard??
XF86Mail = let open = pkgs.writeShellScriptBin "open_or_switch_mail" ''
'';
in
"exec ${getExe open}"; # for some reason tools = audio media on my keyboard??
XF86Mail =
let
open = pkgs.writeShellScriptBin "open_or_switch_mail" ''
desk=$(xdg-settings get default-url-scheme-handler mailto | sed "s/\.desktop//")
swaymsg [app_id="$desk"] focus || deskwhich $desk | xargs gio launch
''; in "exec ${getExe open}";
'';
in
"exec ${getExe open}";
# XF86Bluetooth = "exec blueman-manager";
};
autolaunch = with pkgs; [