Background: Having to use HP laptops at work, I configured mine to use only an external monitor when docked with the lid closed (in Windows). When I took the laptop out of the docking station, I had one smaller desktop on the laptop display. To me, this represents the way to replace a desktop with a laptop. Most other people used both the laptop display and an external monitor when docked, but I never have liked that configuration because of the differences in screen size.
I have looked for a way to do this in Kubuntu over the last several days, and found only one post that comes close: http://forum.kde.org/viewtopic.php?f...217119#p217119
Last week, I finally bought a new machine (HP dv6-6c48US), and installed Kubuntu 12.04. Everything worked until I tried connecting my external monitor (LG W2240) via VGA cable. The radeon drivers would not show anything on the external monitor. After much searching, and fiddling, I declared defeat and installed the proprietary AMD drivers (video in this laptop: ATI HD 6620G), and got VGA output immediately. Configuring dual monitor support using amdcccle worked immediately, but I could only find ways to have both adapters working at the same time.
What I would like: If someone would provide a little help, I would like to write scripts to do the following:
1. Change "lid closed" event to disable LVDS if VGA-0 connected (and do nothing else). If VGA-0 not connected, "lid closed" should continue to work normally.
2. Connecting VGA-0 should disable LVDS -- disconnecting VGA-0 should enable LVDS.
3. "Lid open" event should always enable LVDS when VGA-0 not connected.
The goal is to have exactly one desktop, which moves between the two displays. The system should allow only one active display at a time.
Minor sidelight: If I can make this work using the radeon drivers instead of the proprietary AMD fglrx drivers, I'll switch back to those. So far I haven't had any luck with the radeon driver and the external monitor. Also, the laptop should use FN-F4 to enable VGA, but that doesn't seem to do anything at all (I changed BIOS so this machine uses FN-F4 instead of plain F4 -- WIFI starts and stops on FN-F12 as expected). If possible, I would like to add a script to FN-F4 event to toggle the displays.
If anyone knows how to do any of this, please let me know. Otherwise, if I can get some pointers, I'll write the scripts, test them, and post my results back here.
Hardware: HP dv6-6c48US, with Mobility Radeon 6620G VGA compatible controller. This controller supports laptop (LVDS), external VGA (VGA-0), and HDMI displays: LVDS 1366 x 768, 60 Hz. External VGA-0 display: LG W2240, 1920 x 1080, 51 Hz.
Software: Kubuntu 12.04, recent updates applied, Currently using proprietary ATI/AMD FGLRX graphics driver because default radeon driver wouldn't send signal to VGA port.
Update 16-May-2012:
1. Built a bootable USB thumb-drive and played with the radeon driver. I cannot get any output on the VGA port with this driver and believe it has a problem with support for auxiliary output ports. Xrandr commands can't seem to do a thing. The ATI fglrx driver works with the VGA port (haven't tried HDMI).
2. I checked the scripts that manage configuration of multiple display ports, and built a skeleton script to detect active displays. Then I found a script on another site which toggles through display ports. I haven't tested that one yet.
3. I played with xrandr using the ATI proprietary driver, and can get roughly the settings I desire. However, it appears that I should use aticonfig with the ATI driver, and this requires disabling randr support. I'll look into that next.
4. Using the "/lib/udev/findkeyboards" and "/lib/udev/keymap -i input/event3" commands (under a tty session) shows that FN-F4 generates scan code 0x19 and keymap "p". The documentation which I found on setting keymaps gives the rudiments for changing settings, but doesn't go into great detail. I still need to see what script sets the other keymaps (which I found do exist).
5. Luckily, it appears that 12.04 has one needed feature. If you navigate to "Settings -> System Settings -> Power Management -> On .... -> Button events handling", there exists settings which allows for "Do nothing" on laptop lid closed. These settings cover "On AC Power / On Battery / on Low Battery". Setting "Do nothing" for "On AC Power" takes care of one requirement for simulating a docked PC with only one active (external) monitor.
6. With only one desktop, enabling the higher resolution external display and killing the laptop display causes the desktop to move as desired, but the panel goes to an odd position. I have my panel set to cover about 80% of the laptop display (centered). Kicking the display to the external monitor causes the panel to go left (or mostly left depending on sizing). Seems the panel keeps settings from the previous display. The "new activity" gizmo also goes to a position per the previous display.
Update 03-Jun-2012:
1. Used toggle-display.sh (see: https://wiki.archlinux.org/index.php/Xrandr) successfully to change screens. This script just uses xrandr, and from looking at the script, it appears that changing screens the way I want requires one trick. This script always disables the active screen, then enables the other. However, when initially connecting the external monitor, the first run of toggle-display.sh kills the external monitor and switches the laptop monitor to its correct resolution. The subsequent runs toggle the display correctly (so I'll have to change the script to fix the problem with the first execution). Anyway, here's the action per my testing:
a. Use amdcccle to configure one desktop on multiple displays.
b. While running with only laptop display ( 1366 x 768 ) connected, I connect the external monitor.
c. Both displays drop down to resolution they both can handle ( 1280 x 768 ), and the one desktop appears on both displays.
d. First run of toggle-display.sh disables external monitor, and enables laptop monitor. Laptop monitor goes back to 1366x768 resolution.
e. Next run of toggle-display.sh disables laptop monitor, and then enables external monitor. External monitor goes to desired resolution ( 1920 x 1080 ). Panel goes to center of display (as desired), and only the "New Activity" gizmo goes to the wrong spot (which you can fix by parking it in the upper left instead of upper right).
f. Subsequent toggles work as desired.
g. Pulling the plug on the external monitor (when active) causes the laptop display to become active, but requires another run of toggle-display.sh to get laptop monitor to display the correct resolution.
This all works close to the way I want, but I haven't discovered how to force a script to run when connecting a new display.
2. I had the mapping for FN-F4 partially wrong. The mapping actually goes to 0xDB - 0x19 (yes, two key mappings). This equates to "leftmeta" - "p" (aka: Windows key - p). Apparently HP decided to be good little boys and follow what Microsoft provided (no matter how non-standard). This mapping apparently handles configuring displays in Windows. However, this causes a real problem with Linux key mappings. If you search online, you find several recommendations for adding ACPI settings to disable this action.
3. Tried adding ACPI settings in GRUB to disable the silly two-key combination for FN-F4, but could not make any of the recommended changes work. Finally abandoned that approach, and just mapped the key in KDE. To do this:
- Copy toggle-display.sh to /usr/bin and mark as executable.
- Navigate to "Settings - System Settings - Shortcuts and Gestures".
Under "Custom Shortcuts", add a new group and give it a name (e.g. "Video Switching").
Add an action under this group (e.g. "Toggle Display").
Switch to the "Trigger" tab, click the button beside "Shortcut:", and press FN-F4. The button should then display "Meta+p" for this mapping.
Finally, go to the "Action" tab, and set "Command/URL" to "bash /usr/bin/toggle-display.sh".
After this sad work-around, FN-F4 will toggle between displays as mentioned above.
Based on having toggle-display.sh work pretty well, I ought to boot the USB thumb drive and see if it works with the non-proprietary display driver (radeon).
I now have two things to do in this minor project: 1) determine how to force a script to execute after connecting an external monitor, and 2) modify toggle-display.sh so that it works correctly on the first execution following the connection of an external monitor.
So far, I have received no help from anyone on this forum. If anyone knows how to force a script to execute after connecting an external monitor, please let me know.
I have looked for a way to do this in Kubuntu over the last several days, and found only one post that comes close: http://forum.kde.org/viewtopic.php?f...217119#p217119
Last week, I finally bought a new machine (HP dv6-6c48US), and installed Kubuntu 12.04. Everything worked until I tried connecting my external monitor (LG W2240) via VGA cable. The radeon drivers would not show anything on the external monitor. After much searching, and fiddling, I declared defeat and installed the proprietary AMD drivers (video in this laptop: ATI HD 6620G), and got VGA output immediately. Configuring dual monitor support using amdcccle worked immediately, but I could only find ways to have both adapters working at the same time.
What I would like: If someone would provide a little help, I would like to write scripts to do the following:
1. Change "lid closed" event to disable LVDS if VGA-0 connected (and do nothing else). If VGA-0 not connected, "lid closed" should continue to work normally.
2. Connecting VGA-0 should disable LVDS -- disconnecting VGA-0 should enable LVDS.
3. "Lid open" event should always enable LVDS when VGA-0 not connected.
The goal is to have exactly one desktop, which moves between the two displays. The system should allow only one active display at a time.
Minor sidelight: If I can make this work using the radeon drivers instead of the proprietary AMD fglrx drivers, I'll switch back to those. So far I haven't had any luck with the radeon driver and the external monitor. Also, the laptop should use FN-F4 to enable VGA, but that doesn't seem to do anything at all (I changed BIOS so this machine uses FN-F4 instead of plain F4 -- WIFI starts and stops on FN-F12 as expected). If possible, I would like to add a script to FN-F4 event to toggle the displays.
If anyone knows how to do any of this, please let me know. Otherwise, if I can get some pointers, I'll write the scripts, test them, and post my results back here.
Hardware: HP dv6-6c48US, with Mobility Radeon 6620G VGA compatible controller. This controller supports laptop (LVDS), external VGA (VGA-0), and HDMI displays: LVDS 1366 x 768, 60 Hz. External VGA-0 display: LG W2240, 1920 x 1080, 51 Hz.
Software: Kubuntu 12.04, recent updates applied, Currently using proprietary ATI/AMD FGLRX graphics driver because default radeon driver wouldn't send signal to VGA port.
Update 16-May-2012:
1. Built a bootable USB thumb-drive and played with the radeon driver. I cannot get any output on the VGA port with this driver and believe it has a problem with support for auxiliary output ports. Xrandr commands can't seem to do a thing. The ATI fglrx driver works with the VGA port (haven't tried HDMI).
2. I checked the scripts that manage configuration of multiple display ports, and built a skeleton script to detect active displays. Then I found a script on another site which toggles through display ports. I haven't tested that one yet.
3. I played with xrandr using the ATI proprietary driver, and can get roughly the settings I desire. However, it appears that I should use aticonfig with the ATI driver, and this requires disabling randr support. I'll look into that next.
4. Using the "/lib/udev/findkeyboards" and "/lib/udev/keymap -i input/event3" commands (under a tty session) shows that FN-F4 generates scan code 0x19 and keymap "p". The documentation which I found on setting keymaps gives the rudiments for changing settings, but doesn't go into great detail. I still need to see what script sets the other keymaps (which I found do exist).
5. Luckily, it appears that 12.04 has one needed feature. If you navigate to "Settings -> System Settings -> Power Management -> On .... -> Button events handling", there exists settings which allows for "Do nothing" on laptop lid closed. These settings cover "On AC Power / On Battery / on Low Battery". Setting "Do nothing" for "On AC Power" takes care of one requirement for simulating a docked PC with only one active (external) monitor.
6. With only one desktop, enabling the higher resolution external display and killing the laptop display causes the desktop to move as desired, but the panel goes to an odd position. I have my panel set to cover about 80% of the laptop display (centered). Kicking the display to the external monitor causes the panel to go left (or mostly left depending on sizing). Seems the panel keeps settings from the previous display. The "new activity" gizmo also goes to a position per the previous display.
Update 03-Jun-2012:
1. Used toggle-display.sh (see: https://wiki.archlinux.org/index.php/Xrandr) successfully to change screens. This script just uses xrandr, and from looking at the script, it appears that changing screens the way I want requires one trick. This script always disables the active screen, then enables the other. However, when initially connecting the external monitor, the first run of toggle-display.sh kills the external monitor and switches the laptop monitor to its correct resolution. The subsequent runs toggle the display correctly (so I'll have to change the script to fix the problem with the first execution). Anyway, here's the action per my testing:
a. Use amdcccle to configure one desktop on multiple displays.
b. While running with only laptop display ( 1366 x 768 ) connected, I connect the external monitor.
c. Both displays drop down to resolution they both can handle ( 1280 x 768 ), and the one desktop appears on both displays.
d. First run of toggle-display.sh disables external monitor, and enables laptop monitor. Laptop monitor goes back to 1366x768 resolution.
e. Next run of toggle-display.sh disables laptop monitor, and then enables external monitor. External monitor goes to desired resolution ( 1920 x 1080 ). Panel goes to center of display (as desired), and only the "New Activity" gizmo goes to the wrong spot (which you can fix by parking it in the upper left instead of upper right).
f. Subsequent toggles work as desired.
g. Pulling the plug on the external monitor (when active) causes the laptop display to become active, but requires another run of toggle-display.sh to get laptop monitor to display the correct resolution.
This all works close to the way I want, but I haven't discovered how to force a script to run when connecting a new display.
2. I had the mapping for FN-F4 partially wrong. The mapping actually goes to 0xDB - 0x19 (yes, two key mappings). This equates to "leftmeta" - "p" (aka: Windows key - p). Apparently HP decided to be good little boys and follow what Microsoft provided (no matter how non-standard). This mapping apparently handles configuring displays in Windows. However, this causes a real problem with Linux key mappings. If you search online, you find several recommendations for adding ACPI settings to disable this action.
3. Tried adding ACPI settings in GRUB to disable the silly two-key combination for FN-F4, but could not make any of the recommended changes work. Finally abandoned that approach, and just mapped the key in KDE. To do this:
- Copy toggle-display.sh to /usr/bin and mark as executable.
- Navigate to "Settings - System Settings - Shortcuts and Gestures".
Under "Custom Shortcuts", add a new group and give it a name (e.g. "Video Switching").
Add an action under this group (e.g. "Toggle Display").
Switch to the "Trigger" tab, click the button beside "Shortcut:", and press FN-F4. The button should then display "Meta+p" for this mapping.
Finally, go to the "Action" tab, and set "Command/URL" to "bash /usr/bin/toggle-display.sh".
After this sad work-around, FN-F4 will toggle between displays as mentioned above.
Based on having toggle-display.sh work pretty well, I ought to boot the USB thumb drive and see if it works with the non-proprietary display driver (radeon).
I now have two things to do in this minor project: 1) determine how to force a script to execute after connecting an external monitor, and 2) modify toggle-display.sh so that it works correctly on the first execution following the connection of an external monitor.
So far, I have received no help from anyone on this forum. If anyone knows how to force a script to execute after connecting an external monitor, please let me know.