fixup power config
This commit is contained in:
parent
388a6da603
commit
ecfbf9a557
7 changed files with 89 additions and 57 deletions
|
@ -43,21 +43,22 @@ let
|
||||||
|
|
||||||
build_screen_def = fps_func: with lib; let
|
build_screen_def = fps_func: with lib; let
|
||||||
output_def = mapAttrsToList
|
output_def = mapAttrsToList
|
||||||
(name: value:
|
(name: value:
|
||||||
"output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz"
|
"output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz"
|
||||||
+ (optionalString (value.pos != null) " position ${value.pos}")
|
+ (optionalString (value.pos != null) " position ${value.pos}")
|
||||||
)
|
)
|
||||||
cfg.screens;
|
cfg.screens;
|
||||||
in ''
|
in
|
||||||
for pid in $(${pkgs.procps}/bin/pgrep sway -x)
|
''
|
||||||
do
|
for pid in $(${pkgs.procps}/bin/pgrep sway -x)
|
||||||
uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid))
|
do
|
||||||
export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock"
|
uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid))
|
||||||
if [[ -e "$SWAYSOCK" ]] ; then
|
export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock"
|
||||||
echo "sock is $SWAYSOCK"
|
if [[ -e "$SWAYSOCK" ]] ; then
|
||||||
${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}'
|
echo "sock is $SWAYSOCK"
|
||||||
fi
|
${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}'
|
||||||
done
|
fi
|
||||||
|
done
|
||||||
'';
|
'';
|
||||||
inherit (lib) getExe;
|
inherit (lib) getExe;
|
||||||
|
|
||||||
|
@ -111,6 +112,12 @@ in
|
||||||
sway_conf = lib.concatLines (
|
sway_conf = lib.concatLines (
|
||||||
(build_conf cfg.sway.config)
|
(build_conf cfg.sway.config)
|
||||||
++ lib.optional cfg.sway.bar.enable bar_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";
|
conf_path = "sway.conf";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./laptop.nix
|
./laptop.nix
|
||||||
# ./tlp.nix
|
./tlp.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,13 +46,13 @@ in
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
kernelParams = [
|
kernelParams = [
|
||||||
# "splash"
|
# "splash"
|
||||||
# "quiet"
|
# "quiet"
|
||||||
# "intel_iommu=on"
|
# "intel_iommu=on"
|
||||||
# "iommu=force"
|
# "iommu=force"
|
||||||
# "pcie_acs_override=downstream"
|
# "pcie_acs_override=downstream"
|
||||||
# "mmio_stale_data=full,nosmt"
|
# "mmio_stale_data=full,nosmt"
|
||||||
# "pcie_aspm=off"
|
# "pcie_aspm=off"
|
||||||
]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ];
|
]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ];
|
||||||
loader.efi.canTouchEfiVariables = true;
|
loader.efi.canTouchEfiVariables = true;
|
||||||
initrd.availableKernelModules = [
|
initrd.availableKernelModules = [
|
||||||
|
@ -76,10 +76,10 @@ in
|
||||||
}))
|
}))
|
||||||
];
|
];
|
||||||
kernelModules = [
|
kernelModules = [
|
||||||
# "kvm-intel"
|
# "kvm-intel"
|
||||||
# "vfio_pci"
|
# "vfio_pci"
|
||||||
# "vfio_iommu_type1"
|
# "vfio_iommu_type1"
|
||||||
# "vfio"
|
# "vfio"
|
||||||
"ddcci_backlight"
|
"ddcci_backlight"
|
||||||
"i2c-dev"
|
"i2c-dev"
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,7 +3,7 @@ let
|
||||||
cfg = config.grimmShared;
|
cfg = config.grimmShared;
|
||||||
inherit (lib) optionals optional optionalString concatLines getExe;
|
inherit (lib) optionals optional optionalString concatLines getExe;
|
||||||
inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower;
|
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 ([
|
powersave = with pkgs; writeShellScriptBin "powersave-mode" (concatLines ([
|
||||||
"${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed
|
"${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} 0" # performance preference
|
||||||
"${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo
|
"${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo
|
||||||
] ++ optional cfg.sway.enable "init-screens-max"));
|
] ++ 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
|
in
|
||||||
{
|
{
|
||||||
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) {
|
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) {
|
||||||
|
@ -30,10 +34,16 @@ in
|
||||||
cpupower
|
cpupower
|
||||||
powersave
|
powersave
|
||||||
performance
|
performance
|
||||||
|
auto
|
||||||
] ++ optionals graphical [
|
] ++ optionals graphical [
|
||||||
tlpui
|
tlpui
|
||||||
] ++ optional enable_perf_policy x86_energy_perf_policy;
|
] ++ 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.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power";
|
||||||
powerManagement.cpuFreqGovernor = lib.mkDefault "normal";
|
powerManagement.cpuFreqGovernor = lib.mkDefault "normal";
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ in
|
||||||
{
|
{
|
||||||
config = with cfg; lib.mkIf (enable && portals && graphical) {
|
config = with cfg; lib.mkIf (enable && portals && graphical) {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
(callPackage ../../custom/deskwhich/package.nix {})
|
(callPackage ../../custom/deskwhich/package.nix { })
|
||||||
|
|
||||||
zathura
|
zathura
|
||||||
imhex
|
imhex
|
||||||
|
@ -99,7 +99,7 @@ in
|
||||||
"ranger.desktop"
|
"ranger.desktop"
|
||||||
"dolphin.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" = "calc.desktop";
|
||||||
"application/vnd.oasis.opendocument.chart-template" = "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’
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
# and may be overwritten by future invocations. Please make changes
|
# and may be overwritten by future invocations. Please make changes
|
||||||
# to /etc/nixos/configuration.nix instead.
|
# to /etc/nixos/configuration.nix instead.
|
||||||
{ config, lib, pkgs, modulesPath, ... }: let
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
let
|
||||||
cpus = "12";
|
cpus = "12";
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
imports =
|
imports =
|
||||||
[
|
[
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{ inputs, system, pkgs, config, lib, ... }:
|
{ inputs, system, pkgs, config, lib, ... }:
|
||||||
let
|
let
|
||||||
searchclip = pkgs.writeShellScriptBin "searchclip" ''
|
searchclip = pkgs.writeShellScriptBin "searchclip" ''
|
||||||
xdg-open https://www.google.com/search?q=$(wl-paste -p | urlencode)
|
xdg-open https://www.google.com/search?q=$(wl-paste -p | urlencode)
|
||||||
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
|
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
|
||||||
swaymsg [app_id="$browser" urgent="newest"] focus
|
swaymsg [app_id="$browser" urgent="newest"] focus
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
alacritty
|
alacritty
|
||||||
rmenu
|
rmenu
|
||||||
|
@ -32,7 +32,8 @@ in
|
||||||
|
|
||||||
config = with pkgs; let
|
config = with pkgs; let
|
||||||
inherit (lib) getExe;
|
inherit (lib) getExe;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
definitions = {
|
definitions = {
|
||||||
mod = "Mod4";
|
mod = "Mod4";
|
||||||
left = "h";
|
left = "h";
|
||||||
|
@ -153,21 +154,33 @@ in
|
||||||
XF86MonBrightnessDown = "exec ${getExe brightnessctl} s 10-%";
|
XF86MonBrightnessDown = "exec ${getExe brightnessctl} s 10-%";
|
||||||
XF86Explorer = "exec $term --command ${getExe ranger}";
|
XF86Explorer = "exec $term --command ${getExe ranger}";
|
||||||
XF86Search = "exec ${getExe searchclip}";
|
XF86Search = "exec ${getExe searchclip}";
|
||||||
XF86HomePage = let open = pkgs.writeShellScriptBin "open_or_switch_browser" ''
|
XF86HomePage =
|
||||||
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
|
let
|
||||||
swaymsg [app_id="$browser"] focus || deskwhich $browser | xargs gio launch
|
open = pkgs.writeShellScriptBin "open_or_switch_browser" ''
|
||||||
''; in "exec ${getExe open}";
|
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
|
||||||
XF86Tools = let open = pkgs.writeShellScriptBin "open_or_switch_spotify" ''
|
swaymsg [app_id="$browser"] focus || deskwhich $browser | xargs gio launch
|
||||||
# FIXME: spotify is being weird
|
'';
|
||||||
while IFS= read -r pid; do
|
in
|
||||||
swaymsg [pid=$pid] focus && exit 0
|
"exec ${getExe open}";
|
||||||
done <<< $(pgrep spotify -u "$(whoami)")
|
XF86Tools =
|
||||||
deskwhich spotify | xargs gio launch
|
let
|
||||||
''; in "exec ${getExe open}"; # for some reason tools = audio media on my keyboard??
|
open = pkgs.writeShellScriptBin "open_or_switch_spotify" ''
|
||||||
XF86Mail = let open = pkgs.writeShellScriptBin "open_or_switch_mail" ''
|
# FIXME: spotify is being weird
|
||||||
desk=$(xdg-settings get default-url-scheme-handler mailto | sed "s/\.desktop//")
|
while IFS= read -r pid; do
|
||||||
swaymsg [app_id="$desk"] focus || deskwhich $desk | xargs gio launch
|
swaymsg [pid=$pid] focus && exit 0
|
||||||
''; in "exec ${getExe open}";
|
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";
|
# XF86Bluetooth = "exec blueman-manager";
|
||||||
};
|
};
|
||||||
autolaunch = with pkgs; [
|
autolaunch = with pkgs; [
|
||||||
|
|
Loading…
Reference in a new issue