summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.local/bin/get-res27
1 files changed, 27 insertions, 0 deletions
diff --git a/.local/bin/get-res b/.local/bin/get-res
new file mode 100755
index 0000000..2094f54
--- /dev/null
+++ b/.local/bin/get-res
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+# Copyright 2019 Luke Shumaker
+
+(
+ export LC_ALL=C
+xrandr | sed -rn -e 's@(.*) connected( .*)? ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+)( .*)? ([0-9]+)mm x ([0-9]+)mm( .*)?@\1 \3 \4@p'
+# 1 2 3 4 5 6 7 8 9 10
+# `-outputName | `-fb_xpx `-fb_ypx `-fb_xoff `-fb_yoff `- hw_xmm `- hw_ymm |
+# `-discard `- discard `- discard
+) | (
+ case $# in
+ 0)
+ cat
+ ;;
+ 1)
+ while read -r output x y; do
+ if [[ $output == "$1" ]]; then
+ printf '%s %s\n' "$x" "$y"
+ fi
+ done
+ ;;
+ *)
+ echo 'Usage: get-res [OUTPUT]' >&2
+ exit 2
+ ;;
+ esac
+)