Skip to content

Instantly share code, notes, and snippets.

@juliangroen
Last active July 19, 2020 15:12
Show Gist options
  • Save juliangroen/70566dd4723c3bd6c972b241b45f39d9 to your computer and use it in GitHub Desktop.
Save juliangroen/70566dd4723c3bd6c972b241b45f39d9 to your computer and use it in GitHub Desktop.
Bash script to get current resolution values from xrandr. Use -h for horizontal and -v for vertical.
#!/bin/bash
str=`xrandr | grep '*'`
IFS='x'
read -ra ADDR <<< "$str"
IFS=' '
read -ra ADDR2 <<< "${ADDR[1]}"
while getopts 'hv' flag; do
case "${flag}" in
h) echo "${ADDR[0]:3}" ;;
v) echo "${ADDR2[0]}" ;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment