Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the current virtual terminal

I am working around a problem in Ubuntu 10.04 where after resume, the mouse cursor disappears.

This can be "fixed" by running chvt 1; chvt 7 in a script in /etc/pm/sleep.d, such that those commands run on thaw and resume.

However, the X console is not always vt #7, so chvt 7 is wrong in those cases.

What I would like to do is find out the current vt in the fix-up script and make sure I change back to that vt.

How can I find the current vt? (tty(1) just reports "not a tty")

like image 965
camh Avatar asked Jun 14 '10 01:06

camh


1 Answers

Check if 'fgconsole' does what you need. Seems to work for me (eg, returns 7 and I'm currently in X)

like image 94
bdk Avatar answered Sep 28 '22 08:09

bdk