summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2019-06-02 16:43:06 -0400
committerLuke Shumaker <lukeshu@datawire.io>2019-06-02 16:43:06 -0400
commit669dc2a61bd22030a6d922616b31af878e6d2f8d (patch)
treeda8f9a1952d9f4abda9b887a58fba47ed160187e
parent8c94ca486138a5a07f67e0fa5c35073bc7f4ce3b (diff)
add .local/bin/get-res
-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
+)