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
Merged

Added getedid script #968

merged 1 commit into from
Dec 18, 2016

Conversation

DaVukovic
Copy link
Contributor

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

Copy link
Collaborator

@awiouy awiouy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first code review
Hope it is useful

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is working properly

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe != instead of = then, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"$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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will do

@CvH CvH added the FEATURE label Nov 22, 2016
@DaVukovic
Copy link
Contributor Author

Did some changes ^^

@MilhouseVH
Copy link
Contributor

@MilhouseVH
Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/>.
+################################################################################
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Contributor

@MilhouseVH MilhouseVH Nov 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remount


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a space before ].

fi

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing / - should be:

    sys_path="/flash/EFI/BOOT"

@MilhouseVH
Copy link
Contributor

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
Copy link
Contributor Author

changes done ^^

@chewitt chewitt merged commit cce0158 into LibreELEC:master Dec 18, 2016
@DaVukovic DaVukovic deleted the getedid branch January 3, 2017 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants