Skip to content

Instantly share code, notes, and snippets.

@alepez
Created February 1, 2018 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alepez/bded337bf72a30c8755013fdc5b0ba7e to your computer and use it in GitHub Desktop.
Save alepez/bded337bf72a30c8755013fdc5b0ba7e to your computer and use it in GitHub Desktop.
Shell script to programmatically list xrandr output modes
#!/bin/sh
output=""
xrandr | while read line; do
if echo "${line}" | grep 'connected' > /dev/null; then
if echo "${line}" | grep ' connected' > /dev/null; then
output="$( echo "${line}" | sed 's/\(.*\) connected.*/\1/' )"
fi
elif ! echo "${line}" | grep '^Screen' > /dev/null; then
echo "${output}:$( echo "${line}" | awk '{ print $1 }' )"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment