Comments (21)
Good questions! To give you some answers:
- Yes only one screen for now. Check Issue #9 for more details
- indeed, widgets are serialized to plain objects right now, so there is no scope. However, using properties works (even though I am not a big fan of
this
myself). So you can change your example to
note: "bob"
command: "date"
refreshFrequency: 10000
render: (output) -> """
<h3>#{output} #{@note}</h3>
- It is not possible at the moment. You are correct that the backend is in nodejs but widgets are executed in the client (except for the
command
of course). So to make this work I'd have to use browserify or something, which might be an idea for the future. What you can do though is write a node app that spits out some output and then execute it usingcommand
- see above, but I agree that there might be some cases where you don't need to execute a command, so I might make it non mandatory in future versions
- see Issue #10 for some details on that
from uebersicht.
Ah, interesting. So everything actually runs on the browser side (except for the command evaluation I imagine) and all 'variables' are actually the (client-side) widget object properties.
So the widget developer has no access to anything that's happening in node.js. Is node.js just used to exec the command, compile the coffeescript to JS, listen to modified files in the widget directory and pass that code to the browser side?
from uebersicht.
yes that is indeed pretty much how it works :)
from uebersicht.
Would there be a way for the node.js side to communicate with the client side of the widget (maybe through socket.io) so a widget would have client side & server side components.
from uebersicht.
that is in away how it is at the moment, albeit the communication only happens using polling (refreshFrequency
) and with simple http requests. It would be cool to at some point use web sockets to allow for streaming and pushing of info from the backend, I agree!
from uebersicht.
But there is no way for the developer to create code that runs on the server side (node.js).
from uebersicht.
There is! You can just ship any execetuable (so this can be a node app) with your widget, by adding it to the widget folder.
from uebersicht.
When you say I can ship any executable, does that include shipping a bash script with my widget that I can call from command
?
from uebersicht.
Exactly, at the moment widget commands are exectuted relative to the widgets directory, so if you put your shell script inside your widget folder you can call it from command
like so:
command: "./my-widget.widget/the-script.sh some args"
from uebersicht.
Another way to use uebersicht is simply as a mechanism to display output - and define location on desktop.
command: "source $HOME/.bash_profile &> /dev/null && $HOME/projects/ubersicht/uberTest.coffee"
That gets me my normal shell environment (all libs available - nvm, etc) and then runs a script that does everything - including create all HTML, etc - just returns a string.
style: """
top: 300px
left: 40px
"""
all this does is set positioning...
render: (data) -> "#{data}"
data
is just a string with all HTML/Data/CSS already included. So all the magic happens in uberTest.coffee. Also easy to debug since you can just run your script from shell or in a browser - once you have it working, the last step is to create the "display script" in the ubersicht directory (as shown above).
from uebersicht.
good one!
from uebersicht.
It would, however, make sharing them more difficult since you are relying on tools and npm modules being installed on your system. Great for your personal widgets and for developing though!
from uebersicht.
@felixhageloh , that's true. Ultimately though I think widget really should have a server side & client side components, including a package.json describing required node.js package which could be auto installed via the npm API by uerbersicht.
from uebersicht.
could be an option, indeed. I guess a prerequisite would be to have a 'proper' way to install widgets
from uebersicht.
I feel the current system works really well. Just a folder for active widgets. If they're not in that folder, they're not installed. If they're in that folder and haven't been installed yet (or the package.json or other files are new) run the npm install (or use npm programmatically in node).
from uebersicht.
Thanks for the hint @JaredVogt, it helped me get Ruby working with Übersicht . I still have to put the full path to my preferred Ruby executable as rbenv selection isn't respected. Not sure why, but no problem for now.
from uebersicht.
So how many things were implemented from this discussion, and what still needs to be done?
from uebersicht.
@jhvanophem sorry for the late response. From the top of my head:
- multiple screens are supported now
- you can require npm modules
command
is not mandatory anymore (ifrefreshFrequency
is set to false)- I would need to double check but I think global vars also work now
from uebersicht.
Is there an example of how to to "require" a node module in the script? Just like normal with a var x = require(...) ? Do I understand the docs correct that this is only available if using coffeescript? Thanks!
from uebersicht.
Also, if this is running with node in the background, does it mean that it uses the default version of node? IE if I set a default with NVM it will use that and if so does it mean that I can use es6 syntax as long as my node version supports it?
from uebersicht.
Did you figure out how to use require
- I think there were some answers in another thread?
Regarding node, there are a few things to keep in mind:
- all js code in widgets runs in a 'browser' so the node version doesn't really matter. The browser is a WebView which is in sync with the current version of Safari you have on your system, so it supports anything that your version of Safari does. Regardless of that, all widgets, except plain JS ones are compiled using babel, so you can use ES6 in JSX widgets.
- You can make a node script which you can call as your command, in which case you can use whatever version of node you have installed on your system. Keep in mind that by default Übersicht doesn't load your .bash_profile so you might have to do that manually in your command (or use full paths to your node binary)
- Übersicht does come with its own version of node but it is not easily possible to access it (it is called
localnode
and is inside the Übersicht app bundle)
Hop this helps!
from uebersicht.
Related Issues (20)
- Cannot click items when on background layer HOT 1
- init Called Multiple Times?
- Übersicht seems to hang / stop responding to `osascript` commands after waking from sleep
- icall-buddy not working because Übersicht uses bash instead of zsh
- How can I use shell commands and external api request in one widget? HOT 1
- I want to control option "Interaction" with Applescript...
- Übersicht security risks when running arbitrary shell commands over HTTP HOT 1
- [VENTURA] Widget Update
- `backdrop-filter` gets removed almost immediately, then flickers on/off HOT 2
- Allow targetting widgets to screens using AppleScript HOT 1
- Render Continuous Output in Background?
- Is it possible to send notifications from a widget? HOT 2
- <iframe> interactions are extremely unreliable. HOT 2
- Homebrew version error
- Any way to detect when a widget goes from visible to hidden?
- MS Edge losing focus on toolbar menus when Ubersicht is running
- How to find the widget id for specific widget? HOT 2
- Add `eventListener` after render in JSX? HOT 1
- Your GetWidgets page need to be organized by Arch Type
- HELP shell script formatting ignored? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uebersicht.