+ } else if (handle == HANDLE_TTY_SESSION ||
+ handle == HANDLE_ANY_SESSION) {
+ unsigned n;
+ Session *s;
+
+ n = hashmap_size(b->manager->sessions);
+ s = button_get_session(b);
+
+ /* Silently ignore events of graphical sessions */
+ if (handle == HANDLE_TTY_SESSION &&
+ s && s->type == SESSION_X11)
+ return 0;
+
+ if (n > 1 || (n == 1 && !s)) {
+ log_error("Refusing power-off, other user is logged in.");
+ warn_melody();
+ return -EPERM;
+ }
+
+ }
+
+ if (handle != HANDLE_ALWAYS) {