From 37333afc34060696b74742b913d4efc4c3515f10 Mon Sep 17 00:00:00 2001 From: Simon Long Date: Tue, 1 Mar 2022 09:49:57 +0000 Subject: [PATCH] Put overscan settings in separate shell script --- raspi-config | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/raspi-config b/raspi-config index 3bc7283..fc06ffa 100755 --- a/raspi-config +++ b/raspi-config @@ -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 + 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 - 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 "#!/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