mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 23:29:48 +01:00
Get active VT via ioctl instead of sysfs after e90c5c6347
(#1448)
This commit is contained in:
parent
ff9bcb19fa
commit
c3adc9ec56
1 changed files with 18 additions and 6 deletions
|
@ -2,6 +2,15 @@
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#if defined(__linux__)
|
||||||
|
#include <linux/vt.h>
|
||||||
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
#include <dev/wscons/wsdisplay_usl_io.h>
|
||||||
|
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
|
#include <sys/consio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
CKeybindManager::CKeybindManager() {
|
CKeybindManager::CKeybindManager() {
|
||||||
// initialize all dispatchers
|
// initialize all dispatchers
|
||||||
|
|
||||||
|
@ -442,13 +451,16 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
|
||||||
const unsigned int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
|
const unsigned int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
|
||||||
|
|
||||||
// vtnr is bugged for some reason.
|
// vtnr is bugged for some reason.
|
||||||
const std::string TTYSTR = execAndGet("head -n 1 /sys/devices/virtual/tty/tty0/active").substr(3);
|
|
||||||
unsigned int ttynum = 0;
|
unsigned int ttynum = 0;
|
||||||
try {
|
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
ttynum = std::stoll(TTYSTR);
|
struct vt_stat st;
|
||||||
} catch (std::exception& e) {
|
if (!ioctl(0, VT_GETSTATE, &st))
|
||||||
; // oops?
|
ttynum = st.v_active;
|
||||||
}
|
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
|
int vt;
|
||||||
|
if (!ioctl(0, VT_GETACTIVE, &vt))
|
||||||
|
ttynum = vt;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ttynum == TTY)
|
if (ttynum == TTY)
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue