LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 06-14-2015, 02:11 PM   #1
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Rep: Reputation: 220Reputation: 220Reputation: 220
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:

Code:
xrandr --output HDMI-0 --mode 1280x768 --output LVDS --off
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:

Code:
$ DISPLAY=:0.0 xrandr --verbose --output LVDS --auto
xrandr: Configure crtc 0 failed
crtc 0:     1024x600   60.0 +0+0 "LVDS"
crtc 0: disable
crtc 1: disable
screen 0: revert
crtc 0: revert
crtc 1: revert
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:
Code:
$ env | egrep "^X"
XDG_SESSION_COOKIE=6d01d6298e7d38fd0f15422900000027-1434302274.386423-728739996
XTERM_SHELL=/bin/bash
XDG_CONFIG_DIRS=/etc/xdg:/etc/rox/xdg
XTERM_VERSION=X.Org 7.6.0(281)
XTERM_LOCALE=en_US.UTF-8

Last edited by average_user; 06-20-2015 at 03:14 PM.
 
Old 06-16-2015, 09:22 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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.
 
Old 06-16-2015, 09:41 AM   #3
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
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:

Code:
 DISPLAY=:0.0 xrandr -q
 
Old 06-18-2015, 07:41 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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.
 
Old 06-18-2015, 11:20 AM   #5
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by ondoho View Post
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.
 
Old 06-19-2015, 12:32 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
ok, i re-read your first post and understand better now.

xrandr has a --verbose switch, could you provide that output, too?

is :0,0 really the display you want to switch off? or maybe :0,1 or :1,0? (i don't know myself, it's just a thought)

are you sure you want to switch off LVDS or LVDS1 or VGA or?

have you tried various xrandr commands from within th running xsession? maybe the same one?

i did a little searching and there sems to be a few answers to the topic, but nothing conclusive yet.

Quote:
Originally Posted by average_user View Post
When HDMI is unplugged the screen in Xorg is black and I can just switch to tty to operate the machine.
i think the problem lies here.
seems to have something to do with drivers, from what little searching i did.

edit:
this looks relevant: http://askubuntu.com/questions/40564...-from-terminal

Last edited by ondoho; 06-19-2015 at 12:39 AM.
 
Old 06-20-2015, 03:13 PM   #7
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by ondoho View Post
xrandr has a --verbose switch, could you provide that output, too?
Output I pasted in my first is already result of running xrandr with --verbose switch. Sorry for pasting a wrong listing, I added "--verbose" now.
Quote:
Originally Posted by ondoho View Post
This discussion does not present a solution to my problem.

EDIT:
I guess that Xorg mailing list would be a better place to ask this question. It seems that it's not that common to use xrandr inside tty.

Last edited by average_user; 06-20-2015 at 03:15 PM.
 
Old 06-25-2015, 05:13 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
it cannot hurt to post as much information (terminal output) about your problem as possible, even if part of it is duplicate.

and trying out everything someone suggests.
 
Old 06-26-2015, 04:46 PM   #9
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
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.

I tried all your suggestions - that means none.
 
Old 06-27-2015, 06:18 PM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
it makes me wonder why you even bothered to post a question here.
it seems you know all the answers already.
 
Old 06-27-2015, 09:06 PM   #11
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
If this command turns on the HDMI output and turns off the netbook screen
Code:
xrandr --output HDMI-0 --mode 1280x768 --output LVDS --off
then this command should turn off the HDMI output and turn on the netbook screen.
Code:
xrandr --output HDMI-0 --off --output LVDS --auto
That would be best run _before_ unplugging the HDMI cable.
 
1 members found this post helpful.
Old 07-02-2015, 05:56 AM   #12
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
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
 
Old 07-03-2015, 07:54 AM   #13
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
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.
 
Old 07-04-2015, 08:07 AM   #14
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
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: Reputation: 157Reputation: 157
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xrandr does not see HDMI zsp Linux - Hardware 1 10-07-2014 01:47 AM
using xrandr to turn screen off/on like mate-display-properties Lop3 Linux - Software 3 11-08-2013 10:48 AM
I screwed up my HDMI port with xrandr Ranko Kohime Linux - Hardware 11 11-05-2013 03:56 PM
Is it possible to play Blu Ray through a video card HDMI output to HDMI TV? SharpyWarpy Linux - Hardware 5 10-28-2012 01:01 AM
How to turn on log for tty device yan Linux - General 0 12-08-2003 04:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration