From d5bc7c31431fea71c9edb22c5aa93a45f397c880 Mon Sep 17 00:00:00 2001 From: Drew Haven Date: Mon, 19 May 2025 15:52:29 -0700 Subject: [PATCH] [Hypr] Sets up hypridle. [Nvim] Sets up nix formatting --- .../features/development/development.nix | 1 + home-manager/features/development/sh.nix | 6 ++++ home-manager/features/hypr/hypridle.nix | 34 +++++++++++++++++++ home-manager/features/hyprland.nix | 14 +++----- .../neovim/config/lua/plugins/conform.lua | 8 +++++ 5 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 home-manager/features/development/sh.nix create mode 100644 home-manager/features/hypr/hypridle.nix create mode 100644 home-manager/features/neovim/config/lua/plugins/conform.lua diff --git a/home-manager/features/development/development.nix b/home-manager/features/development/development.nix index a77984f..1178ea4 100644 --- a/home-manager/features/development/development.nix +++ b/home-manager/features/development/development.nix @@ -10,6 +10,7 @@ # Base languages that should always be available ./nix.nix ./lua.nix + ./sh.nix ]; programs.direnv = { diff --git a/home-manager/features/development/sh.nix b/home-manager/features/development/sh.nix new file mode 100644 index 0000000..b50a790 --- /dev/null +++ b/home-manager/features/development/sh.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +{ + home.packages = with pkgs; [ + shfmt # Formatter + ]; +} diff --git a/home-manager/features/hypr/hypridle.nix b/home-manager/features/hypr/hypridle.nix new file mode 100644 index 0000000..c1fbee4 --- /dev/null +++ b/home-manager/features/hypr/hypridle.nix @@ -0,0 +1,34 @@ +{ ... }: +{ + 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 = 150; # 2.5min. + on-timeout = "brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor. + on-resume = "brightnessctl -r"; # monitor backlight restore. + } + { + 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 && brightnessctl -r"; # screen on when activity is detected after timeout has fired. + } + { + timeout = 1800; # 30min + on-timeout = "systemctl suspend"; # suspend pc + } + ]; + }; + }; +} diff --git a/home-manager/features/hyprland.nix b/home-manager/features/hyprland.nix index 4659c20..75028c4 100644 --- a/home-manager/features/hyprland.nix +++ b/home-manager/features/hyprland.nix @@ -1,5 +1,9 @@ { pkgs, ... }: { + imports = [ + ./hypr/hypridle.nix + ]; + home.packages = with pkgs; [ swayosd # volume pop-up swaynotificationcenter # notifications @@ -11,16 +15,6 @@ xclip ]; - services.swayidle = { - enable = true; - events = [ - { - event = "before-sleep"; - command = "hyprlock"; - } - ]; - }; - wayland.windowManager.hyprland = { enable = true; plugins = [ diff --git a/home-manager/features/neovim/config/lua/plugins/conform.lua b/home-manager/features/neovim/config/lua/plugins/conform.lua new file mode 100644 index 0000000..3371acf --- /dev/null +++ b/home-manager/features/neovim/config/lua/plugins/conform.lua @@ -0,0 +1,8 @@ +return { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + nix = { "nixfmt" }, + }, + }, +}