]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/login/logind.h
man: document that 'loginctl activate' only takes a single argument
[thirdparty/systemd.git] / src / login / logind.h
CommitLineData
20263082
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
c2f1db8f 3#pragma once
20263082
LP
4
5/***
6 This file is part of systemd.
7
8 Copyright 2011 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
20263082
LP
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 18 Lesser General Public License for more details.
20263082 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
20263082
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
24#include <stdbool.h>
25#include <inttypes.h>
20263082
LP
26#include <libudev.h>
27
cc377381
LP
28#include "sd-event.h"
29#include "sd-bus.h"
20263082
LP
30#include "util.h"
31#include "list.h"
32#include "hashmap.h"
cc377381 33#include "set.h"
20263082 34
20263082 35typedef struct Manager Manager;
20263082 36
90821c93
LP
37#include "logind-device.h"
38#include "logind-seat.h"
39#include "logind-session.h"
40#include "logind-user.h"
f8e2fb7b 41#include "logind-inhibit.h"
069cfc85 42#include "logind-button.h"
23406ce5 43#include "logind-action.h"
20263082 44
f9cd6be1
LP
45#define IGNORE_LID_SWITCH_STARTUP_USEC (3 * USEC_PER_MINUTE)
46#define IGNORE_LID_SWITCH_SUSPEND_USEC (30 * USEC_PER_SEC)
47
20263082 48struct Manager {
cc377381
LP
49 sd_event *event;
50 sd_bus *bus;
20263082
LP
51
52 Hashmap *devices;
53 Hashmap *seats;
54 Hashmap *sessions;
55 Hashmap *users;
f8e2fb7b 56 Hashmap *inhibitors;
069cfc85 57 Hashmap *buttons;
cc377381
LP
58
59 Set *busnames;
20263082 60
14c3baca
LP
61 LIST_HEAD(Seat, seat_gc_queue);
62 LIST_HEAD(Session, session_gc_queue);
63 LIST_HEAD(User, user_gc_queue);
64
20263082 65 struct udev *udev;
718d006a 66 struct udev_monitor *udev_seat_monitor, *udev_device_monitor, *udev_vcsa_monitor, *udev_button_monitor;
30ed21ce 67
cc377381
LP
68 sd_event_source *console_active_event_source;
69 sd_event_source *udev_seat_event_source;
70 sd_event_source *udev_device_event_source;
71 sd_event_source *udev_vcsa_event_source;
72 sd_event_source *udev_button_event_source;
20263082 73
20263082 74 int console_active_fd;
20263082 75
3f49d45a 76 unsigned n_autovts;
20263082 77
98a77df5
LP
78 unsigned reserve_vt;
79 int reserve_vt_fd;
80
92432fcc 81 Seat *seat0;
20263082 82
3f49d45a 83 char **kill_only_users, **kill_exclude_users;
20263082 84 bool kill_user_processes;
98a28fef
LP
85
86 unsigned long session_counter;
f8e2fb7b 87 unsigned long inhibit_counter;
1713813d 88
fb6becb4
LP
89 Hashmap *session_units;
90 Hashmap *user_units;
8c8c4351 91
eecd1362 92 usec_t inhibit_delay_max;
069cfc85 93
314b4b0a
LP
94 /* If an action is currently being executed or is delayed,
95 * this is != 0 and encodes what is being done */
96 InhibitWhat action_what;
97
98 /* If a shutdown/suspend was delayed due to a inhibitor this
99 contains the unit name we are supposed to start after the
100 delay is over */
101 const char *action_unit;
102
103 /* If a shutdown/suspend is currently executed, then this is
104 * the job of it */
105 char *action_job;
106 usec_t action_timestamp;
af9792ac 107
cc377381 108 sd_event_source *idle_action_event_source;
23406ce5
LP
109 usec_t idle_action_usec;
110 usec_t idle_action_not_before_usec;
111 HandleAction idle_action;
112
113 HandleAction handle_power_key;
114 HandleAction handle_suspend_key;
115 HandleAction handle_hibernate_key;
116 HandleAction handle_lid_switch;
3c56cab4 117 HandleAction handle_lid_switch_docked;
beaafb2e
LP
118
119 bool power_key_ignore_inhibited;
8e7fd6ad
LP
120 bool suspend_key_ignore_inhibited;
121 bool hibernate_key_ignore_inhibited;
beaafb2e 122 bool lid_switch_ignore_inhibited;
31b79c2b 123
66cdd0f2
LP
124 bool remove_ipc;
125
cc377381 126 Hashmap *polkit_registry;
f9cd6be1
LP
127
128 sd_event_source *lid_switch_ignore_event_source;
1c231f56
LP
129
130 size_t runtime_dir_size;
20263082
LP
131};
132
20263082
LP
133Manager *manager_new(void);
134void manager_free(Manager *m);
14c3baca 135
718d006a 136int manager_add_device(Manager *m, const char *sysfs, bool master, Device **_device);
069cfc85 137int manager_add_button(Manager *m, const char *name, Button **_button);
20263082 138int manager_add_seat(Manager *m, const char *id, Seat **_seat);
9444b1f2 139int manager_add_session(Manager *m, const char *id, Session **_session);
20263082
LP
140int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user);
141int manager_add_user_by_name(Manager *m, const char *name, User **_user);
142int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
f8e2fb7b 143int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **_inhibitor);
14c3baca 144
30ed21ce 145int manager_process_seat_device(Manager *m, struct udev_device *d);
069cfc85
LP
146int manager_process_button_device(Manager *m, struct udev_device *d);
147
20263082
LP
148int manager_startup(Manager *m);
149int manager_run(Manager *m);
92bd5ff3 150int manager_spawn_autovt(Manager *m, unsigned int vtnr);
20263082 151
4a4b033f 152void manager_gc(Manager *m, bool drop_not_started);
14c3baca 153
405e0255
LP
154bool manager_shall_kill(Manager *m, const char *user);
155
a185c5aa
LP
156int manager_get_idle_hint(Manager *m, dual_timestamp *t);
157
9444b1f2 158int manager_get_user_by_pid(Manager *m, pid_t pid, User **user);
9b221b63
LP
159int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session);
160
2d62c530 161bool manager_is_docked(Manager *m);
6a79c586 162int manager_count_displays(Manager *m);
3c56cab4 163bool manager_is_docked_or_multiple_displays(Manager *m);
2d62c530 164
cc377381 165extern const sd_bus_vtable manager_vtable[];
3f49d45a 166
ebcf1f97
LP
167int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
168int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
169int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
170int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
171int match_name_owner_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
1713813d 172
cc377381 173int bus_manager_shutdown_or_sleep_now_or_later(Manager *m, const char *unit_name, InhibitWhat w, sd_bus_error *error);
069cfc85 174
cc377381 175int manager_send_changed(Manager *manager, const char *property, ...) _sentinel_;
9418f147 176
d889a206 177int manager_dispatch_delayed(Manager *manager);
eecd1362 178
ba4c5d93 179int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, const char *after, const char *after2, sd_bus_error *error, char **job);
cc377381
LP
180int manager_start_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
181int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
5f41d1f1 182int manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *error);
cc377381 183int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo, sd_bus_error *error);
fb6becb4 184int manager_unit_is_active(Manager *manager, const char *unit);
cc377381 185int manager_job_is_active(Manager *manager, const char *path);
fb6becb4 186
f975e971
LP
187/* gperf lookup function */
188const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length);
e8b212fe
DH
189
190int manager_watch_busname(Manager *manager, const char *name);
191void manager_drop_busname(Manager *manager, const char *name);
f9cd6be1
LP
192
193int manager_set_lid_switch_ignore(Manager *m, usec_t until);
1c231f56
LP
194
195int config_parse_tmpfs_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);