Danilo Pianini's space
Automatically switch screen configuration when a new monitor is connected in Sabayon Linux
2012-05-20
Using often my laptop for presentations, I really got bored of manual switching the graphics every time a new monitor is connected. Thou KDE offers a functional utility in its control panel for that, I prefer my computer to switch automagically as soon as a screen connector is plugged in or removed. The following instructions will work for both Sabayon and Gentoo, and possibly under other Linux distributions like Ubuntu, Mint, SUSE, depending on where the configuration files are placed.
To see if you can trigger udev events related to monitor connected, run as root:
udevadm monitor --property
Now, if you try to plug and unplug a new monitor, you should see some events on your console, something like:
KERNEL[1303765357.560848] change /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
UDEV_LOG=0
ACTION=change
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
SUBSYSTEM=drm
HOTPLUG=1
DEVNAME=dri/card0
DEVTYPE=drm_minor
SEQNUM=2943
MAJOR=226
MINOR=0
If you can see that, you will be able to configure your monitor for the automatic switch. First:
cd /etc/udev/rules.d/
here are stored the udev rules. Let's create a new one. I will use nano, but every editor is ok.
nano 80-vga.rules
in the file, write the following, to intercept the monitor events:
ACTION=="change", SUBSYSTEM=="drm", HOTPLUG=="1", RUN+="/root/hotplug.sh"
The RUN variable will contain the path to a script which will be run when a new event is detected. I placed it in /root/hotplug.sh, but you may want to place it somewhere else.
Now, the script. I will quote mine, then explain:
#!/bin/sh
read STATUS < /sys/class/drm/card0-VGA-1/status
export DISPLAY=:0
export XAUTHORITY=/home/danysk/.Xauthority
if [ "$STATUS" = "connected" ]; then
xrandr --output VGA1 --right-of LVDS1 --auto --screen 0
else
xrandr --output VGA1 --off --screen 0
fi
So, this is what this simple script does:
- read the current status of the VGA connector (can be either "connected" or "disconnected");
- export the variables required in order to access the current running X (remember to change "danysk" to your user name!);
- verify the current status of the VGA connector and use xrandr to properly set it (i like to the right of my main screen, but you may set clone or whatever you like.
That's it. If you did it well, now your system reacts to plug and unplug operations automatically switching to the right configuration. Have fun :)
nVidia Optimus on Sabayon Linux: an happy ending story
2012-03-03
As promised, I'm back to keep you updated on the status of the nVidia Optimus support under Sabayon Linux. Thanks to the work of all the team (Joost, lxnay, micia, mva, and me too) Sabayon has now Bumblebee in its main repository. This simplifies a lot the whole process of installation. Currently, that's all you need to do:
* equo install bumblebee
* rc-update add bumblebee
* add your user to the bumblebee group
* reboot
All done. Your notebook won't warm any longer, your battery life will be greatly improved, and you can always use your nVidia discrete card when you need better performances. I've successfully tested it on ASUS N53S, ASUS ASUS X53SC-SX042V and ASUS 1215N.
When I'll have some spare time, I will run some benchmarks and report, stay tuned.
Bumblebee 3.0 on Sabayon and Gentoo Linux
2012-02-05
Here we are again. Some progresses have been done by the guys working at Bumblebee. Some interesting progresses. With the 3.0 release, they are now able to power off the discrete GPU when not used, allowing your notebook to drain less battery energy and last longer. Last but not least, it won't warm any longer.
The following how to worked for an ASUS X53SC-SX042V notebook powered by a GeForce GT520MX (not the 1215N I used for the previous guide). From now on, please follow this article and not the previous. All the commands are issued in a root shell.
Most of the useful staff was available in the mva overlay. Since I'm on Sabayon Linux, I ported the needed ebuilds to our sabayon overlay. So, for pure Gentoo users, there is a small step to do:
layman -a sabayon
This will download all the stuff you need. From now on, things should be the same for both Sabayon and Gentoo users.
- layman -S
Synchronizes all your ebuilds from the Sabayon overlay - emerge --sync
It's good to have also the latest stable version of the Portage tree :) - equo install nvidia-drivers libbsd help2man virtual/linux-sources:0 dev-perl/Locale-gettext:0
This will make things faster for Sabayon user, installing what is needed from binary pre-compiled packages. Pure Gentoo users can skip this step and just rely on the Portage dependency resolution system - USE="static-libs pic" emerge libjpeg-turbo::sabayon
Tells Portage to emerge the libjpeg-turbo package from the sabayon overlay, using the position independent code feature. This would cripple the performances on x86: amd64 version of your operating system is recommended in order to get the best - VIDEO_CARDS="nvidia" emerge bumblebee --autounmask-keep-masks
This will install all Bumblebee, BBSwitch and VirtualGL, configuring them for using the proprietary nVidia drivers - now you need to modify the file at /etc/bumblebee/bumblebee.conf, changing "VirtualDisplay=:8" to "VirtualDisplay=:1"
- add your user to the "bumblebee" group
- rc-update add bumblebee
Adds the bumblebee service to your startup - reboot
- That's it! From now on, your nVidia card will be shut down when unused, and you can use it to accelerate your workflow by launching
optirun commandname
commandname will run using your nVidia card. I tested it successfully with XMBC and glxgears.
Some final notes.
Please remember that if you switch your kernel, you'll need to install the new sources and to re-emerge bbswitch. Otherwise, it won't work.
As you may note, I have still not added any space for comments here. However, I opened a thread in the official Sabayon Linux forum: please use it as reference for comments and suggestions.
Enjoy your discrete card :)
UPDATE!!
The ebuilds in Sabayon overlay have been updated. Now it's no longer required to run USE="static-libs pic" emerge libjpeg-turbo::sabayon (it will actually return an error). Moreover, all this stuff is in Entropy: I wrote a new guide for Sabayon users to install all the required stuff without messing with Portage.
More Articles...
- Get nVidia Optimus working in Sabayon Linux with Bumblebee
- How to install an AMD Radeon HD6670, Linux and Windows comparison
- How to solve the dilemma of choosing a new video card
- The Witcher saved games
- Materiale per Fondamenti di Computer Graphics L-M
- Mass Effect saved games
- Materiale per Inglese L-B
- In risposta all'Ing Carlo Rossi
- Materiale per Ingegneria del Software L-A
- Materiale per Fondamenti di Elaborazione dei Segnali L
Page 1 of 16



