Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Let me preface my question with the following: I am pretty sure that I can hack together a solution by modifying /usr/share/xsessions/somesessionfile.desktop and make it run /etc/X11/Xsession, and get it to work that way, but I would still like to clear a few things up.

Setup: 12.04, completely fresh installation(3 hours old, maybe). Want to use xmonad as my WM. Dual-head setup.

My question: I am thoroughly, or rather utterly, confused about which program is doing what, regarding X , unity, login managers(or whatever they are called) and window managers. I am using xmonad as my window manager, I know this much. And when I log in, or perhaps even earlier, I want my dual monitors to be set up properly using a script that runs xrandr(that I already have working). Everyone I talk to or whose questions I read online talk about xinitrc, ~/.xsession or /etc/X11/xsession, but none of these files are being run. The files in /usr/share/xsesssions seem to be the only files that are being run, and I cannot for the life of me find any documentation about any of this.

Where is the consistency in this system? What, exactly, am I supposed to do if I want to do this properly? Some window managers seem to do this(KDE and gnome seem to have something just called 'autostart'). Am I supposed to let my window manager handle this, X, or lightdm? I understand there are probably dozens of files in the startup process that I could possibly put this in, but I'm asking for the proper convention. What is the solution, for something like this?

TL;DR; Is there one, consistent way for me to run a script automatically for every window manager that runs on top of X, or does this depend entirely upon the combination of window managers and login managers I am using?

share|improve this question
add comment

2 Answers

Many thanks for the "What happens under the cover..." link, a must read !

~/.xprofile happens too early, the xrandr settings are lost.

One solution is to create a script and execute it in the "applications on startup". Though, since nautilus is already launched and it will decide to display the icons on the secondary monitor (after the xrandr command), I added at the end :

killall -1 nautilus
nautilus -n

Dirty but works. Hope this helps.

share|improve this answer
add comment

I believe you may find this will work for you. It will be sourced by dash script /usr/sbin/lightdm-session which will later execute the exec for the window manager.

Assuming that this is just for you, and because it is related to X, I'd suggest putting it into ~/.xprofile. If it will apply to every user of the system, /etc/xprofile may be more appropriate.

Create a file ~/.xprofile and edit it to contain something your xrandr command (similar to the following test item):

xrandr --output LVDS --mode 1280x854

You can find more information at What happens under the covers to log me in and start up the Unity Graphics User Interface?. It does cover some of what happens for non-unity window managers.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.