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: " & 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