1  #!/bin/bash
   2  # ==============================================================================
   3  # PERMANENT CAFFEINE FOR DELL-SS
   4  # Disables all suspend, sleep, hibernate, lid-switch actions, and Wi-Fi powersave
   5  # ==============================================================================
   6  
   7  DELL_IP="192.168.31.65"
   8  DELL_USER="agent"
   9  
  10  echo "========================================================================"
  11  echo "  APPLYING LINUX 'CAFFEINATE' CONFIGURATION TO DELL-SS"
  12  echo "========================================================================"
  13  
  14  # Step 1: Complete logind lid switch override
  15  echo "[1/4] Configuring logind lid switch ignore..."
  16  ssh $DELL_USER@$DELL_IP "sudo mkdir -p /etc/systemd/logind.conf.d && sudo tee /etc/systemd/logind.conf.d/99-caffeinate.conf << 'EOF'
  17  [Login]
  18  HandleLidSwitch=ignore
  19  HandleLidSwitchExternalPower=ignore
  20  HandleLidSwitchDocked=ignore
  21  LidSwitchIgnoreInhibited=no
  22  EOF"
  23  
  24  # Step 2: Mask all systemd sleep/suspend/hibernate targets completely
  25  echo "[2/4] Masking all systemd sleep, suspend, and hibernate targets..."
  26  ssh $DELL_USER@$DELL_IP "sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target"
  27  
  28  # Step 3: Disable Wi-Fi power saving so network interface never drops
  29  echo "[3/4] Disabling Wi-Fi power management..."
  30  ssh $DELL_USER@$DELL_IP "sudo tee /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf << 'EOF'
  31  [connection]
  32  wifi.powersave = 2
  33  EOF
  34  sudo systemctl restart NetworkManager"
  35  
  36  # Step 4: Restart logind to apply
  37  echo "[4/4] Restarting systemd-logind..."
  38  ssh $DELL_USER@$DELL_IP "sudo systemctl restart systemd-logind"
  39  
  40  echo ""
  41  echo "========================================================================"
  42  echo "  SUCCESS: Dell is now permanently caffeinated."
  43  echo "  Closing the lid will NEVER suspend the laptop or drop Wi-Fi."
  44  echo "========================================================================"
  45