diff --git a/home-manager/default.nix b/home-manager/default.nix index cb8ffcdc..5665ec69 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -15,6 +15,11 @@ ]; options.custom = with lib; { + autologinCommand = mkOption { + type = types.nullOr types.str; + default = null; + description = "Command to run after autologin"; + }; fonts = { regular = mkOption { type = types.str; @@ -81,9 +86,7 @@ let normalizeHome = p: if (lib.hasPrefix "/home" p) then p else "${config.home.homeDirectory}/${p}"; in - lib.mapAttrsToList ( - dest: src: "L+ ${normalizeHome dest} - - - - ${normalizeHome src}" - ) config.custom.symlinks; + lib.mapAttrsToList (dest: src: "L+ ${normalizeHome dest} - - - - ${src}") config.custom.symlinks; xdg = { enable = true; diff --git a/home-manager/hyprland/keybinds.nix b/home-manager/hyprland/keybinds.nix index 03bcbf6c..1421667a 100644 --- a/home-manager/hyprland/keybinds.nix +++ b/home-manager/hyprland/keybinds.nix @@ -27,12 +27,12 @@ in # $1 is string to search for in window title # $2 is the command to run if the window isn't found text = '' - address=$(hyprctl clients -j | jq -r ".[] | select(.title | contains(\"$1\")) | \"address:\(.address)\"") + address=$(hyprctl clients -j | jq -r ".[] | select(.title | contains(\"$1\")) | .address") if [ -z "$address" ]; then eval "$2" else - hyprctl dispatch focuswindow "$address" + hyprctl dispatch focuswindow "address:$address" fi ''; }; diff --git a/home-manager/hyprland/startup.nix b/home-manager/hyprland/startup.nix index f43c3544..56471e6b 100644 --- a/home-manager/hyprland/startup.nix +++ b/home-manager/hyprland/startup.nix @@ -9,6 +9,8 @@ let openOnWorkspace = workspace: program: "[workspace ${toString workspace} silent] ${program}"; in lib.mkIf config.custom.hyprland.enable { + custom.autologinCommand = lib.getExe config.wayland.windowManager.hyprland.package; + # start hyprland programs.bash.profileExtra = '' if [ "$(tty)" = "/dev/tty1" ]; then diff --git a/nixos/users.nix b/nixos/users.nix index 671ab2cb..88d66963 100644 --- a/nixos/users.nix +++ b/nixos/users.nix @@ -19,9 +19,25 @@ { # autologin services = { - displayManager.autoLogin.user = lib.mkDefault ( - if config.boot.zfs.requestEncryptionCredentials then user else null - ); + greetd = + let + inherit (config.hm.custom) autologinCommand; + in + lib.mkIf (config.boot.zfs.requestEncryptionCredentials && autologinCommand != null) { + enable = true; + + settings = { + default_session = { + command = autologinCommand; + }; + + initial_session = { + inherit user; + command = autologinCommand; + }; + }; + }; + getty.autologinUser = config.services.displayManager.autoLogin.user; };