fixup power config
This commit is contained in:
parent
388a6da603
commit
ecfbf9a557
7 changed files with 89 additions and 57 deletions
|
@ -41,23 +41,24 @@ let
|
|||
};
|
||||
});
|
||||
|
||||
build_screen_def = fps_func: with lib; let
|
||||
build_screen_def = fps_func: with lib; let
|
||||
output_def = mapAttrsToList
|
||||
(name: value:
|
||||
"output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz"
|
||||
+ (optionalString (value.pos != null) " position ${value.pos}")
|
||||
)
|
||||
cfg.screens;
|
||||
in ''
|
||||
for pid in $(${pkgs.procps}/bin/pgrep sway -x)
|
||||
do
|
||||
uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid))
|
||||
export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock"
|
||||
if [[ -e "$SWAYSOCK" ]] ; then
|
||||
echo "sock is $SWAYSOCK"
|
||||
${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}'
|
||||
fi
|
||||
done
|
||||
(name: value:
|
||||
"output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz"
|
||||
+ (optionalString (value.pos != null) " position ${value.pos}")
|
||||
)
|
||||
cfg.screens;
|
||||
in
|
||||
''
|
||||
for pid in $(${pkgs.procps}/bin/pgrep sway -x)
|
||||
do
|
||||
uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid))
|
||||
export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock"
|
||||
if [[ -e "$SWAYSOCK" ]] ; then
|
||||
echo "sock is $SWAYSOCK"
|
||||
${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}'
|
||||
fi
|
||||
done
|
||||
'';
|
||||
inherit (lib) getExe;
|
||||
|
||||
|
@ -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";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./laptop.nix
|
||||
# ./tlp.nix
|
||||
./tlp.nix
|
||||
];
|
||||
}
|
||||
|
|
|
@ -46,13 +46,13 @@ in
|
|||
|
||||
boot = {
|
||||
kernelParams = [
|
||||
# "splash"
|
||||
# "quiet"
|
||||
# "intel_iommu=on"
|
||||
# "iommu=force"
|
||||
# "pcie_acs_override=downstream"
|
||||
# "mmio_stale_data=full,nosmt"
|
||||
# "pcie_aspm=off"
|
||||
# "splash"
|
||||
# "quiet"
|
||||
# "intel_iommu=on"
|
||||
# "iommu=force"
|
||||
# "pcie_acs_override=downstream"
|
||||
# "mmio_stale_data=full,nosmt"
|
||||
# "pcie_aspm=off"
|
||||
]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ];
|
||||
loader.efi.canTouchEfiVariables = true;
|
||||
initrd.availableKernelModules = [
|
||||
|
@ -76,10 +76,10 @@ in
|
|||
}))
|
||||
];
|
||||
kernelModules = [
|
||||
# "kvm-intel"
|
||||
# "vfio_pci"
|
||||
# "vfio_iommu_type1"
|
||||
# "vfio"
|
||||
# "kvm-intel"
|
||||
# "vfio_pci"
|
||||
# "vfio_iommu_type1"
|
||||
# "vfio"
|
||||
"ddcci_backlight"
|
||||
"i2c-dev"
|
||||
];
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ in
|
|||
{
|
||||
config = with cfg; lib.mkIf (enable && portals && graphical) {
|
||||
environment.systemPackages = with pkgs; [
|
||||
(callPackage ../../custom/deskwhich/package.nix {})
|
||||
(callPackage ../../custom/deskwhich/package.nix { })
|
||||
|
||||
zathura
|
||||
imhex
|
||||
|
@ -99,7 +99,7 @@ in
|
|||
"ranger.desktop"
|
||||
"dolphin.desktop"
|
||||
];
|
||||
"x-scheme-handler/mailto"="thunderbird.desktop";
|
||||
"x-scheme-handler/mailto" = "thunderbird.desktop";
|
||||
|
||||
"application/vnd.oasis.opendocument.chart" = "calc.desktop";
|
||||
"application/vnd.oasis.opendocument.chart-template" = "calc.desktop";
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{ inputs, system, pkgs, config, lib, ... }:
|
||||
let
|
||||
{ inputs, system, pkgs, config, lib, ... }:
|
||||
let
|
||||
searchclip = pkgs.writeShellScriptBin "searchclip" ''
|
||||
xdg-open https://www.google.com/search?q=$(wl-paste -p | urlencode)
|
||||
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
|
||||
swaymsg [app_id="$browser" urgent="newest"] focus
|
||||
'';
|
||||
xdg-open https://www.google.com/search?q=$(wl-paste -p | urlencode)
|
||||
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
|
||||
swaymsg [app_id="$browser" urgent="newest"] focus
|
||||
'';
|
||||
in
|
||||
{
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
alacritty
|
||||
rmenu
|
||||
|
@ -30,9 +30,10 @@ in
|
|||
style = ./bar/style.css;
|
||||
};
|
||||
|
||||
config = with pkgs; let
|
||||
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" ''
|
||||
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" ''
|
||||
# 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" ''
|
||||
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}";
|
||||
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" ''
|
||||
# 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" ''
|
||||
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}";
|
||||
# XF86Bluetooth = "exec blueman-manager";
|
||||
};
|
||||
autolaunch = with pkgs; [
|
||||
|
|
Loading…
Reference in a new issue