From 6ab59cf453509b4f53637fe613d990bd325f2787 Mon Sep 17 00:00:00 2001 From: albert Date: Fri, 25 Aug 2023 08:02:10 +0900 Subject: [PATCH] Add TLP --- flake.nix | 4 +- .../desktops/hyprland/hyprland-conf.nix | 39 +++++++++++++++---- .../desktops/hyprland/swaylock-conf.nix | 2 +- lib/default.nix | 4 +- nixos/common/desktops/gnome/default.nix | 4 +- nixos/common/desktops/hyprland/default.nix | 8 +++- nixos/default.nix | 2 +- nixos/hosts/nixos-laptop/default.nix | 4 +- 8 files changed, 47 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index 8d20adaa..a54a8395 100644 --- a/flake.nix +++ b/flake.nix @@ -19,8 +19,8 @@ libx = import ./lib { inherit inputs outputs stateVersion hmStateVersion; }; in { nixosConfigurations = { - nixos-laptop = libx.mkHost { hostname = "nixos-laptop"; username = "albert"; desktop = "hyprland"; graphics = "nvidia"; }; - nixos-desktop = libx.mkHost { hostname = "nixos-desktop"; username = "albert"; desktop = "gnome"; graphics = "nvidia"; }; + nixos-laptop = libx.mkHost { hostname = "nixos-laptop"; username = "albert"; desktop = "hyprland"; gpu = "intel"; }; + nixos-desktop = libx.mkHost { hostname = "nixos-desktop"; username = "albert"; desktop = "gnome"; gpu = "nvidia"; }; }; homeConfigurations = { "albert@nixos-laptop" = libx.mkHome { hostname = "nixos-laptop"; username = "albert"; desktop = "hyprland"; }; diff --git a/home-manager/hosts/nixos-laptop/desktops/hyprland/hyprland-conf.nix b/home-manager/hosts/nixos-laptop/desktops/hyprland/hyprland-conf.nix index 13539035..03f013f9 100644 --- a/home-manager/hosts/nixos-laptop/desktops/hyprland/hyprland-conf.nix +++ b/home-manager/hosts/nixos-laptop/desktops/hyprland/hyprland-conf.nix @@ -174,32 +174,51 @@ # Laptop specific config # Set up the FN keys: + # F1 - Mute - bind = , XF86AudioMute, exec, amixer set Master toggle + # bind = , XF86AudioMute, exec, amixer set Master toggle && swayosd --output-volume=mute-toggle + bind = , XF86AudioMute, exec, swayosd --output-volume=mute-toggle + # F2 - Volume Down - binde = , XF86AudioLowerVolume, exec, amixer set Master 3%- + # binde = , XF86AudioLowerVolume, exec, amixer set Master 3%- + binde = , XF86AudioLowerVolume, exec, swayosd --output-volume=lower + # F3 - Volume Up - binde = , XF86AudioRaiseVolume, exec, amixer set Master 3%+ + # binde = , XF86AudioRaiseVolume, exec, amixer set Master 3%+ + binde = , XF86AudioRaiseVolume, exec, swayosd --output-volume=raise + # F4 - Mute Microphone - bind = , XF86AudioMicMute, exec, amixer set Capture toggle + # bind = , XF86AudioMicMute, exec, amixer set Capture toggle + bind = , XF86AudioMicMute, exec, swayosd --input-volume=mute-toggle + # F5 - Brightness Down - binde = , XF86MonBrightnessDown, exec, light -U 5 + # binde = , XF86MonBrightnessDown, exec, light -U 5 + binde = , XF86MonBrightnessDown, exec, swayosd --brightness=lower + # F6 - Brightness Up - binde = , XF86MonBrightnessUp, exec, light -A 5 + # binde = , XF86MonBrightnessUp, exec, light -A 5 + binde = , XF86MonBrightnessUp, exec, swayosd --brightness=raise + # F7 - External Displays # bind = , XF86 + # F8 - Airplane Mode # bind = , XF86 + # F9 - Notifications? # bind = , XF86 + # F10 - Call Answer? # bind = , XF86 + # F11 - Call Hang Up? # bind = , XF86 + # F12 - Favorites? # bind = , XF86 + # Use rofi as an alt-tab switcher - bind = ALT, TAB, exec, rofi -show window + # bind = ALT, TAB, exec, rofi -show window # Start the config: exec-once=bash ~/.config/hypr/start.sh @@ -220,7 +239,11 @@ waybar & # Set up the idle management daemon - swayidle -w timeout 300 'swaylock -f -c 000000' timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' before-sleep 'swaylock -f -c 000000' + swayidle -w \ + timeout 300 'swaylock -f' \ + timeout 600 'swaymsg "output * power off"' \ + resume 'swaymsg "output * power on"' \ + before-sleep 'swaylock -f' mako ''; }; diff --git a/home-manager/hosts/nixos-laptop/desktops/hyprland/swaylock-conf.nix b/home-manager/hosts/nixos-laptop/desktops/hyprland/swaylock-conf.nix index dc986bd4..1881b83a 100644 --- a/home-manager/hosts/nixos-laptop/desktops/hyprland/swaylock-conf.nix +++ b/home-manager/hosts/nixos-laptop/desktops/hyprland/swaylock-conf.nix @@ -15,7 +15,7 @@ clock = true; timestr = "%R"; datestr = "%a, %b %d"; - grace = 15; + grace = 5; indicator = true; indicator-radius = "120"; diff --git a/lib/default.nix b/lib/default.nix index ef862bbd..feaac2ed 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -10,9 +10,9 @@ }; # Helper function for generating host configs - mkHost = { hostname, username, desktop ? null, installer ? null, graphics ? null }: inputs.nixpkgs.lib.nixosSystem { + mkHost = { hostname, username, desktop ? null, installer ? null, gpu ? null }: inputs.nixpkgs.lib.nixosSystem { specialArgs = { - inherit inputs outputs desktop hostname username stateVersion graphics; + inherit inputs outputs desktop hostname username stateVersion gpu; }; modules = [ ../nixos diff --git a/nixos/common/desktops/gnome/default.nix b/nixos/common/desktops/gnome/default.nix index 5243dbd1..8f3f1191 100644 --- a/nixos/common/desktops/gnome/default.nix +++ b/nixos/common/desktops/gnome/default.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, hostname, graphics, ... }: { +{ lib, config, pkgs, hostname, gpu, ... }: { # Enable sound with pipewire. sound.enable = true; hardware.pulseaudio.enable = false; @@ -17,7 +17,7 @@ xkbVariant = ""; autorun = true; # When you play games, change this to nvidia - videoDrivers = [ graphics ]; + videoDrivers = [ gpu ]; }; ##### disable nvidia, very nice battery life. diff --git a/nixos/common/desktops/hyprland/default.nix b/nixos/common/desktops/hyprland/default.nix index 9e9790bd..d5a83a71 100644 --- a/nixos/common/desktops/hyprland/default.nix +++ b/nixos/common/desktops/hyprland/default.nix @@ -1,5 +1,5 @@ -{pkgs, graphics, ...}: { - services.xserver.videoDrivers = [ graphics ]; +{pkgs, gpu, ...}: { + services.xserver.videoDrivers = [ gpu ]; # tuigreet services.greetd = { @@ -12,6 +12,10 @@ }; }; + services.tlp = { + enable = true; + }; + # Brightness and volume control # https://haikarainen.github.io/light/ programs.light.enable = true; diff --git a/nixos/default.nix b/nixos/default.nix index 7a2e8c99..a0af3085 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, hostname, stateVersion, username, desktop, graphics, ... }: { +{ lib, config, pkgs, hostname, stateVersion, username, desktop, gpu, ... }: { imports = [ # Services ./common/services/openssh.nix diff --git a/nixos/hosts/nixos-laptop/default.nix b/nixos/hosts/nixos-laptop/default.nix index 17e8614a..76152039 100644 --- a/nixos/hosts/nixos-laptop/default.nix +++ b/nixos/hosts/nixos-laptop/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, modulesPath, desktop, username, graphics, ... }: { +{ config, lib, pkgs, modulesPath, desktop, username, ... }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ../../common/services/powertop.nix @@ -94,7 +94,7 @@ environment.systemPackages = with pkgs; [ # Fingerprint software fprintd - # nVidia graphics options + # nVidia gpu options vulkan-loader vulkan-validation-layers vulkan-tools