Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added getedid script #968

Merged
merged 1 commit into from Dec 18, 2016

Conversation

Projects
None yet
5 participants
@DaVukovic
Copy link
Contributor

commented Nov 22, 2016

This is a newer version for the getedid script which contains the changes @MilhouseVH mentioned in the previous PR

@awiouy
Copy link
Contributor

left a comment

My first code review
Hope it is useful

@@ -0,0 +1,254 @@
#!/bin/sh

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

Add LE header

rm -fr /storage/.config/firmware
sys_reboot
else
echo "You don't have a backup file for $file. You didn't used this script to create the custom EDID"

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

did not use

sys_reboot
else
echo "You don't have a backup file for $file. You didn't used this script to create the custom EDID"
echo "Therefore we can't be sure the script working prooerly. Exiting"

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

is working properly

check_file() {
# check boot system
boot="$([ -d /sys/firmware/efi ] && echo UEFI || echo BIOS)"
if [ "$boot" = "BIOS" ]; then

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

would be clearer:
if -d... then
boot=... sys_path=...
else
boot=... sys_path=...
fi


#check which file is available
if [ -f "$sys_path"/syslinux.cfg ] && [ -f "$sys_path"/extlinux.conf ];then
echo "Your system contains both. A /flash/syslinux.cfg and a /flash/extlinux.conf file"

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

both a

check_content() {
# check if changes are already made to $file and exit if yes
if [ "$(grep "APPEND" $file)" = " APPEND boot=LABEL=System disk=LABEL=Storage ssh quiet" ]; then
echo "You alread did some changes to $file. Exiting."

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

already

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

i do not understand, how can you know that the user made exactly these changes?

This comment has been minimized.

Copy link
@DaVukovic

DaVukovic Nov 22, 2016

Author Contributor

AFAIK this is the standard content of the APPEND line after a fresh install

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

maybe != instead of = then, no?

This comment has been minimized.

Copy link
@DaVukovic

DaVukovic Nov 22, 2016

Author Contributor

True ;)

echo "You didn't created a custom EDID yet or you didn't use this script for this task."
echo "Therefore we can't ensure the script working properly."
echo "Exiting"
exit 3

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

you exit in rw mode, move mount_rw between if and else

mv /storage/.config/xorg.conf /storage/.config/xorg.le.backup
else
echo "You don't have a xorg.conf in your .config folder. Exiting"
exit 7

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

here, too: you exit in rw mode

sed -i 's/"ModeDebug" "true"/"ModeDebug" "false"/g' /storage/.config/xorg.conf

# set port and uncomment lines
sed -i "s/# Option \"ConnectedMonitor\" \"DFP-0\"/ Option \"ConnectedMonitor\" \"$nv_port\"/g" /storage/.config/xorg.conf

This comment has been minimized.

Copy link
@awiouy

awiouy Nov 22, 2016

Contributor

Are the seded lines invariable (they exist and are never edited)?

This comment has been minimized.

Copy link
@DaVukovic

DaVukovic Nov 22, 2016

Author Contributor

The lines I change by using sed can ofc be edited by the user before. But therefore I check if a xorg.conf already exists and exit if yes. If the user already did some changes to the xorg.conf, he's also able to do that a 2nd time ;) and then won't need that script

fi

#check which file is available
if [ -f "$sys_path"/syslinux.cfg ] && [ -f "$sys_path"/extlinux.conf ];then

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 22, 2016

Contributor

"$sys_path"/syslinux.cfg ->"$sys_path/syslinux.cfg"
"$sys_path"/extlinux.conf ->"$sys_path/extlinux.conf"

and the same wherever this has been repeated. Presumably it works as it is, but I find it a little odd.

This comment has been minimized.

Copy link
@DaVukovic

DaVukovic Nov 22, 2016

Author Contributor

ok, will do

@CvH CvH added the FEATURE label Nov 22, 2016

@DaVukovic

This comment has been minimized.

Copy link
Contributor Author

commented Nov 22, 2016

Did some changes ^^

@MilhouseVH

This comment has been minimized.

Copy link
Contributor

commented Nov 23, 2016

@MilhouseVH

This comment has been minimized.

Copy link
Contributor

commented Nov 23, 2016

You should also chmod 775 the getedid file, like the other scripts in the same folder.

help() {
echo "This script generates a custom EDID depending on your GPU"
echo ""
echo "To check which GPU you are using, use: ./getedid gpu"

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

Assuming this script will eventually be on the users PATH, you shouldn't then instruct them to use ./getedid gpu because this won't work - it assumes the script is in the users current directory, when it won't be.

Change all uses of ./getedid to simply getedid.

#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
+################################################################################

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

Two ++ here - cut & paste error? Please remove the "+" at the beginning of the line.

echo ""
echo "To check which GPU you are using, use: ./getedid gpu"
echo ""
echo "To create a custon EDID, just use this script like: ./getedid start"

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

getedid start is a little odd, what am I starting? Why not getedid create as this is more in keeping with the other delete and restore options.

#check which output is connnected:
for i in /sys/class/drm/*; do
if [ "$(cat "$i"/status 2>/dev/null)" = "connected" ]; then
hdmi="$(echo "$i" | cut -d / -f 5 | sed 's/card[0-9]-//g')"

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

break?

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

Also, you need to keep the card0- prefix, at least on my Skylake, in which case you just need:

      hdmi="$(basename "$i")"

#create edid
mkdir -p /storage/.config/firmware/edid
cat "/sys/class/drm/$hdmi/edid" > /storage/.config/firmware/edid/edid.bin

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

Binary data... dunno, maybe use cp instead?


# mounting /flash to rw
mount_rw() {
mount -o remout,rw /flash

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

remount


#remount /flash to rw
mount_rw
mv /storage/edid.cpio "$sys_path"

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

sys_path isn't known at this point, you haven't called check_file yet...

# check syslinux.cfg and/or extlinux.conf
check_file() {
# check boot system
if [ -d /sys/firmware/efi]; then

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

Needs a space before ].

fi

#check which file is available
if [ -f "$sys_path/syslinux.cfg" ] && [ -f "$sys_path/extlinux.conf" ];then

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

space between ; and then

I'd also rewrite the condition thus:

  if [ -f "$sys_path/syslinux.cfg" -a  -f "$sys_path/extlinux.conf" ]; then
# check boot system
if [ -d /sys/firmware/efi]; then
boot="UEFI"
sys_path="flash/EFI/BOOT"

This comment has been minimized.

Copy link
@MilhouseVH

MilhouseVH Nov 23, 2016

Contributor

Missing / - should be:

    sys_path="/flash/EFI/BOOT"
@MilhouseVH

This comment has been minimized.

Copy link
Contributor

commented Nov 23, 2016

For intel, are both /storage/.config/firmware/edid/edid.bin and /storage/cpio/lib/firmware/edid/edid.bin required? Or is the cpio folder just being used temporarily to create the cpio file (in which case, it's probably not required at all)?

@DaVukovic

This comment has been minimized.

Copy link
Contributor Author

commented Nov 26, 2016

changes done ^^

@chewitt chewitt merged commit cce0158 into LibreELEC:master Dec 18, 2016

@DaVukovic DaVukovic deleted the DaVukovic:getedid branch Jan 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.