]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/login/logind-inhibit.h
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / login / logind-inhibit.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 typedef struct Inhibitor Inhibitor;
5
6 typedef enum InhibitWhat {
7 INHIBIT_SHUTDOWN = 1 << 0,
8 INHIBIT_SLEEP = 1 << 1,
9 INHIBIT_IDLE = 1 << 2,
10 INHIBIT_HANDLE_POWER_KEY = 1 << 3,
11 INHIBIT_HANDLE_SUSPEND_KEY = 1 << 4,
12 INHIBIT_HANDLE_HIBERNATE_KEY = 1 << 5,
13 INHIBIT_HANDLE_LID_SWITCH = 1 << 6,
14 _INHIBIT_WHAT_MAX = 1 << 7,
15 _INHIBIT_WHAT_INVALID = -1
16 } InhibitWhat;
17
18 typedef enum InhibitMode {
19 INHIBIT_BLOCK,
20 INHIBIT_DELAY,
21 _INHIBIT_MODE_MAX,
22 _INHIBIT_MODE_INVALID = -1
23 } InhibitMode;
24
25 #include "logind.h"
26
27 struct Inhibitor {
28 Manager *manager;
29
30 sd_event_source *event_source;
31
32 char *id;
33 char *state_file;
34
35 bool started;
36
37 InhibitWhat what;
38 char *who;
39 char *why;
40 InhibitMode mode;
41
42 pid_t pid;
43 uid_t uid;
44
45 dual_timestamp since;
46
47 char *fifo_path;
48 int fifo_fd;
49 };
50
51 Inhibitor* inhibitor_new(Manager *m, const char *id);
52 void inhibitor_free(Inhibitor *i);
53
54 int inhibitor_save(Inhibitor *i);
55 int inhibitor_load(Inhibitor *i);
56
57 int inhibitor_start(Inhibitor *i);
58 int inhibitor_stop(Inhibitor *i);
59
60 int inhibitor_create_fifo(Inhibitor *i);
61 void inhibitor_remove_fifo(Inhibitor *i);
62
63 InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm);
64 bool manager_is_inhibited(Manager *m, InhibitWhat w, InhibitMode mm, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid, Inhibitor **offending);
65
66 const char *inhibit_what_to_string(InhibitWhat k);
67 InhibitWhat inhibit_what_from_string(const char *s);
68
69 const char *inhibit_mode_to_string(InhibitMode k);
70 InhibitMode inhibit_mode_from_string(const char *s);