Giter Site home page Giter Site logo

Comments (19)

nathhad avatar nathhad commented on June 6, 2024 1

I'm stuck away from the test setup tonight - but should be able to pull to test first thing in the morning (about 12h). I'll plan to pull latest at that time and test against all current open issues to get caught back up to state of the code. Thanks!

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

Follow up - took a look at the code, this is failing because there is no swap configured on the system in question. Easy fix for that is to filter with an if statement for a one-line /proc/swaps.

That does mean there will also be a bug on any system with more than one swap space configured, as well.

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

Can you verify if /proc/swaps exist on your system without a swapfile or partition?

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

Confirmed, the file /proc/swaps still exists - it's one line only, just the headers. A system with multiple swap spaces will have numswaps+1 for file length. You can filter based on $(cat /proc/swaps | wc -l) to get line count. Have just started that on a branch, will test and send you a pull to look at shortly.

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

Great idea thank you!

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

Also - as I was working swap, discovered this issue is actually two issues. The pstree output above is part of determining the terminal, but was showing up on the swap line. Realized this while cleaning up swap. Hence, PR #24 will resolve the swap portion, but not the extraneous output quoted above.

OpenWRT and a lot of slim systems don't have pstree - I'm looking to see if there's an alternate clean method.

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

Further addendum on terminal determination, ps -p "$PPID" -o comm= is a nice alternative without pstree, but the trimmed down version of ps in busybox doesn't support any flags to ps.

I'd complain, but you can fit the entire OS into 8MB, trimming the fat has to happen somewhere!

Will continue looking to see if any of the simplified methods will work under busybox. If not, we might just have to filter it out like we did elsewhere for uptime --pretty. (This is easy to do for busybox versions of commands, because all of the normal command locations like /bin/ps are always symlinks to /bin/busybox instead of standalone programs. Busybox gets so skinny by compiling in all the commands so it can share libraries and resources really efficiently.)

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

I avoided the PR to keep code clean, I made a commit with what I believe should fix the issue for you. The fix is based on your idea to use line count and should print all swap partitions as well. Further testing with multiple swaps will have to be done

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

Thanks! I should be able to test in a moment, sending a quick band-aid suggestion to cover systems without pstree (I'm not finding an alternative supported by busybox, so maybe better to return an unknown instead of a jumble of error output)

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

The terminal deal wasn't easy to drop $TERM shell variable for Linux in general so I can imagine it'll be difficult for busybox. Thanks for the PR

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

Okay, tested commit df4d0c2 on the swap read - still gives an issue on swap read. However, now it's just an extraneous newline that's not getting parsed right. Just leaving out the entire swap ~ chunk if we can get rid of that \n would work just fine.

Current snippet of output on OpenWRT/busybox:

ram ~ 919 MiB\n
-ash: ./fetch.sh: pstree: not found
term ~  shell ~ ash

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

I'm not sure what is causing the swap line to get bad pstree output on BusyBox, which could only be from the term variable found below.. Hopefully last commit fixed spacing

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

Currently erroring out on the load averages addition before output gets to swap/term - will switch over to see what's going on there, then switch back to checking this once I can verify.

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

I commented it out for now. May be best to create a new branch for load avs or just make a script for load avgs then once the script functions make PR. I can make a new branch for you to push like test_load

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

That makes sense! It was working well on my x86 system, but I suspect ash shell was having a problem somewhere in there. I'll work with the commented version of saintphaenixos original code and see which part was giving it trouble. Thanks!

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

Can you pull latest commit and check output now?

from sysfetch.

nathhad avatar nathhad commented on June 6, 2024

Okay, have had a chance to pull and update tests based on commit c3092ba with following results:

Ram portion skips cleanly across the swap section, since there is no swap on this box. No newline at the end. Still get a shell complaint that pstree isn't there. I like the direction your solution is going, I think it's just out of order in the code. Output:

ram ~ 919 MiB-ash: ./components/term_shell.sh: pstree: not found
screen
 shell ~ ash

Code as it is right now:

# // TERM // get terminal name w/ pstree
shell="$(echo $SHELL | sed 's%.*/%%')"
term="$(pstree -sA $$)"; term="$(echo ${term%%---${shell}*})"; term="$(echo ${term##*---})"
if [[ $(command -v pstree) ]] ; then
  echo -ne "${GREEN}term${NC} ~ "
  echo $term | tr -d '\n'
else
  echo $TERM
fi

Code as needed to fix the issue, you should just need to move the pstree line inside the if (which I think is what you meant to do originally) and the header line back out:

# // TERM // get terminal name w/ pstree
shell="$(echo $SHELL | sed 's%.*/%%')"
echo -ne "${GREEN}term${NC} ~ "
if [[ $(command -v pstree) ]] ; then
   term="$(pstree -sA $$)"; term="$(echo ${term%%---${shell}*})"; term="$(echo ${term##*---})"
  echo $term | tr -d '\n'
else
  echo $TERM
fi

As you can see from my output, it's still getting "screen" okay on my simplified system (that's what tmux should report there), so it's just switching the position of those two lines, and I believe output will be fixed.

As a test, I just did that quickly on my local copy, and it solved everything except missing newline on the ram/swap line, this is the output with those two lines switched around:

ram ~ 919 MiBterm ~ screen
 shell ~ ash

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

I will try that! Idk much about the string of code used currently it was made by @SimoneSalzano
#15 duplicate error

from sysfetch.

wick3dr0se avatar wick3dr0se commented on June 6, 2024

The terminal is found in a completely different way now and should work as intended! I'm keeping #15 open and closing this

from sysfetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.