Skip to content

Commit

Permalink
Use more complex sed script that works also on older systems
Browse files Browse the repository at this point in the history
  • Loading branch information
schlomo committed Jun 26, 2014
1 parent 9b6de79 commit ad048f2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion automirror.sh
Expand Up @@ -38,7 +38,8 @@ xrandr_current="$($XRANDR_STATUS_PROGRAM)"

# find connected displays
connected_displays=( $(sed -n -e 's/^\(.*\) connected.*mm$/\1/p' <<<"$xrandr_current") )
display_list="$(sed -z -e 's/\n / /g' <<<"$xrandr_current" | sed -n -e 's/^\([A-Z0-9_-]\+\) connected.* \([0-9]\+\)mm.* \([0-9]\+\)mm.* \([0-9]\+\)x\([0-9]\+\)[ 0-9\.\*]\++.*$/\1 \2 \3 \4 \5/p' )"
# See http://stackoverflow.com/a/1252191/2042547 for how to use sed to replace newlines
display_list="$(sed ':a;N;$!ba;s/\n / /g' <<<"$xrandr_current" | sed -n -e 's/^\([A-Z0-9_-]\+\) connected.* \([0-9]\+\)mm.* \([0-9]\+\)mm.* \([0-9]\+\)x\([0-9]\+\)[ 0-9\.\*]\++.*$/\1 \2 \3 \4 \5/p' )"
: ${connected_displays[@]}
: "$display_list"

Expand Down

0 comments on commit ad048f2

Please sign in to comment.