Skip to content

Instantly share code, notes, and snippets.

@konglie
Created July 29, 2015 15:51
Show Gist options
  • Save konglie/5f8c95e5b2b890e811f8 to your computer and use it in GitHub Desktop.
Save konglie/5f8c95e5b2b890e811f8 to your computer and use it in GitHub Desktop.
#!/bin/bash
dt=$(mktemp);
xrandr &> "$dt";
scr_size(){
read width height <<<$(IFS="x";echo $1);
size=$(($width * $height));
echo $size;
}
scr="default";
found="0";
lsize=0;
xline="";
set_max(){
xline=$1;
}
while read line; do
if [ $found = "0" ]; then
if [[ $line =~ "$scr connected" ]]; then
found="1";
fi;
continue;
fi;
if [ "$found" = "1" ]; then
if [[ "$line" =~ "connected" ]]; then
break;
fi;
scrsize=$(scr_size $line);
if [ $scrsize -gt $lsize ]; then
lsize=$scrsize;
set_max $line;
fi;
fi;
done < $dt;
echo "Max: $xline";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment