LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-02-2010, 05:39 AM   #1
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Automating Xorg RandR turning laptop screen off if external monitor is connected


Hi all,

I have a netbook (Acer Aspire One) I'm running Slackware 13. and usually, I prefer to connect an external monitor. When I switch my machine on with the monitor connected, the display is duplicated on both screens and since I just want the netbook's screen to be off and only see the display on the external monitor, I can do

xrandr --output LVDS --off

Great! However, it's a hassle to do this every time I log in and I'd like to automate the process if possible. I did some googling and I found that if you want to automate xrandr commands, you can put a script in /etc/X11/Xsession.d/ (see this). I wrote the following script to automate my xrandr commands and since the Xsession.d directory didn't exist, I tried creating it. The script was called 45custom-xrandr_settings, as the one on the RandR wiki is called the same.

Code:
#!/bin/bash

# Check whether the external monitor is connected
xrandr | grep VGA | grep " connected "

# 0 is returned on success
if [ $? -eq 0 ]; then
  xrandr --output LVDS --off
fi
However, when I start my machine with the monitor attached, the script does not seem to be executed (and yes, execute permissions were set!). The script itself works fine, which I know since I executed it manually. I've also tried putting the commands in ~/.xinitrc and /etc/X11/xinit/xinitrc.kde, but they're all ignored.

So, what is the correct way to automate xrandr commands under Slack?
 
Old 01-02-2010, 06:00 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
I'm not sure that this is quite the answer you're looking for, but I've run into the same problem with my main laptop and the only automatic solution I found was to have the external monitor listed as the first monitor in xorg.conf. The console displays in both monitors, but X displays in just the external when it is attached. When unattached, the laptop monitor is used.
 
1 members found this post helpful.
Old 01-02-2010, 10:01 AM   #3
aocab
Member
 
Registered: Nov 2009
Location: Heart of Texas
Distribution: Slackware-current
Posts: 138

Rep: Reputation: 30
I myself have to run xrandr to adjust my monitors
resolution / color depth...(or the machine starts in a
higher resolution and lower color depth than I want)

I start in init 4 and am using kde.

I ended up putting the commands in the /etc/kde/kdm/Xsetup file.
And my screens resolution is set to what I want while kdm is starting.

If you are using kdm/kde, maybe you could try and run
your script from this file?

HTH
Cheers
 
1 members found this post helpful.
Old 01-02-2010, 10:07 AM   #4
DonnieP
Member
 
Registered: Jan 2008
Location: Richmond, VA USA
Distribution: Slackware
Posts: 144

Rep: Reputation: 29
Exactly where you put it depends on how you get into X in the first place. In my case I boot to console and use startx. My xinitrc has this in it at the bottom:

xrandr --output LVDS --off --output VGA --mode 1920x1080

# Start the window manager:
startlxde
 
2 members found this post helpful.
Old 01-02-2010, 11:15 AM   #5
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Hangdog42 View Post
I'm not sure that this is quite the answer you're looking for, but I've run into the same problem with my main laptop and the only automatic solution I found was to have the external monitor listed as the first monitor in xorg.conf. The console displays in both monitors, but X displays in just the external when it is attached. When unattached, the laptop monitor is used.
Thanks for that. The solution below works fine for me. Perhaps you could find something equivalent, for your desktop environment?

Quote:
Originally Posted by aocab View Post
I myself have to run xrandr to adjust my monitors
resolution / color depth...(or the machine starts in a
higher resolution and lower color depth than I want)

I start in init 4 and am using kde.

I ended up putting the commands in the /etc/kde/kdm/Xsetup file.
And my screens resolution is set to what I want while kdm is starting.

If you are using kdm/kde, maybe you could try and run
your script from this file?

HTH
Cheers
Works like a charm. Thank you!

Quote:
Originally Posted by DonnieP View Post
Exactly where you put it depends on how you get into X in the first place. In my case I boot to console and use startx. My xinitrc has this in it at the bottom:

xrandr --output LVDS --off --output VGA --mode 1920x1080

# Start the window manager:
startlxde
Ahh, I didn't realise that. I start in runlevel 4, using KDE and KDM. Again, the solution posted by aocab works.

Thanks everyone!
 
1 members found this post helpful.
Old 08-02-2010, 11:20 AM   #6
mwildam
Member
 
Registered: Sep 2006
Location: Vienna, Austria
Distribution: Fedora 13, Ubuntu 10.04
Posts: 52

Rep: Reputation: 15
First I want to thank Nylex for posting the script - I am on Ubuntu and experienced the same issue - and more difficult - after login I already saw everything fine and something switched away again after a ~ 5 seconds delay.

So for me this topic was a great help but not sufficient.

Anybody still experiencing the issue after trying what has been posted above, have a look at http://it-tactics.blogspot.com/2010/...g-station.html
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
External Monitor setting through xorg.conf kagashe Ubuntu 1 04-23-2008 12:46 AM
Screen Resolution problems connected with xorg.conf and xorgconfig with Slackware 10 tvisher Linux - Newbie 17 04-03-2007 07:39 AM
External Monitor with VGA cable to Laptop --->Blue Screen alpharm Linux - Laptop and Netbook 2 11-02-2006 11:14 AM
Xorg setup with external monitor k4ution Slackware 2 11-18-2004 06:05 PM
Laptop connected to external monitor codegomer Linux - General 0 04-21-2004 12:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:30 AM.

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