pimp xrandr script

This commit is contained in:
tavo-wasd 2024-08-25 13:05:48 -06:00
parent 4d94f87790
commit 120dbfd338

View file

@ -1,13 +1,23 @@
#!/bin/sh
LIST=`xrandr | sed '/ connected/!d;s/ .*$//'`
MONITORS=`printf '%s' "${LIST}" | tr '\n' ' '`
LIST="$(xrandr | sed '/ connected/!d;s/ .*$//')"
MONITORS="$(printf '%s' "${LIST}" | tr '\n' ' ')"
MIRR="$(printf 'Yes\nNo' | menu "Mirror monitors?:")"
CMD="$(FIRST=1 ; for i in ${MONITORS} ; do
CURR=`printf '%s' "${LIST}" | sed "/${LAST:=empty}/d" | menu "Next monitor (to right):"`
[ "${MIRR}" = "Yes" ] && CMD="$(FIRST=1 ; for i in ${MONITORS} ; do
CURR="${i}"
[ "${FIRST}" ] && printf 'xrandr --output %s' "${CURR}" && FIRST=
[ "${LAST}" ] && printf ' --same-as %s' "${CURR}"
LAST="${CURR}"
done)"
! [ "${CMD}" ] && CMD="$(FIRST=1 ; for i in ${MONITORS} ; do
CURR="$(printf '%s' "${LIST}" | sed "/${LAST:=empty}/d" | menu "Next monitor (to right):")"
[ -z "${CURR}" ] && exit 0
[ "${FIRST}" ] && printf 'xrandr --output %s' "${CURR}" && FIRST=
[ "${LAST}" ] && printf ' --left-of %s' "${CURR}"
LAST="${CURR}"
done)"
$($CMD)
CMD="xrandr --auto && $CMD"
[ "${CMD}" ] && eval "${CMD}"
printf '%s' "${CMD}"