GithubHelp home page GithubHelp logo

Streaming through stdout about xbar HOT 8 CLOSED

matryer avatar matryer commented on May 23, 2024 5
Streaming through stdout

from xbar.

Comments (8)

iosdeveloper avatar iosdeveloper commented on May 23, 2024 1

Implemented in #317. :)

from xbar.

shepazon avatar shepazon commented on May 23, 2024 1

I do like this idea. The ability for a script to just stay running and periodically send updated information to BitBar would really be a win, because it eliminates the overhead of spawning processes periodically, and it lets the plugin more easily maintain state across passes through its code (instead of having to stash its variables to a file every time it runs).

Also, I have noticed that even when I use "2> foo.txt" to redirect stderr, it instead changes the title of the plugin in the menu bar, rather than logging it to the file.

from xbar.

matryer avatar matryer commented on May 23, 2024

That's an interesting idea - so a single long running process. Hmmm.

from xbar.

matryer avatar matryer commented on May 23, 2024

... and thanks :)

from xbar.

Tarang avatar Tarang commented on May 23, 2024

It might sound bad in terms of a being a long running process, but it can make things quite efficient.

Sometimes there is an overheard with the first request, here websockets can be used to stream data down and update it as it arrives.

from xbar.

keithamus avatar keithamus commented on May 23, 2024

To spitball on a design for this: you could send a particular escape character to tell BitBar that this particular block of stdout has finished. Take for example the following script:

#!/usr/bin/env sh
COUNTER=0
count() {
  COUNTER=$((COUNTER+1));
  echo "$COUNTER"
  echo '---'
  echo "Some menu entry"
  echo "~~~"
}
while true; do
  count
  sleep 1
done

The output looks a little like this:

1
---
Some menu entry
~~~
2
---
Some menu entry
~~~
3
---
Some menu entry
~~~

The ~~~ tells BitBar to take everything above it, and since the last ~~~ and render that menu. In other words BitBar can keep the process alive, buffer up to the next ~~~ and subsequently render the menu.

from xbar.

exside avatar exside commented on May 23, 2024

please merge this, I'm using this and it works, the ONLY issue I have is that somewhere is a memory leak, at least the way I'm using it, basically JavaScript/Deno connecting to a websocket, streaming data and console.log() updates in the BitBar format...over time Bitbar consumes several 100MB of memory (starting at around 5.5MB in my case), so I have to kill it and restart it every few days (it actually depends on how much data comes in). I suspect is some kind of issue with all the console.logs() accumulating in the background, I tried to console.clear() etc. with no success so far...

from xbar.

shepazon avatar shepazon commented on May 23, 2024

FWIW, the BitBar-alike SwiftBar uses this approach to do streaming plugins. See swiftbar/SwiftBar#118.

from xbar.

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.