{
  flake,
  osConfig,
  lib,
  pkgs,
  ...
}:

let
  inherit (flake.config.aesthetics.themes) fonts;
  inherit (flake.config.machines) devices;
  mars = devices.mars.name;
  deimos = devices.deimos.name;
  host = osConfig.networking.hostName;
  deviceLogic =
    d: m:
    if host == deimos then
      d
    else if host == mars then
      m
    else
      null;
in
{
  imports = [ flake.inputs.plasma-manager.homeModules.plasma-manager ];

  programs = {
    plasma = {
      enable = true;
      workspace = {
        clickItemTo = "select";
        lookAndFeel = "org.kde.breezedark.desktop";
        colorScheme = "Scratchy";
      };
      session = {
        general.askForConfirmationOnLogout = false;
        sessionRestore = {
          excludeApplications = [
            (lib.getExe pkgs.bitwarden-desktop)
          ];
        };
      };
      shortcuts = {
        kwin = {
          "Window to Desktop 1" = "Ctrl+!";
          "Window to Desktop 2" = "Ctrl+@";
          "Window to Desktop 3" = "Ctrl+#";
          "Window to Desktop 4" = "Ctrl+$";
          "Window to Desktop 5" = "Ctrl+%";
          "Switch to Desktop 1" = "Meta+1";
          "Switch to Desktop 2" = "Meta+2";
          "Switch to Desktop 3" = "Meta+3";
          "Switch to Desktop 4" = "Meta+4";
          "Switch to Desktop 5" = "Meta+5";
          "Window Close" = "Meta+Tab";
          "Window Fullscreen" = "Ctrl+Shift+Tab";
        };
      };
      hotkeys = {
        commands = {
          "launch-obsidian" = {
            name = "Launch Obsidian";
            key = "Meta+Z";
            command = lib.getExe pkgs.obsidian;
          };
          "launch-feishin" = {
            name = "Launch Feishin";
            key = "Meta+H";
            command = lib.getExe pkgs.feishin;
          };
          "launch-scrcpy" = {
            name = "Launch Scrcpy";
            key = "Meta+G";
            command = lib.getExe pkgs.scrcpy;
          };
          "launch-dolphin" = {
            name = "Launch Dolphin";
            key = "Meta+E";
            command = "dolphin";
          };
          "launch-steam" = {
            name = "Launch Steam";
            key = "Meta+S";
            command = lib.getExe pkgs.steam;
          };
          "launch-signal" = {
            name = "Launch Signal";
            key = "Meta+N";
            command = lib.getExe pkgs.signal-desktop-bin;
          };
          "launch-zeditor" = {
            name = "Launch Zed Editor";
            key = "Meta+T";
            command = lib.getExe pkgs.zed-editor;
          };
          "launch-floorp" = {
            name = "Launch Floorp";
            key = "Meta+B";
            command = lib.getExe pkgs.floorp-bin;
          };
          "launch-freetube" = {
            name = "Launch FreeTube";
            key = "Meta+X";
            command = lib.getExe pkgs.freetube;
          };
          "launch-vesktop" = {
            name = "Launch Vesktop";
            key = "Meta+V";
            command = lib.getExe pkgs.vesktop;
          };
          "launch-element" = {
            name = "Launch Element";
            key = "Meta+M";
            command = lib.getExe pkgs.element-desktop;
          };
          "launch-ghostty" = {
            name = "Launch Ghostty";
            key = "Meta+D";
            command = lib.getExe pkgs.ghostty;
          };
          "launch-bitwarden" = {
            name = "Launch Bitwarden";
            key = "Meta+P";
            command = lib.getExe pkgs.bitwarden-desktop;
          };
          "launch-dotfiles" = {
            name = "Launch Dotfiles in Zellij";
            key = "Meta+F";
            command = "ghostty -e zellij a dotfiles";
          };
          "launch-yazi" = {
            name = "Launch Dotfiles in Zellij";
            key = "Meta+R";
            command = "${lib.getExe pkgs.ghostty} -e ${lib.getExe pkgs.yazi}";
          };

          # Screenshots & Utilities
          "screenshot-gui" = {
            name = "Screenshot GUI";
            key = "Meta+Shift+S";
            command = "flameshot gui";
          };
          # "launch-emote" = {
          #   name = "Launch Emoji Picker";
          #   key = "Meta+Shift+.";
          #   command = lib.getExe pkgs.emote;
          # };

          # Media Controls
          "media-next" = {
            name = "Next Track";
            key = "Meta+Page_Up";
            command = "playerctl next";
          };
          "media-previous" = {
            name = "Previous Track";
            key = "Meta+Page_Down";
            command = "playerctl previous";
          };
          "media-play-pause" = {
            name = "Play/Pause";
            key = "Meta+Home";
            command = "playerctl play-pause";
          };

          # System Controls
          "system-shutdown" = {
            name = "Shutdown";
            key = "Meta+Shift+End";
            command = "shutdown now";
          };
          "system-reboot" = {
            name = "Reboot";
            key = "Meta+Shift+Insert";
            command = "systemctl reboot";
          };
          "lock-screen" = {
            name = "Lock Screen";
            key = "Meta+Shift+Home";
            command = "swaylock";
          };
        };
      };
      kwin = {
        virtualDesktops = {
          rows = 1;
          number = 5;
          names = [
            "Desktop 1"
            "Desktop 2"
            "Desktop 3"
            "Desktop 4"
            "Desktop 5"
          ];

        };
        titlebarButtons.right = [
          "minimize"
          "maximize"
          "close"
        ];
        nightLight = {
          enable = true;
          mode = "times";
          temperature = {
            day = 4500;
            night = 2500;
          };
          time = {
            evening = "22:00";
            morning = "07:00";
          };
          transitionTime = 30;
        };
        effects = {
          desktopSwitching = {
            animation = "slide";
            navigationWrapping = true;
          };
          minimization = {
            animation = "squash";
          };
          shakeCursor.enable = false;
          translucency.enable = true;
          windowOpenClose = {
            animation = "scale";
          };
        };
      };
      powerdevil = {
        AC = {
          autoSuspend = {
            action = deviceLogic "sleep" null;
            idleTimeout = deviceLogic 1200 null;
          };
          dimDisplay = {
            enable = deviceLogic true false;
            idleTimeout = deviceLogic 900 null;
          };
          displayBrightness = 100;
          inhibitLidActionWhenExternalMonitorConnected = deviceLogic true null;
          powerButtonAction = deviceLogic "lockScreen" "shutDown";
          powerProfile = "performance";
          turnOffDisplay = {
            idleTimeout = deviceLogic 1800 null;
            idleTimeoutWhenLocked = deviceLogic 600 null;
          };
          whenLaptopLidClosed = deviceLogic "sleep" null;
          whenSleepingEnter = deviceLogic "hybridSleep" null;
        };
        battery = {
          autoSuspend = {
            action = "hibernate";
            idleTimeout = 1200;
          };
          dimDisplay = {
            enable = true;
            idleTimeout = 1200;
          };
          displayBrightness = 100;
          inhibitLidActionWhenExternalMonitorConnected = true;
          powerButtonAction = "hibernate";
          powerProfile = "powerSaving";
          turnOffDisplay = {
            idleTimeout = 1800;
            idleTimeoutWhenLocked = 600;
          };
          whenLaptopLidClosed = "sleep";
          whenSleepingEnter = "standbyThenHibernate";
        };
        lowBattery = {
          autoSuspend = {
            action = "hibernate";
            idleTimeout = 900;
          };
          dimDisplay = {
            enable = true;
            idleTimeout = 450;
          };
          displayBrightness = 100;
          inhibitLidActionWhenExternalMonitorConnected = true;
          powerButtonAction = "hibernate";
          powerProfile = "powerSaving";
          turnOffDisplay = {
            idleTimeout = 1200;
            idleTimeoutWhenLocked = 600;
          };
          whenLaptopLidClosed = "hibernate";
          whenSleepingEnter = "standbyThenHibernate";
        };
        batteryLevels = {
          criticalLevel = 5;
          lowLevel = 20;
        };
        general.pausePlayersOnSuspend = true;
      };
      windows.allowWindowsToRememberPositions = true;
    };
    elisa.enable = false;
    ghostwriter.enable = false;
    kate.enable = false;
    konsole.enable = false;
    okular.enable = false;
  };
}
