LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Re-starting/initializing XServer Without Loosing Session? (https://www.linuxquestions.org/questions/linux-newbie-8/re-starting-initializing-xserver-without-loosing-session-939471/)

mrm5102 04-12-2012 10:09 AM

Re-starting/initializing XServer Without Loosing Session?
 
Hello All,

I'm trying to solve a little problem I'm having with my Laptop.

Here's some general info:
Code:

# uname -a
    Linux localhost 2.6.37.6-0.11-default #1 SMP 2011-12-19 23:39:38 +0100 i686 i686 i386 GNU/Linux

# cat SuSE-release
    openSUSE 11.4 (i586)
    VERSION = 11.4
    CODENAME = Celadon

# Xorg -version

    X.Org X Server 1.9.3
    Release Date: 2010-12-13
    X Protocol Version 11, Revision 0
    Build Operating System: openSUSE SUSE LINUX
    Current Operating System: Linux localhost 2.6.37.6-0.11-default #1 SMP 2011-12-19 23:39:38 +0100 i686
    Kernel command line: root=/dev/disk/by-id/ata-ST9250410AS_5VG9JNPG-part7 resume=/dev/disk/by-id/ata-ST9250410AS_5VG9JNPG-part6    splash=silent quiet vga=0x314
    Build Date: 07 February 2012  04:33:35PM
 
    Current version of pixman: 0.20.0
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.

When I'm using my laptop at work I keep it in a Docking Station which has my monitor, keyboard, mouse, etc...
And the problem I'm running into is that whenever I have to go to a meeting or anything like that where I may
need to bring it with me I need to either restart to whole computer all together or take it out of the Docking
Station and issue "CTR+ALT+Backspace". Or go into "nvidia-settings" and 'enable' my laptop screen then issue a
restart of X.


All of those options above are kind of a pain in the butt..!!

And obviously when you do either of these things you will have to close everything out first and start over
again after the reboot...

Does anyone know if when for instance, if I put the laptop to "sleep" or "hibernate", would it "re-read" the
xorg.conf file..? In other words does Xserver sort of "restart" when you come back after putting it to sleep/hibernate?
Because I'm thinking about scripting this out, where I might possibly replace the config file before putting it
to sleep, then upon awakening it would re-read the config file.

I got this idea from this link here (http://www.geekwisdom.com/dyn/node/241), but it doesn't work for my laptop even though it is also a Dell Latitude Laptop. I believe that he used xrandr and a bash script to accomplish it.
Must be have been done on an older version.

Any suggestions would be great...


Thanks in Advance,
Matt

VDP76 05-25-2012 06:57 PM

Hi Matt,

ok, this is an old thread and I don't know if in the mean while you have came up with a solution, but I'll give it a try.. ;)
Quote:

Originally Posted by mrm5102 (Post 4651097)
In other words does Xserver sort of "restart" when you come back after putting it to sleep/hibernate?

It is my understanding that hibernation is a sort of shut down, so I guess Xorg.conf should be read again at resume, I am not sure if the same applies to sleeping.

At the beginning, the script that you have linked in your post did not work for me as well. The problem was with a function supposed to check if the screen resolution adopted was actually supported by the monitor; after commenting that out, it worked! :D
Here it is the modified version:
Code:

#!/bin/bash

# Created: 20110908
# Author: Steve Moitozo <god at zilla dot us> -- geekwisdom.com
# License: MIT License (see below)
# Description:
#  This script does the heavy lifting of switching
#  display settings for various types of configurations:
#    Dualhead (laptop and dock-attached monitor)
#    Monitor only
#    Laptop only
#
# ---------------------------------------------------------------
# Copyright (c) 2006 Steve Moitozo <god at zilla dot us>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
#  The above copyright notice and this permission notice shall
# be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
# AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
# OR OTHER DEALINGS IN THE SOFTWARE.
#---------------------------------------------------------------

# Configuration
## Edit the following lines with the required outputs and modes.
## Be sure to use parameters which are supported by your monitors.
## Check it opening a terminal and typing "xrandr" without quotes.
LAPTOP_OUTPUT=eDP1
LAPTOP_OUTPUT_MODE=1440x900
MONITOR_OUTPUT=HDMI1
MONITOR_OUTPUT_MODE=1680x1050

case "$1" in
  dualhead)
    ### DOCKED DUAL HEAD
            # Activate the monitor
            xrandr --output $MONITOR_OUTPUT --mode $MONITOR_OUTPUT_MODE
            # Activate the laptop
            xrandr --output $LAPTOP_OUTPUT --mode $LAPTOP_OUTPUT_MODE
            # Monitor primary
            xrandr --output $MONITOR_OUTPUT --primary
            # Position the laptop to the right of the monitor
            xrandr --output $LAPTOP_OUTPUT --right-of $MONITOR_OUTPUT
    ;;
  monitor-only)
    ### DOCKED MONITOR ONLY
        # Monitor primary
        xrandr --output $MONITOR_OUTPUT --primary
        # Turn off laptop
        xrandr --output $LAPTOP_OUTPUT --off
        # Activate the monitor
        xrandr --output $MONITOR_OUTPUT --mode $MONITOR_OUTPUT_MODE
    ;;
  laptop-only)
    ### DOCKED LAPTOP ONLY
        # First, turn off monitor
        xrandr --output $MONITOR_OUTPUT --off
        # Activate the laptop
        xrandr --output $LAPTOP_OUTPUT --mode $LAPTOP_OUTPUT_MODE
    ;;
  *)
    echo "Usage: tweakdisp [dualhead|monitor-only|laptop-only]"
    ;;
esac
exit $?

Try this one and let's see how it goes...

Anyway, talking about automation at startup, I have realized that xrandx is a powerful tool for scripting, check this out: http://crunchbanglinux.org/forums/post/214037/#p214037.

Good luck ;)

mrm5102 05-29-2012 08:40 AM

Hey VDP76, thanks for your reply...

Na, I never found a solution to this problem. I kinda just gave up after a while, I felt like I was just going in circles with it and not getting much closer to the goal.

Cool, I'll give your changes to the script a try and see how it goes.
Also, I'll check out that link you posted for any other good info.

Thanks again for your suggestions, I appreciate your help!

Thanks Again,
Matt


All times are GMT -5. The time now is 10:31 AM.