Results 1 to 10 of 12

Thread: HOWTO: Convenient monitor switching with ATI's fglrx

Threaded View

  1. #1
    Join Date
    Dec 2006

    Default HOWTO: Convenient monitor switching with ATI's fglrx


    Being a mobile user who uses linux(currently 2.6.18-1.2849.fc6) and fglrx(8.31.5) I had a nasty problem of switching between being mobile and using the internal monitor and being at my desk and using an external one. I don't know how it works in other distros/drivers but in my setup the Function F8 key didn't do anything once everything was loaded.

    Using ati's new dynamic display management I devised a more convient API that mimicks Windows. It is only tested in the "clone mode" setup.

    Goals: It cycles through modes(LCD only, CRT Only, LCD + CRT).

    1.) Create a file called ".0.switch" in your home directory. There should be one in each user's home directory that switches between mobile and desktop use, btw it should be owned by each of the respective users.

    2.) Below is the code for a file called:
    if   cat $HOME/.0.switch  ; then
    rm -f $HOME/.0.switch
    touch $HOME/.1.switch
    #We then run what each switch number entails: 
    #1: CRT On, LCD Off
    #2: LCD + CRT On
    #3: LCD On, CRT Off reset switches to 1
    if  cat $HOME/.1.switch ; then
    aticonfig --enable-monitor=crt1
    rm -f $HOME/.1.switch
    touch $HOME/.2.switch;
    elif  cat $HOME/.2.switch ; then
    aticonfig --enable-monitor=lvds,crt1
    rm -f $HOME/.2.switch
    touch $HOME/.3.switch;
    elif  cat $HOME/.3.switch ; then
    aticonfig --enable-monitor=lvds
    rm -f $HOME/.3.switch
    touch $HOME/.0.switch;
    Place this in the directory /usr/bin and chmod it to 755.

    Now do a quick test and type: "sh", with any luck it should switch to a CRT-only mode. Run the comand again and you'll get CRT+LCD mode, and again to get LCD-only mode.

    3.) Lastly you can/should map a custom command to run when you press certain keys. Rather then repeat the tutorial here I will supply a link: Gnome Custom key shortcuts.

    Note: The command you want to run is sh (or monitorSwitch if you follow the extra step below)
    Note #2: You can map it to "Func-F8" if you are fancy enough to map that keycode into your keymap... rather then go through that hoopla I'd reccomend making it "<CTRL><SHIFT>F8".
    Note #3: KDE users you are on your own on mapping the keyboard shortcut.

    Optional Step
    If you are like me and want a clean "monitorSwitch" command to switch monitors you can compile and place the resulting exectuable in your /usr/bin directory.
    #include <cstdlib>
    using namespace std;
    int main()
    	return system("sh /usr/bin/ >> /dev/null");
    Compile it with the command: "g++ monitorSwitch.cpp -o monitorSwitch".
    Move the resulting exectuable(monitorSwitch) to /usr/bin and make sure it is chmoded to 755. Now executing "monitorSwitch" instead of "sh" will switch monitors.
    Note: You still need in the /usr/bin directory! All the exectuable does is run the sh command on that script.

    Hopefully this is useful to people. I wrote it for my system and it seems to work so far.

    At some point I'd like to address some of the drawbacks of this solution. Now it just uses that file so it cycles between modes indeterminent of what mode you are in or what monitors are connected(like a TV in an S-Video port for instance). The script should determine the connected monitors and be "smart" to will determine what to cycle. Also it would be nice to automatically adjust the screen resolution from mode to mode(in the ***-only modes). At some point I may add that functionality in or if someone else does please amend the thread.
    Last edited by koolmanoncampus; 12-28-2006 at 07:48 PM. Reason: Fixing a few spelling mistakes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts