In KDE, I have set my preferences so that if I unplug my laptop and then close the lid, it will go into sleep mode. However, if I close the lid first and then unplug it, it will not suspend.
More specifically, I have KDE set up to choose one of two profiles based on whether or not the AC adapter is plugged in. (This is the default.) The "plugged-in" profile is set to turn off the screen when the lid is closed, while the "no plugged in" profile is set to go to sleep mode when the lid is closed. If the lid is already closed when I unplug the laptop, it will still switch profiles, but it will not trigger the new action because the lid status has not changed.
So is there a way to trigger the appropriate lid action whenever I plug or unplug the laptop? Alternatively, is there a way to automatically generate a fake lid ACPI event when I plug or unplug the laptop?
Further info: KDE Bug Report