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

"about" broken on parsing X config #87

Closed
mremski opened this issue May 9, 2019 · 1 comment
Closed

"about" broken on parsing X config #87

mremski opened this issue May 9, 2019 · 1 comment

Comments

Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
@mremski
Copy link

@mremski mremski commented May 9, 2019

Describe the bug
Typing "about" hangs for a long time and complains when it normally puts out the X config with:
grep: /var/log/Xorg.0.0.log: No such file or directory

To Reproduce
Steps to reproduce the behavior:
Simply type in "about"

Expected behavior
No hang, and info about X

Root cause is the DISPLAY variable and the cut command used at line 30 in /usr/local/bin/about.
Previous versions of echo $DISPLAY would show :0 on a single display, but now show :0.0 so the command on line 30 sees 0.0 as "field 2" in the command.
Changing the $(echo ${DISPLAY} | cut -d ":" -f 2) to $(echo ${DISPLAY} | cut -c 2) fixes it (NetMic2018 on Telegram posted this).

about also fails in a console (non-X session) and if run as root. X11 information should probably be gated by checking ${DISPLAY} being non zero length.

Patch for about:

diff --git a/core-files/usr/local/bin/about b/core-files/usr/local/bin/about
index c054591..97ce0c9 100755
--- a/core-files/usr/local/bin/about
+++ b/core-files/usr/local/bin/about
@@ -27,18 +27,22 @@ phys_mem=$(sysctl -n hw.physmem)
 phys_mem=`bc -e scale=2 -e ${phys_mem}/1073741824 -e quit`
 echo "  Physical Memory: ${phys_mem} GB"
 #Now detect the current GPU Driver
-xconf=$(grep "Using config file:" /var/log/Xorg.$(echo ${DISPLAY} | cut -d : -f 2).log | cut -d \" -f 2)
 echo "--------------------------------------"
-echo "X11 Information:"
-if [ -n "xconf" ] ; then
-  echo "  X11 Configuration File: ${xconf}"
-  echo "  X11 Driver Running: $(grep Driver ${xconf} | cut -d \" -f 2)"
+xdisp=$(echo ${DISPLAY} | cut -c 2)
+if [ -n "${xdisp}" ] ; then
+    xconf=$(grep "Using config file:" /var/log/Xorg.$xdisp.log | cut -d \" -f 2)
+    echo "X11 Information:"
+    if [ -n "${xconf}" ] ; then
+      echo "  X11 Configuration File: ${xconf}"
+      echo "  X11 Driver Running: $(grep Driver ${xconf} | cut -d \" -f 2)"
+    else
+      xconf="/usr/local/etc/X11/xorg.conf"
+      echo "  X11 Auto-Configuration File: ${xconf}"
+      echo "  X11 Auto-Configuration Driver: $(grep Driver ${xconf} | cut -d \" -f 2)"
+    fi
 else
-  xconf="/usr/local/etc/X11/xorg.conf"
-  echo "  X11 Auto-Configuration File: ${xconf}"
-  echo "  X11 Auto-Configuration Driver: $(grep Driver ${xconf} | cut -d \" -f 2)"
+    echo "Can't determine X Configuration, DISPLAY not set"
 fi
-
 echo "--------------------------------------"
 #Now get some GPU information
 echo "GPU Information:"

@beanpole135
Copy link
Member

@beanpole135 beanpole135 commented May 9, 2019

Confirmed this is working and committed.

In the future please open up a pull request instead of dumping the contents of a patch file into an issue. That makes it a ton easier to review/merge the changes without me having to manually copy text out of an issue, ensure the formatting did not get screwed up, and then do patch procedures by hand. GitHub handles all of that via the PR system.... ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment