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