dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 30abe38b1de9fa6f81859aa1d42463a780fc6f62
parent a55a96aa7ce0c1fddf95629898acc26b967d1269
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Fri, 25 Sep 2020 14:00:10 +0200

mon: allow setting INT and EXT as environment variables

Diffstat:
M.local/bin/mon | 31++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/.local/bin/mon b/.local/bin/mon @@ -1,8 +1,8 @@ #!/bin/sh -int=eDP-1 int_dpi=315 -ext=HDMI-1 +if [ -z "$INT" ]; then INT=eDP-1; fi +if [ -z "$EXT" ]; then EXT=HDMI-1; fi res_from_xrandr() { awk -v disp="$1" ' @@ -14,9 +14,9 @@ res_from_xrandr() { find_res() { xrandr_q="$(xrandr -q)" - res_int="$(printf '%s' "$xrandr_q" | res_from_xrandr "$int")" - if printf '%s' "$xrandr_q" | grep -q "${ext} connected"; then - res_ext="$(printf '%s' "$xrandr_q" | res_from_xrandr "$ext")" + res_int="$(printf '%s' "$xrandr_q" | res_from_xrandr "$INT")" + if printf '%s' "$xrandr_q" | grep -q "${EXT} connected"; then + res_ext="$(printf '%s' "$xrandr_q" | res_from_xrandr "$EXT")" fi res_int_x="${res_int%x*}" @@ -35,14 +35,14 @@ die() { int() { xrandr --dpi "$int_dpi" --fb "$res_int" \ - --output "$int" --mode "$res_int" --scale 1x1 \ - --output "$ext" --off + --output "$INT" --mode "$res_int" --scale 1x1 \ + --output "$EXT" --off } ext() { xrandr --dpi "$int_dpi" --fb "$res_int" \ - --output "$int" --off \ - --output "$ext" --mode "${res_ext}" \ + --output "$INT" --off \ + --output "$EXT" --mode "${res_ext}" \ --scale "${res_factor}x${res_factor}" \ --panning "$res_int" } @@ -50,8 +50,8 @@ ext() { dual() { xrandr --dpi "$int_dpi" \ --fb "$(printf '%d*2\n' "$res_int_x" | bc)x${res_int_y}" \ - --output "$int" --primary --mode "${res_int}" --scale 1x1 \ - --output "$ext" --mode "${res_ext}" \ + --output "$INT" --primary --mode "${res_int}" --scale 1x1 \ + --output "$EXT" --mode "${res_ext}" \ --pos "${res_int_x}x0" \ --scale "${res_factor}x${res_factor}" \ --panning "${res_int}+${res_int_x}+0" @@ -60,14 +60,11 @@ dual() { mirror() { xrandr --dpi "$int_dpi" \ --fb "$(printf '%d+%d\n' "$res_int_x" "$res_ext_x" | bc)x${res_int_y}" \ - --output "$int" --auto --scale 1x1 \ - --output "$ext" --mode "${res_ext}" \ - --same-as "$int" --scale "${res_factor}x${res_factor}" + --output "$INT" --auto --scale 1x1 \ + --output "$EXT" --mode "${res_ext}" \ + --same-as "$INT" --scale "${res_factor}x${res_factor}" } -if [ $# -gt 1 ]; then - ext="$2" -fi find_res if [ $# -eq 0 ] || [ -z "$res_ext" ]; then int