Question

Every morning I come to work, plug in my sleeping laptop into the large monitor on my desk, and then fiddle with this dialog:

screenshot of KDE

I imagine that the result of this fiddling is that the "Display Settings" app writes the new monitor configuration to some file, and then sends some signal to the window manager to notice that the settings have changed. I would like to do this myself and control it directly, for this purpose as well as others.

If I could find out the name of the process that produces the ‘Display Settings’ dialog I could run it with strace and see what it is doing, but I haven't been able to find that out either.

My questions are:

To what program does this dialog belong? What would I look for in the ps output to identify it? And what is it actually doing when it changes the monitor configuration?

Was it helpful?

Solution

The xrandr utility can be controlled from a script. The configuration shown in the screenshot can be obtained by running the command:

xrandr \
 --output LVDS-1 --mode 1680x1050 --pos 1080x1120 --rotate normal \ 
 --output DVI-D-1 --off --output VGA-1 --mode 1920x1080 --pos 0x0 --rotate left          

To generate this command line, I used arandr. It presents a dialog something like the one in the original question, but simpler, and then has a "save" option which saves the correct xrandr invocation to a file.

After using the arandr dialog to configure the monitors the way I want them, I save the configuration to a file, say ~/.screenlayout/office.sh. Executing this file as a shell script restores the saved configuration. I wrote a trivial shell script, disp, which executes $HOME/.screenlayout/$1.sh, so when I get to the office I just type disp office on the command line to restore the office monitor configuration. When I go home I type disp 1, which runs ~/.screenlayout/1.sh, where I have saved the default one-monitor configuration.

Still no answers to the other questions in my post, although probably the dialog in the original question is running xrandr itself to change the screen configuration.

[ Update 2018-04-08: I have continued to use disp, which is no longer trivial. The current version is at https://github.com/mjdominus/util/blob/master/bin/disp . One improvement is that it has a -c flag to support shell programmable completion, which I set up like this:

    complete -F __complete_disp disp

    __complete_disp () {
        COMPREPLY=($(disp -c "$2"))
    }

Since I wrote this reply, KDE itself has gotten smarter about using the right display configuration. It usually seems to recognize which monitors are plugged in and to remember the configuration from last time they were the same, so I find myself using disp much less than before. Sometimes, though, it gets confused, and then it is convenient to be able to reset the configuration with disp. ]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top