This is probably linux-specific question...
I am running multiple virtual sessions and switching between them using "Ctrl+Alt+Fn". I am trying to write a script which would trigger some actions after I switch in/out of consoles.
I understand that I can read /sys/class/tty/tty0/active device to see which is currently active virtual console:
$ cat /sys/class/tty/tty0/active
tty2
Now, how do I identify which virtual tty am I actually running in? tty command does not return that information:
$ tty
/dev/pts/0
$DISPLAY also shows :0, not tty2. How can I determine that I am indeed running in tty2?