reactivate second monitor in el capitan My first attempt to run el capitan 10.11.0 on one of my macintoshes is with a mac mini using a dual monitor setup. 

There is one HDMI monitor Samsung Syncmaster and one DVI monitor Medion MD20429 connected via the display port with an adapter. 

After getting back from sleepmode the second monitor (DVI) does not come up by itself. In system setup / monitor it does not show and only
if i use the option key and click detect monitors (see e.g. http://osxdaily.com/2014/03/31/detect-displays-mac-os-x/)  will it come back.

My OS 10.9.5 Mavericks computers do not show this unwanted effect.


How can this El Capitan behavior be avoided? 
Is there at least a one-click
workaround somewhere?
is this a known bug to Apple?
This is a two part workaround:


an  applescript to click on the detect monitor
a bash script to run the script


I "saved" the applescript to $HOME/source/detectmonitor.scpt (see 
Run AppleScript from bash script) how to work around the issue that you can not really start with a text file ...

Then I saved the bashscript to $HOME/dm

I created a symbolic link
ln -s $HOME/Desktop/detectMonitors $HOME/bin/dm

and set my Terminal preferences according to https://stackoverflow.com/a/8822669/1497139

now i can double click "detectMonitors" on my Desktop to work around the issue.

Applescript to click "detect monitor" in monitor system preferences

see https://stackoverflow.com/questions/12640643/applescript-to-run-detect-displays

-- Script to click the "Detect Displays" button
-- 2015-12-22 WF
-- see https://stackoverflow.com/questions/12640643/applescript-to-run-detect-displays
-- adopt to your language settings by setting the right button name below
-- currently this is german "Monitore erkennen"
-- to create and run this script you need a compiled scpt file to begin with see
-- https://apple.stackexchange.com/questions/103621/run-applescript-from-bash-script
-- then you also need to set the security settings
tell application "System Preferences"
    activate
    reveal pane "com.apple.preference.displays"
end tell

delay 0.5

tell application "System Events"
    tell process "System Preferences"
        try --don't even consider not using a try block!
            key down option
            delay 0.5
            --click button "Detect Displays" of window 1
            click button "Monitore erkennen" of window 1
            delay 0.5
            key up option
            tell application "System Preferences"
                quit
            end tell
        on error errMsg --logging out is the only other way to clear these
            key up option
            display dialog "ERROR: " &amp; errMsg
        end try
    end tell
end tell


Bash-Script to run the applescript

#!/bin/bash
# WF 2015-12-22
# run detect monitors
cd $HOME/source/applescript
osascript detectmonitor.scpt
# set Terminal settings
# according to https://stackoverflow.com/a/8822669/1497139
# to get this to close your terminal window
exit 0