1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 typedef struct Inhibitor Inhibitor
;
8 typedef enum InhibitWhat
{
9 INHIBIT_SHUTDOWN
= 1 << 0,
10 INHIBIT_SLEEP
= 1 << 1,
11 INHIBIT_IDLE
= 1 << 2,
12 INHIBIT_HANDLE_POWER_KEY
= 1 << 3,
13 INHIBIT_HANDLE_SUSPEND_KEY
= 1 << 4,
14 INHIBIT_HANDLE_HIBERNATE_KEY
= 1 << 5,
15 INHIBIT_HANDLE_LID_SWITCH
= 1 << 6,
16 INHIBIT_HANDLE_REBOOT_KEY
= 1 << 7,
17 _INHIBIT_WHAT_MAX
= 1 << 8,
18 _INHIBIT_WHAT_INVALID
= -EINVAL
,
21 typedef enum InhibitMode
{
25 _INHIBIT_MODE_INVALID
= -EINVAL
,
33 sd_event_source
*event_source
;
54 int inhibitor_new(Manager
*m
, const char* id
, Inhibitor
**ret
);
55 Inhibitor
* inhibitor_free(Inhibitor
*i
);
57 DEFINE_TRIVIAL_CLEANUP_FUNC(Inhibitor
*, inhibitor_free
);
59 int inhibitor_load(Inhibitor
*i
);
61 int inhibitor_start(Inhibitor
*i
);
62 void inhibitor_stop(Inhibitor
*i
);
64 int inhibitor_create_fifo(Inhibitor
*i
);
66 bool inhibitor_is_orphan(Inhibitor
*i
);
68 InhibitWhat
manager_inhibit_what(Manager
*m
, InhibitMode mm
);
69 bool manager_is_inhibited(Manager
*m
, InhibitWhat w
, InhibitMode mm
, dual_timestamp
*since
, bool ignore_inactive
, bool ignore_uid
, uid_t uid
, Inhibitor
**offending
);
71 static inline bool inhibit_what_is_valid(InhibitWhat w
) {
72 return w
> 0 && w
< _INHIBIT_WHAT_MAX
;
75 const char *inhibit_what_to_string(InhibitWhat k
);
76 int inhibit_what_from_string(const char *s
);
78 const char *inhibit_mode_to_string(InhibitMode k
);
79 InhibitMode
inhibit_mode_from_string(const char *s
);