Put overscan settings in separate shell script

This commit is contained in:
Simon Long 2022-03-01 09:49:57 +00:00
parent 715b391f1b
commit 37333afc34

View File

@ -329,7 +329,7 @@ do_overscan() {
}
get_overscan_kms() {
RES=$(grep "HDMI-$1" /usr/share/dispsetup.sh | grep margin | rev | cut -d ' ' -f 1 | rev)
RES=$(grep "HDMI-$1" /usr/share/ovscsetup.sh 2> /dev/null | grep margin | rev | cut -d ' ' -f 1 | rev)
if [ -z $RES ] ; then
echo 1
elif [ $RES -eq 0 ] ; then
@ -343,7 +343,7 @@ do_overscan_kms() {
if [ "$INTERACTIVE" = True ]; then
NDEVS=$(xrandr -q | grep -c connected)
if [ $NDEVS -gt 1 ] ; then
DEV=$(whiptail --menu "Select the output for which overscan is to be set" 20 60 10 "1" "HDMI-1" "2" "HDMI-2" 3>&1 1>&2 2>&3)
DEV=$(whiptail --menu "Select the output for which overscan compensation is to be set" 20 60 10 "1" "HDMI-1" "2" "HDMI-2" 3>&1 1>&2 2>&3)
if [ $? -eq 1 ] ; then
return
fi
@ -373,10 +373,17 @@ do_overscan_kms() {
xrandr --output HDMI-$DEV --set "left margin" $PIX --set "right margin" $PIX --set "top margin" $PIX --set "bottom margin" $PIX
sed $CONFIG -i -e "s/^overscan_/#overscan_/"
set_config_var disable_overscan 1 $CONFIG
if grep "HDMI-$DEV" /usr/share/dispsetup.sh | grep -q margin ; then
sed /usr/share/dispsetup.sh -i -e "s/xrandr --output HDMI-$DEV.*margin.*/xrandr --output HDMI-$DEV --set \"left margin\" $PIX --set \"right margin\" $PIX --set \"top margin\" $PIX --set \"bottom margin\" $PIX/"
if [ -e /usr/share/ovscsetup.sh ] ; then
if grep "HDMI-$DEV" /usr/share/ovscsetup.sh 2> /dev/null | grep -q margin ; then
sed /usr/share/ovscsetup.sh -i -e "s/xrandr --output HDMI-$DEV.*margin.*/xrandr --output HDMI-$DEV --set \"left margin\" $PIX --set \"right margin\" $PIX --set \"top margin\" $PIX --set \"bottom margin\" $PIX/"
else
sed /usr/share/dispsetup.sh -i -e "s/exit/xrandr --output HDMI-$DEV --set \"left margin\" $PIX --set \"right margin\" $PIX --set \"top margin\" $PIX --set \"bottom margin\" $PIX\nexit/"
echo "xrandr --output HDMI-$DEV --set \"left margin\" $PIX --set \"right margin\" $PIX --set \"top margin\" $PIX --set \"bottom margin\" $PIX" >> /usr/share/ovscsetup.sh
fi
else
echo "#!/bin/sh\nxrandr --output HDMI-$DEV --set \"left margin\" $PIX --set \"right margin\" $PIX --set \"top margin\" $PIX --set \"bottom margin\" $PIX" > /usr/share/ovscsetup.sh
fi
if ! grep -q ovscsetup /usr/share/dispsetup.sh 2> /dev/null ; then
sed /usr/share/dispsetup.sh -i -e "s#exit#if [ -e /usr/share/ovscsetup.sh ] ; then\n. /usr/share/ovscsetup.sh\nfi\nexit#"
fi
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "Display overscan compensation for HDMI-$DEV is $STATUS" 20 60 1