{
  config,
  pkgs,
  lib,
  ...
}: {
  services.hypridle.settings = {
    general = {
      # lock_cmd = notify-send "lock!"          # dbus/sysd lock command (loginctl lock-session)
      # unlock_cmd = notify-send "unlock!"      # same as above, but unlock
      ignore_dbus_inhibit = "false"; # whether to ignore dbus-sent idle-inhibit requests (used by e.g. firefox or steam)
      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 = [
      # Screenlock
      {
        timeout = 180; # in seconds
        on-timeout = "hyprlock"; # command to run when timeout has passed
        # on-resume = notify-send "Welcome back to your desktop!"  # command to run when activity is detected after timeout has fired.
      }
      # Suspend
      {
        timeout = 360; # in seconds
        on-timeout = "systemctl suspend"; # command to run when timeout has passed
        # on-resume = notify-send "Welcome back to your desktop!"  # command to run when activity is detected after timeout has fired.
      }
    ];
  };

  programs.hyprlock = lib.mkIf config.wayland.windowManager.hyprland.enable {
    enable = true;
    settings = {
      background = [
        {
          path = "screenshot"; # only png supported for now
          # color = $color1

          # all these options are taken from hyprland, see https://wiki.hyprland.org/Configuring/Variables/#blur for explanations
          blur_size = 4;
          blur_passes = 3; # 0 disables blurring
          noise = 0.0117;
          contrast = 1.3000; # Vibrant!!!
          brightness = 0.8000;
          vibrancy = 0.2100;
          vibrancy_darkness = 0.0;
        }
      ];

      # Hours
      label = [
        {
          text = ''cmd[update:1000] echo "<b><big> $(date +"%H") </big></b>"'';
          #color = $color6
          font_size = 112;
          # font_family = Geist Mono 10
          shadow_passes = 3;
          shadow_size = 4;

          position = "0, 220";
          halign = "center";
          valign = "center";
        }
        {
          text = ''cmd[update:1000] echo "<b><big> $(date +"%M") </big></b>"'';
          # color = $color6
          font_size = 112;
          # font_family = Geist Mono 10
          shadow_passes = 3;
          shadow_size = 4;

          position = "0, 80";
          halign = "center";
          valign = "center";
        }
        {
          text = ''cmd[update:18000000] echo "<b><big> "$(date +'%A')" </big></b>"'';
          # color = $color7
          font_size = 22;
          # font_family = JetBrainsMono Nerd Font 10

          position = "0, 30";
          halign = "center";
          valign = "center";
        }
        {
          text = ''cmd[update:18000000] echo "<b> "$(${pkgs.coreutils-full}/bin/date +'%d %b')" </b>"'';
          # color = $color7
          font_size = 18;
          #font_family = JetBrainsMono Nerd Font 10

          position = "0, 6";
          halign = "center";
          valign = "center";
        }
        {
          text = ''cmd[update:18000000] echo "<b>So ca. <big> $(${pkgs.curl}/bin/curl -s 'wttr.in?format=%t' | ${pkgs.coreutils-full}/bin/tr -d '+')</big> oder watt.</b>"'';
          #color = $color7
          font_size = 18;
          # font_family = Geist Mono 10

          position = "0, 40";
          halign = "center";
          valign = "bottom";
        }
      ];

      input-field = [
        {
          size = "250, 50";
          outline_thickness = 3;

          dots_size = 0.26; # Scale of input-field height, 0.2 - 0.8
          dots_spacing = 0.64; # Scale of dots' absolute size, 0.0 - 1.0
          dots_center = true;
          dots_rouding = -1;

          rounding = 22;
          # outer_color = $color0
          # inner_color = $color0
          # font_color = $color6
          fade_on_empty = true;
          placeholder_text = ''<i>Password...</i>''; # Text rendered in the input box when it's empty.

          position = "0, 120";
          halign = "center";
          valign = "bottom";
        }
      ];
    };
  };

  wayland.windowManager.hyprland = lib.mkIf config.wayland.windowManager.hyprland.enable {
    settings = {
      exec-once = [
        "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
        "${pkgs.systemd}/bin/systemctl --user import-environment DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
        "${pkgs.wpaperd}/bin/wpaperd &"
      ];

      "$mod" = "SUPER";
      bind =
        [
          "$mod, RETURN, exec, ${pkgs.kitty}/bin/kitty"
          "$mod, d, exec, ${pkgs.wofi}/bin/wofi --show drun"
          "$mod, h, movefocus, l"
          "$mod, j, movefocus, d"
          "$mod, k, movefocus, u"
          "$mod, l, movefocus, r"
          "$mod, LEFT, movefocus, l"
          "$mod, DOWN, movefocus, d"
          "$mod, UP, movefocus, u"
          "$mod, RIGHT, movefocus, r"
          "$mod SHIFT, h, movewindow, l"
          "$mod SHIFT, j, movewindow, d"
          "$mod SHIFT, k, movewindow, u"
          "$mod SHIFT, l, movewindow, r"
          "$mod SHIFT, LEFT, movewindow, l"
          "$mod SHIFT, DOWN, movewindow, d"
          "$mod SHIFT, UP, movewindow, u"

          "$mod CTRL SHIFT, LEFT, moveactive, -10 0"
          "$mod CTRL SHIFT, DOWN, moveactive, 0 10"
          "$mod CTRL SHIFT, UP, moveactive, 0 -10"
          "$mod CTRL SHIFT, RIGHT, moveactive, 10 0"
          "$mod CTRL SHIFT, h, moveactive, -10 0"
          "$mod CTRL SHIFT, j, moveactive, 0 10"
          "$mod CTRL SHIFT, k, moveactive, 0 -10"
          "$mod CTRL SHIFT, l, moveactive, 10 0"
          "$mod SHIFT, q, killactive"
          "$mod CTRL, h, resizeactive, -5% 0%"
          "$mod CTRL, l, resizeactive, 5% 0%"
          "$mod CTRL, j, resizeactive, 0% -5%"
          "$mod CTRL, k, resizeactive, 0% 5%"
          "$mod, SPACE, togglefloating, active"
          "$mod SHIFT, SPACE, centerwindow"
          "$mod, f, fullscreen, 1"
          "$mod SHIFT, f, fullscreen, 0"
          "$mod CTRL, f, fakefullscreen"
          "$mod SHIFT, s, pin"
          "$mod SHIFT, x, exec, ${pkgs.hyprland}/bin/hyprctl kill"
          ", XF86AudioRaiseVolume, exec, ${pkgs.pulsemixer}/bin/pulsemixer --change-volume +5"
          ", XF86AudioLowerVolume, exec, ${pkgs.pulsemixer}/bin/pulsemixer --change-volume -5"
          ", XF86AudioMute, exec, ${pkgs.pulsemixer}/bin/pulsemixer --toggle-mute"
          ", XF86AudioMicMute, exec, ${pkgs.pulsemixer}/bin/pulsemixer --toggle-mute --id 1"
          ", XF86MonBrightnessUp, exec, ${pkgs.brightnessctl}/bin/brightnessctl set +5%"
          ", XF86MonBrightnessDown, exec, ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"
          "$mod, 9, exec, ${pkgs.hyprlock}/bin/hyprlock"
          "$mod, 0, exec, ${pkgs.wlogout}/bin/wlogout -b 5"
          "$mod, n, exec, ${pkgs.swaynotificationcenter}/bin/swaync-client -t"
        ]
        ++ (
          # workspaces
          # binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
          builtins.concatLists (builtins.genList (
              x: let
                ws = builtins.toString (x + 1);
              in [
                "$mod, ${ws}, workspace, ${ws}"
                "$mod SHIFT, ${ws}, movetoworkspace, ${ws}"
                "$mod CTRL, ${ws}, movetoworkspacesilent, ${ws}"
              ]
            )
            8)
        );
      # See https://wiki.hyprland.org/Configuring/Monitors/
      monitor = ",preferred,auto,1";
      env = [
        "GDK_SCALE,1"
        "XCURSOR_SIZE,12"
      ];

      xwayland = {
        force_zero_scaling = true;
      };

      # See https://wiki.hyprland.org/Configuring/Keywords/ for more

      # Execute your favorite apps at launch
      # exec-once = waybar & hyprpaper & firefox

      # Source a file (multi-file configs)
      # source = ~/.config/hypr/myColors.conf

      # For all categories, see https://wiki.hyprland.org/Configuring/Variables/
      input = {
        kb_layout = "de";
        kb_variant = "deadacute";
        kb_model = "";
        kb_options = "caps:ctrl_modifier";
        kb_rules = "";
        repeat_delay = 250;
        repeat_rate = 30;
        follow_mouse = 1;

        touchpad = {
          natural_scroll = "yes";
        };

        sensitivity = 0; # -1.0 - 1.0, 0 means no modification.
      };

      general = {
        # See https://wiki.hyprland.org/Configuring/Variables/ for more

        gaps_in = 5;
        gaps_out = 10;
        border_size = 2;
        "col.active_border" = "rgba(33ccffee) rgba(00ff99ee) 45deg";
        "col.inactive_border" = "rgba(595959aa)";

        layout = "dwindle";

        # Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on
        allow_tearing = false;
      };

      layerrule = [
        # blur for wlogout
        "blur, logout_dialog"

        # blur for swaync
        "blur, swaync-control-center"
        "blur, swaync-notification-window"
        "ignorezero, swaync-control-center"
        "ignorezero, swaync-notification-window"
        "ignorealpha 0.5, swaync-control-center"
        "ignorealpha 0.5, swaync-notification-window"
      ];

      decoration = {
        # See https://wiki.hyprland.org/Configuring/Variables/ for more

        rounding = 10;

        blur = {
          enabled = true;
          size = 8;
          passes = 1;
          new_optimizations = true;
        };

        drop_shadow = "yes";
        shadow_range = 4;
        shadow_render_power = 3;
        "col.shadow" = "rgba(1a1a1aee)";
      };

      animations = {
        enabled = "yes";

        # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more

        bezier = "myBezier, 0.05, 0.9, 0.1, 1.05";

        animation = [
          "windows, 1, 7, myBezier"
          "windowsOut, 1, 7, default, popin 80%"
          "border, 1, 10, default"
          "borderangle, 1, 8, default"
          "fade, 1, 7, default"
          "workspaces, 1, 6, default"
        ];
      };

      dwindle = {
        # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
        pseudotile = "yes"; # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
        preserve_split = "yes"; # you probably want this
        no_gaps_when_only = 0;
      };

      master = {
        # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
        # new_is_master = true;
        no_gaps_when_only = 0;
      };

      gestures = {
        # See https://wiki.hyprland.org/Configuring/Variables/ for more
        workspace_swipe = "off";
      };

      misc = {
        # See https://wiki.hyprland.org/Configuring/Variables/ for more
        force_default_wallpaper = 0; # Set to 0 to disable the anime mascot wallpapers
      };

      # Example per-device config
      # See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
      # "device:epic-mouse-v1" = {
      #   sensitivity = -0.5;
      # };
    };
  };
}
