Is it possible to turn off a HDMI output using xrandr in tty?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is it possible to turn off a HDMI output using xrandr in tty?
I use a netbook connected to an external display with a HDMI cable. I have a following line added to ~/.xsession to automatically disable netbtook screen after logging in Xorg:
When HDMI is unplugged the screen in Xorg is black and I can just switch to tty to operate the machine. Therefore, I want to find a way to bring LVDS back on and disable a HDMI screen in Xorg after unplugging a HDMI cable. I can remove the above line from ~/.xsession and restart Xorg but I don't want to start all programs again and lose unsaved shell history inside xterm. I tried to switch to tty and run xrandr but it doesn't work:
I get the same error on Ubuntu with Xorg in version 1.15.1 and xrandr in version 1.4.1 and Slackware with Xorg in version 1.12.3 and xrandr in version 1.4.1. Do you have any clue on what this error means and how to overcome this?
EDIT: The error is still there after copying values of all variables that start with X inside xterm to tty:
i don't quite understand what you are trying to do.
however - tty refers to a non-graphical console.
but apps starting with x refer to the Xserver or Xorg, which is a graphical environment.
in other words, they will not work in a tty.
What's specifically not clear in my question? I want to use xrandr in tty. And yes, it's possible to execute X programs on a particular display in tty because this works:
yes, it's possible if you have an xsession running on another tty.
so, in that way, you can do anything for that xsession that you could do when you switch to that xsession and do it from there.
however, i think the changes will not carry over to the tty you're in. because xrandr is an X utility.
yes, it's possible if you have an xsession running on another tty.
so, in that way, you can do anything for that xsession that you could do when you switch to that xsession and do it from there.
however, i think the changes will not carry over to the tty you're in. because xrandr is an X utility.
Ok, I know that. My question is whether anybody knows what does this error mean and how can I make xrandr turn off/on a given source from tty. As I described, after unplugging HDMI cable before enabling LVDS I need to remove an aforementioned line from ~/.xsession file and restart X server because netbook screen is turned off. If my question is not clear tell me that and I will fix it.
I don't think that duplicating makes sense. This command works flawlessly inside X. My current thought is that xrandr does not work inside tty because in such case X is not a parent process.
It's a shame you didn't even read my question. I know how xrandr works. It can be run inside TTY. I don't know how to make it turn on/off a given input from TTY. I want to know how to do it and it cannot be done to learn why it cannot be done for 1) curiosity 2) in case I forgot to enable LVDS before unplugging HDMI
This is probably a language difficulty.
I certainly did read your question very carefully, trying to understand your desire, and answered it as I understood the meaning.
Quote:
I know how xrandr works. It can be run inside TTY. I don't know how to make it turn on/off a given input from TTY.
To a native English speaker, the quoted sentences are a nonsense, leaving the reader with an oxymoron.
Are you asking for a method to automatically detect when the HDMI cable is disconnected and, if so, automatically re-enable the LVDS display?
It may be possible, dependent on the hardware, but it seems rather pointless. If you are going to take the positive action to unplug the HDMI cable, then that should be a prompt to initially revert the display.
Do you unplug the power cable and expect the netbook to automatically shutdown? Or, do you do the sensible thing, shutdown the netbook, then unplug the power cable?
Computers are tools, treat them well and they serve you well. Do not expect them to be intelligent and forgiving of thoughtless behavior. Abuse them at your own risk.
Distribution: K/Ubuntu 18.04-14.04, Scientific Linux 6.3-6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,802
Rep:
If you are trying to issue a command to a given display, but you're not in that display, you have to use the environment command to do so... I think this is why you are having problems...
For example: I have an issue where in KDE I need to issue the xset command to turn off DPMS because there is a bug in KDE that reactivates DPMS when certain applications are run (VLC and HandBrake as two examples),... and activates screen blanking after really short durations (10-30 seconds), making watching video impossible. So,... I have a user cron job running to deactivate DPMS every minute. To do that, I have to use env to set the display for which I am issuing the xset command, otherwise the command does nothing. If I was on that display and issuing the command, it wouldn't matter, since it is implied that I'm issuing the command to the active display I'm in. But cron isn't being issued from the tty that is the active display... So I have to set the environment to the primary display for it to work.
I think you have to do something similar. You are (or seem to be) issuing the xrandr command from a tty other than the display you wish to activate.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.