#include <unistd.h>
-#include "sd-messages.h"
#include "conf-parser.h"
#include "special.h"
#include "sleep-config.h"
[HANDLE_HYBRID_SLEEP] = "Hibernating and suspending..."
};
- static const char * const target_table[_HANDLE_ACTION_MAX] = {
- [HANDLE_POWEROFF] = SPECIAL_POWEROFF_TARGET,
- [HANDLE_REBOOT] = SPECIAL_REBOOT_TARGET,
- [HANDLE_HALT] = SPECIAL_HALT_TARGET,
- [HANDLE_KEXEC] = SPECIAL_KEXEC_TARGET,
- [HANDLE_SUSPEND] = SPECIAL_SUSPEND_TARGET,
- [HANDLE_HIBERNATE] = SPECIAL_HIBERNATE_TARGET,
- [HANDLE_HYBRID_SLEEP] = SPECIAL_HYBRID_SLEEP_TARGET
- };
-
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
InhibitWhat inhibit_operation;
Inhibitor *offending = NULL;
}
if (inhibit_key == INHIBIT_HANDLE_LID_SWITCH) {
- int n;
-
- /* If we are docked don't react to lid closing */
- if (manager_is_docked(m)) {
- log_debug("Ignoring lid switch request, system is docked.");
- return 0;
- }
-
- /* If we have more than one or no displays connected,
- * don't react to lid closing. The no display case we
- * treat like this under the assumption that there is
- * no modern drm driver available. */
- n = manager_count_displays(m);
- if (n < 0)
- log_warning("Display counting failed: %s", strerror(-n));
- else if (n != 1) {
- log_debug("Ignoring lid switch request, %i displays connected.", n);
- return 0;
- }
-
/* If the last system suspend or startup is too close,
* let's not suspend for now, to give USB docking
* stations some time to settle so that we can
if (!supported) {
log_warning("Requested operation not supported, ignoring.");
- return -ENOTSUP;
+ return -EOPNOTSUPP;
}
if (m->action_what) {
log_info("%s", message_table[handle]);
- r = bus_manager_shutdown_or_sleep_now_or_later(m, target_table[handle], inhibit_operation, &error);
+ r = bus_manager_shutdown_or_sleep_now_or_later(m, handle, inhibit_operation, &error);
if (r < 0) {
log_error("Failed to execute operation: %s", bus_error_message(&error, r));
return r;