andresgongora / synth-shell

Boost your terminal, script by script
GNU General Public License v3.0
992 stars 241 forks source link

Problem with pop_os 20.04 update #169

Closed zedidous closed 3 years ago

zedidous commented 4 years ago

Hello here I've been using synth-shell for couple of months without any problem, but since the Pop_OS 20.04 update from yesterday I have a problem in the script as you can see on the screen capture. On the right side you have the ~/.bashrc file. When I # comment the status line, I don't have this warning anymore (but obviously I lose all the cool stuff). I've tried to install synth-shell-greeter but it went exactly with the same problem but in addition, when I edit the synth-shell-greeter.conf file, no change appears whatsoever (and I've tried as well to change the synth-shell-greeter.conf.default file... So I reverted to the old status.sh (but i kept the greeter logo as it looks cool!) Screenshot_20200502_150228

andresgongora commented 4 years ago

The problem with bash is that its quite difficult to debug. Let's try the following: go to your synth-shell-greeter.config file, and under print_info=" ... " disable everything. If the error persists, report back, if the error goes away, slowly re-enable your elements until the error happens. That we I might be able to pint point the function that is causing the trouble.

It might also be possible that I've mixed up shell and bash code. The weird thing, however, is that it seemed to work for you in the past.

zedidous commented 4 years ago

Sorry for the delay, I was busy working. Now I have more time to spend with you! ;-) So I've found which item was causing this issue: SYSLOAD_MON% (I've tried with and without the % with the same result) When i remove this item it's all fine. Oh and again, i can't use the synth-shell-greeter.config file because whatever i change, it's not taken into account in the bash (it is always the default i see on my screen). So i'm using the status.config instead. So the problem comes from the SYSLOAD_MON after the last Pop_OS 20.04 update...

andresgongora commented 4 years ago

Hi Zed, Please confirm:

  1. Did you install synth-shell or synth-shell greeter? The status.sh in synth-shell is outdated. All the new features are in synth-shell greeter. I will merge them soon(ish) as per #161 .

  2. If you installed synth-shell-greeter, did you use the setup script or the AUR package? And did you set it up for your user only for system wide? I will assume that you have installed it for your user only. synth-shell -greeter uses a NEW configuration file. That means that ~/.config/status.config is deprecated. You have to use ~/.config/synth-shell-greeter.config.

  3. Can you please give me your output for awk '{avg_1m=($1)} END {printf "%3.2f", avg_1m}' /proc/loadavg. This is the bit of code that computes the current CPU usage in SYSLOAD_MON. Maybe the bug is there.

zedidous commented 4 years ago

Hello Andres So here are my answers:

  1. Initially i've had synth-shell installed but when the bug appeared i've installed synth-shell greeter .
  2. I'm fully aware that in synth-shell greeter i have to modify the synth-shell greeter.conf file but as I said, whatever i changed on it nothing happened. It was always the default page on my screen even after rebooting. So i came back on synth-shell where i could modify the status.conf page without a problem this time. (i've installed both as user only)
  3. when i run this code i have in return 0,00 I hope it helps... Cheers
andresgongora commented 4 years ago
  1. Perfect
  2. Hmm I think there was a bug a while bag. Maybe I've fixed it in develop but not in master. You probably can use the correct config file if you clone the develop branch instead of master.
  3. Ok... I'm not 100% sure, but maybe its because it reads 0,00 instead of 0.00. But then you say that its the only monitor that fails, right?

Could you please install the develop version of synth-shell-greeter? That way I can push changes for you to test much faster.

zedidous commented 4 years ago

is it possible to use git clone to have the develop branch? For me it shows the same adress as the master one (sorry I'm noob with github... )

zedidous commented 4 years ago

so when i try to install the develop branch i have this : zed-system  pop-os  ~  synth-shell-greeter-develop/setup.sh synth-shell-greeter-develop/setup.sh: line 31: cd: /home/zed-system/synth-shell-greeter-develop/bash-tools/bash-tools: No such file or directory Include failed /home/zed-system/synth-shell-greeter-develop->bash-tools/bash-tools/user_io.sh

andresgongora commented 4 years ago
git clone --recursive https://github.com/andresgongora/synth-shell-greeter.git
checkout -b develop
git pull
synth-shell-greeter/setup.sh

Don't forget the --recursive This should work. I've written this without checking it.

zedidous commented 4 years ago

Si i confirm, there is in home/synth-shell-greeter/config/synth-shell-greeter.config.default file, when i change stuff in it nothing happen (I've removed the .default at the end to see if the problem is not from that, but no)

andresgongora commented 4 years ago

I think you got it mixed up.

I hope this helps :)

zedidous commented 4 years ago

Hello Andres. I've searching a lot why after installing synth-shell-greeter i couldn't modify the config file like i could do with previous synth-shell. And i found out why: when I install synth-shell-greeter as it's mentionned on the github page, it installs the config parameters IN the synth-shell-geeter.sh as you can see on my screen capture. So if i modify the .sh file now i can see the changes... There is a bug I guess in the installation process... Screenshot_20200506_160229

zedidous commented 4 years ago

And also by installing synth-shell-greeter i lose the fancy-bash-prompt and better-ls (i loved those tools...)

zedidous commented 4 years ago

and for the sys_mon item i've found this piece of code to change , to .

$ cat foo.sh
#!/bin/bash        # added shebang, bash since you have [[
code() {
  if [[ $1 == , ]] # removed the ; and added a space after ,
  then
    echo then      # added this
    code .
  else
    echo else      # and this
    code $1
  fi
  return 1
}

code $1

I don't know it his helps...

andresgongora commented 4 years ago

Hi Zed.

The config file "inside" the script is not a config file. Those are the default parameters ant they are meant as a fall back in case the script can't find any configuration under ~/.config/synth-shell/synth-shell-greeter.sh.

You can install synth-shell and greeter at the same time. When installing the base synth-shell, simply say no when asked about status.

Thanks por the code snippet. My code is very messy right now and so it's no wonder that there are bugs. However, the piece of code you have sent me, where should it go? Please specify file and line. All add the fixes and push them to github ;)

zedidous commented 4 years ago

Hi Andres So for the config file i've found the problem. On the line 65 of the synth-shell-greeter.sh : local user_config_file="~/.config/synth-shell/synth-shell-greeter.config" you should write instead local user_config_file="$HOME/.config/synth-shell/synth-shell-greeter.config" When i change this it works fine and now i can modify my synth-shell-greeter.config as intended, For the , instead of the . that cause the problem, I'm no programmer at all, so I'll try to help you the best I can but I can't promise anything ... But I'll try my best ! cheers

andresgongora commented 4 years ago
Sorry for the late reply. I have several major projects going on and so I was unable to address all issues of this repo. I'm a bit more free now and so we should be able to fix all issues in a short time.

Please let me remind you that synth-shell is going through a big change. I'm moving all script inside synth-shell to external repos, so that they now becomes submodules that can, if the user wishes so, be installed completely independently. This is a big improvement, but requires a lot of work. Just as a brief overview:

- synth-shell https://github.com/andresgongora/synth-shell: this will be the parent repo. Eventually it will contain little code on its own and will become a bundle of submodules.

- bash-tools https://github.com/andresgongora/bash-tools: all auxiliar functions that have "generic" use will be store here. Like printer helpers and such.

- synth-shell-greeter https://github.com/andresgongora/synth-shell-greeter, formerly known as status.sh, is the script that prints the logo and system status info.

- synth-shell-prompt https://github.com/andresgongora/synth-shell-prompt: prints a nice colored prompt with triangles.

Hi @zedidous , thanks for your patience. I think this issue is tightly tied to the other bugs the script has. Please consider reinstalling synth-shell, I have updated the master branch heavily. Please let me know if doing so fixes the bug or other new ones appear.

Ok. Please follow these steps to see if we can pinpoint the issue:

  1. Go to your bashrc file and remove EVERYTHING related to synth-shell. Simply use your favorite text editor, such as nano ~/.bashrc or gedit ~/.bashrc and scroll to (propably) the bottom of the file, locate all lines by synth-shell, delete them, and save.
  2. Update synth-shell from the master branch. That is, simply reinstall synth-shell from scratch. Do so for your user only and use all the default options (aka smash that ENTER key repeatedly).
  3. Confirm if you still get the bug, or new ones.
  4. Let's try to determine if the problem is caused by synth-shell-greeter. This is VERY LIKELY the case. To confirm if it is, run in your terminal source $HOME/.config/synth-shell/synth-shell-prompt.sh. Does the errors appear again?
war-and-peace commented 4 years ago

Hello, I had the same problem with Ubuntu 20.04.1 LTS using the latest version of synth-shell. After some investigations, I found out that after commenting out the line 2609 in synth-shell-greeter.sh the errors disappeared. I couldn't further investigate to find the actual problem though.

transmissionator commented 4 years ago

Similar issue here in Arch Linux. Screenshot 2020-08-03 at 11 25 41 The issue seems to be somewhere in printStatusInfo. However, I was unable to work out exactly what the issue was.

andresgongora commented 4 years ago

Hi @war-and-peace and @transmissionator . That annoying syntax error... Let's pin in down once and for all :D

If you don't mind, edit your synth-shell-greeter.config (usually under ~/.config/synth-shell/) and remove the elements in print_info one by one until it goes away. Under the hood, the script calls all these subscripts to generate the final output. One of them has an error that appears only on some system configurations (none of my machines have that problem, but then again, I have almost the same software installed in all of them). I'm almost positive it must be related to LOCALIPV4 or EXTERNALIPV4.

Let me know which one of those, when deleted, got rid of the error in your system.

Also, I'm seeing that have no CPU temp readout. So also try to delete CPUTEMP. Maybe that's the problematic one. Going to the config is much safer that going through the code ;)

andresgongora commented 4 years ago

Also, @transmissionator , if the LocalIPv4 output is too long and ugly, even if not the source of the problem, you might want to remove it anyway in your system. You have like 4 different IPs probably and it's getting very messy

war-and-peace commented 4 years ago

For me deleting SYSLOAD_MON% in synth-shell-greeter.config solved the problem.

andresgongora commented 4 years ago

@war-and-peace To confirm: that got rid of the 1: syntax error, right? Ok, I'll have a look at the code as soon as I have some free time. I guess it should be easy to fix

war-and-peace commented 4 years ago

It got rid of these errors (all of them): image

andresgongora commented 4 years ago

Ah ok, then those are a bit different than @transmissionator . So we might be facing two separate problems at the same time. Thanks for the screenshot, that very useful

transmissionator commented 4 years ago

Yeah I think it is two seperate issues, for me removing CPUTEMP removes the errors. I'm going to look at this now too and see if I can help.

transmissionator commented 4 years ago

OK I have a fix for this now. The issue is when you are running Synth Shell in a vm, there isn't going to be any CPU temp readings. If it's ok with you i'll submit a PR shortly with a patch?

andresgongora commented 4 years ago

@transmissionator Yeah, that would certainly help! Thanks!

@war-and-peace Let's try something crazy. Can you go to ~/.config/synth-shell/synth-shell-greeter.sh and search for the line:

    local percent=$('bc' <<< "$value*100/$max")

And replace it with:

    local percent=$('bc' <<< "$value*100/$max")
    local percent=${percent/.*}

The variable percent should be an int, but maybe its staying as a float and causing the problem. If that does not work, also try with:

    local percent=$('bc' <<< "$value*100/$max")
    local percent=${percent/\.*}
war-and-peace commented 4 years ago

I have checked both of them but they did not change anything.

war-and-peace commented 4 years ago

I found the actual cause of the problem. It is because I have a Russian local. When I changed the local to the USA the problems disappeared. In Russian local as far as I understood, the fractions are denoted by ',' (comma) rather than '.' (dot). E.g: instead of 2.3 it is 2,3. So, above you were trying to convert percent from float to int, but instead of '.' there should be ',' for me. Also, the problem turns out to be with value rather than percent. I have added the following lines in order to solve these problems I have added local value=${value/\,*} to printResourceMonitor and printInfoMonitor before calculating the percent.

war-and-peace commented 4 years ago

Also, I noticed that even though adding those two lines eliminates the above error messages, the system load is always 0% when I am in Russian local. When I changed it to the USA, it started showing the actual percentage (not 0).

transmissionator commented 4 years ago

@andresgongora I added my fix for my issue here --> https://github.com/andresgongora/synth-shell-greeter/pull/27. Please let me know if I added it wrong, I haven't worked with git submodules before.

andresgongora commented 4 years ago

@transmissionator Awesome! Pull request accepted. Once we fix everything, I'll move all changes over to synth-shell:master!

@war-and-peace Ok, then the problem is that we have to convert floats into integers, regardless of whether they use , or .. Now that we know the problem it should't be difficult. I'll try to do it this evening :)

andresgongora commented 3 years ago

185 should fix it