backend/session: Allow setting a custom tty via WLR_DIRECT_TTY
Niklas Schulze authored 5 years ago
emersion committed 5 years ago
154 | 154 | } |
155 | 155 | |
156 | 156 | static bool setup_tty(struct direct_session *session, struct wl_display *display) { |
157 | int fd = open("/dev/tty", O_RDWR | O_CLOEXEC); | |
157 | ||
158 | bool default_tty = false; | |
159 | ||
160 | const char *tty_path = getenv("WLR_DIRECT_TTY"); | |
161 | ||
162 | if (!tty_path) { | |
163 | tty_path = "/dev/tty"; | |
164 | default_tty = true; | |
165 | } | |
166 | ||
167 | int fd = open(tty_path, O_RDWR | O_CLOEXEC); | |
158 | 168 | if (fd == -1) { |
159 | wlr_log_errno(WLR_ERROR, "Cannot open /dev/tty"); | |
169 | wlr_log_errno(WLR_ERROR, "Cannot open %s", tty_path); | |
160 | 170 | return false; |
161 | 171 | } |
162 | 172 | |
175 | 185 | goto error; |
176 | 186 | } |
177 | 187 | |
178 | if (kd_mode != KD_TEXT) { | |
188 | if (default_tty && kd_mode != KD_TEXT) { | |
179 | 189 | wlr_log(WLR_ERROR, |
180 | 190 | "tty already in graphics mode; is another display server running?"); |
181 | 191 | goto error; |