-
Notifications
You must be signed in to change notification settings - Fork 21
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
How do I add simple script output to my bar? #172
Comments
First thing, if you manage to get sfwbar to segfault with a dodgy config, please let me know (and post the config that did it if possible)! It certainly shouldn't happen and I would like to get rid of any bugs that cause it. Hopefully the config parser update I'm working on should get rid of most of these segfaults. As for the question itself, there is the usual way of doing this (i.e. running the script over an over) and the better way (which is why scanner has been written to begin with). If all you want to do is to display an output of a script, it's easy:
This will update value of a label every second and since it references MyVar which is a scanner variable it will execute the script Now, the above is the UNIX way of doing these things and it's also a pretty horrible way of building a taskbar. You're running a script every second and the script is probably running cat, grep, cut etc every time. This takes up a lot of resources just spawning processes for all these commands, not to mention initializing them, parsing arguments etc. The scanner system of sfwbar can perform most of the tasks involved in displaying and updating this information internally. Let's say, you want to display CPU utilization, you can do something like this:
This config works similar to the first one, but instead of running a script every second, it opens /proc/stat and parses it's contents. While parsing, it will look for lines matching regular expressions (in the above case lines beginning with "cpu") and populate variables with the contents of the first capture buffer in each regular expression. So, CpuUser will be the first number after "cpu", CpuNice will be the second number etc. Each scan variable stores it's latest value, but also it's value from the previous update in If you want to look at the examples of setting up scanners for various things, you can look at |
I believe this is what the scanner option is for? However, the instructions on how to use the scanner option are unclear. I've attempted to include various things in my "taskbar" declaration but either nothing happens, or I've got incorrect options and sfwbar segfaults. I've checked all the example configs and none of those really provide a lot of hints either.
The docs show the following in the Scanner section:
but that has no relation to the bar itself? I don't understand what the docs are showing me. How would you indicate the position in the bar of that "getweather.sh" script as shown in the example?
I just want to show CPU load and RAM usage on the far right hand side of the taskbar. I have a simple bash script to spit this out as a simple string. How can I add this to sfwbar?
The text was updated successfully, but these errors were encountered: