ENIGMA Forums

General fluff => Off-Topic => Topic started by: edsquare on August 04, 2014, 10:58:27 AM

Title: Can enigma be a widget engine?
Post by: edsquare on August 04, 2014, 10:58:27 AM
Acces the OS info? You know cpu temperature, ram usage, etc.

You know acces the web? like getting the weather from a site, or music, or stuff like that, not in a graphical way like a browser would but more like getting the info data and then displaying it in some way choosen by the programer.

And make calls to JS code?

I have a friend on deviantArt who makes desktop widgets for the now defunct Yahoo engine and one or two other widget engines, and talking about it we came up with the crazy idea of a universal widget engine. He knows VB and JS, I could do some stuff on Python.

Thinking about it I thought about ENIGMA as a possible solution to this, if the engine can get acces to that kind of stuff. And maybe even launch other installed applications, like a multimedia player, or a file manager.

It would also be a great way for enigma to get more exposure.
Title: Re: Can enigma be a widget engine?
Post by: fervi on August 04, 2014, 11:36:37 AM
On Linux it can be easy, if "INI" and "execute_shell" options will be implemented

In Windows probably external software or DLL

Fervi
Title: Re: Can enigma be a widget engine?
Post by: edsquare on August 04, 2014, 12:34:39 PM
On Linux it can be easy, if "INI" and "execute_shell" options will be implemented

In Windows probably external software or DLL

Fervi

INI so it would launch at boot time right? and

Execute_Shell to launch other programms?

Will be implemented? you mean in enigma?

The windows comment I didn't understand.
Title: Re: Can enigma be a widget engine?
Post by: TheExDeus on August 04, 2014, 12:39:27 PM
Everything is possible with ENIGMA. It's open source. You could use it to control mars rovers if you wanted to (I actually use ENIGMA for robot planning and control). Current net_ functions should have the possibility to load html pages (though someone tried it some while back and had some problems with it), and then you could parse the html to get information. You can launch applications with execute_shell - I have used it to launch security camera feeds. It should also be quite easy to access PC information, like CPU temp. and RAM usage. We should actually make an extension like that.

Linux has ini (trough extension) and execute_shell functions as well.

edit: I think he meant something else. I don't understand why he actually mentioned INI's, as they are config files and are not that useful for information acquiring. To make it launch in boot time you would have to add it to Startup (on windows) and something equivalent on linux. It's not really that connected to the app itself, although ENIGMA has registry functions which should allow you to set this behavior inside the program.
Title: Re: Can enigma be a widget engine?
Post by: edsquare on August 04, 2014, 12:58:32 PM
Everything is possible with ENIGMA. It's open source. You could use it to control mars rovers if you wanted to (I actually use ENIGMA for robot planning and control). Current net_ functions should have the possibility to load html pages (though someone tried it some while back and had some problems with it), and then you could parse the html to get information. You can launch applications with execute_shell - I have used it to launch security camera feeds. It should also be quite easy to access PC information, like CPU temp. and RAM usage. We should actually make an extension like that.

Linux has ini (trough extension) and execute_shell functions as well.

edit: I think he meant something else. I don't understand why he actually mentioned INI's, as they are config files and are not that useful for information acquiring. To make it launch in boot time you would have to add it to Startup (on windows) and something equivalent on linux. It's not really that connected to the app itself, although ENIGMA has registry functions which should allow you to set this behavior inside the program.


So if we had the code in c++ adding the extension to read the hardware data would be easy?

The INI's may be for saving the state of the active widgets, size, location, theme, etc.
Title: Re: Can enigma be a widget engine?
Post by: TheExDeus on August 04, 2014, 01:14:36 PM
Quote
So if we had the code in c++ adding the extension to read the hardware data would be easy?
Most of the stuff in C++ is easy, as it has great libraries and tons of API's. I just googled "get cpu temperature C++" and got some pretty good results for both Windows and Linux (ubuntu). But I did notice that there is a lot of incompatibility between versions of linux and variations of hardware. So it could end up not be so easy if we want to support all of that.
Title: Re: Can enigma be a widget engine?
Post by: edsquare on August 04, 2014, 01:51:56 PM
Quote
So if we had the code in c++ adding the extension to read the hardware data would be easy?
Most of the stuff in C++ is easy, as it has great libraries and tons of API's. I just googled "get cpu temperature C++" and got some pretty good results for both Windows and Linux (ubuntu). But I did notice that there is a lot of incompatibility between versions of linux and variations of hardware. So it could end up not be so easy if we want to support all of that.

On linux no matter what distro (I think) you can read this information from /proc/pid/stat, where pid is the process ID that you're interested in.

See the proc man pages for details.
Code: [Select]
http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html
Look also at ps -o format, which allows you to select the fields that ps should display. Again, see the man pages for details.
Code: [Select]
http://linux.die.net/man/1/ps

Title: Re: Can enigma be a widget engine?
Post by: Josh @ Dreamland on August 04, 2014, 09:38:30 PM
You are able to include arbitrary C++ code in ENIGMA games. You can do any of that stuff. The issue is that you probably don't want the weight of an entire game engine powering your little desklet. I'd recommend writing a minimalistic system under Platforms/ and implementing a full None graphics system, if you wanted to pursue that.
Title: Re: Can enigma be a widget engine?
Post by: edsquare on August 04, 2014, 10:42:21 PM
You are able to include arbitrary C++ code in ENIGMA games. You can do any of that stuff. The issue is that you probably don't want the weight of an entire game engine powering your little desklet. I'd recommend writing a minimalistic system under Platforms/ and implementing a full None graphics system, if you wanted to pursue that.

Not sure if I understood you, the weight of the game would be on the engine not on the desklets, the desklets would comunicate with the engine and extract the info from it, it would also provide the graphics capability to the desklets to draw clocks, calendars and what not. The desklet itself could be nothing more than the graphics and some JS, Lua or python to communicate with the engine.

The real problem would be to make it launch itself at boot time, to prevent it from launching more than one instance of itself and/or the desklets, and to allow it to communicate with the web and to extract the weather, and other stuff from it.

Also it would need to be able to use full trasnparency no matter where it's installed, and to scale the desklet up and/or down accordingly to the desktop real state available.
Title: Re: Can enigma be a widget engine?
Post by: Josh @ Dreamland on August 05, 2014, 07:06:00 AM
The problem is that ENIGMA's events are synchronous. A normal clock applet does a repaint once a second or once a minute, and only ever gains CPU time otherwise when the user interacts with it. The panel tells the applet that the user has done something, and the applet responds. Using ENIGMA to code this, you'll instead be responding every thirtieth of a second, wasting CPU in the meantime. ENIGMA's default event loop is designed for games, which always have logic that needs performed 30 or more times per second. Your typical applet draws once, then sleeps for hours.
Title: Re: Can enigma be a widget engine?
Post by: TheExDeus on August 05, 2014, 10:19:50 AM
There is no problem sleeping in ENIGMA as well. You could set automatic redraw to false, then pause the whole game for as long as possible, while creating a threaded script which checks for click in the window about five times a frame. Then CPU cost should be 0%. So I personally don't see a reason why it wouldn't be possible.

But Ed seems to care only about the "engine", or the one sending information to the widgets. Finding an effective way for that is more problematic, as sending data to a JS widget (which is rendered where exactly?) might be more involved.
Title: Re: Can enigma be a widget engine?
Post by: edsquare on August 05, 2014, 10:41:18 AM
There is no problem sleeping in ENIGMA as well. You could set automatic redraw to false, then pause the whole game for as long as possible, while creating a threaded script which checks for click in the window about five times a frame. Then CPU cost should be 0%. So I personally don't see a reason why it wouldn't be possible.

But Ed seems to care only about the "engine", or the one sending information to the widgets. Finding an effective way for that is more problematic, as sending data to a JS widget (which is rendered where exactly?) might be more involved.

So building it as a "game" which displays all of this "minigames" would be easier?
Title: Re: Can enigma be a widget engine?
Post by: TheExDeus on August 05, 2014, 11:39:49 AM
It doesn't need to be a "game" with "minigames". I would just make everything in ENIGMA, that's all. Probably one project per widget. I have done many things in GM and ENIGMA, and making a complete game is not one of them. I use them for many totally different things. Like making a file browser that is actually faster than Windows one. I remember the "SubOS" (more precisely a "shell") craze in GMC many years back (it's basically making the graphical part of an OS inside GM and then running over your original OS), which really pushed the limits on what people though GM can do in terms of windows, widgets, file manipulation and so on. Many of those "SubOS's" really had widgets and things.
Title: Re: Can enigma be a widget engine?
Post by: edsquare on August 05, 2014, 12:18:55 PM
It doesn't need to be a "game" with "minigames". I would just make everything in ENIGMA, that's all. Probably one project per widget. I have done many things in GM and ENIGMA, and making a complete game is not one of them. I use them for many totally different things. Like making a file browser that is actually faster than Windows one. I remember the "SubOS" (more precisely a "shell") craze in GMC many years back (it's basically making the graphical part of an OS inside GM and then running over your original OS), which really pushed the limits on what people though GM can do in terms of windows, widgets, file manipulation and so on. Many of those "SubOS's" really had widgets and things.

But one project per widget means one engine per widget, which means heigher ram use if you open more than ona widget.  :-\
Title: Re: Can enigma be a widget engine?
Post by: TheExDeus on August 05, 2014, 12:48:14 PM
An empty GM project is 15mb of ram right now. With all the bells and whistles of a widget, it probably be around 30mb. Taking into account I have seen rarely more than 3 widgets at the same time, then that is 90mb. Which is not that bad. The "engine" what you call shouldn't be more than a few megs in program anyway. Gathering data isn't that ram consuming. On the other hand the rendering and all that can be. From what I found widgets do use about that much ram or even more. They usually also use more CPU (like 2% to 9%) - this is from a topic I just read about Win7 gadgets.
And you said you would want to use JS and python to render them. I don't know what you can use to render JS as a widget though, I'd say Adobe AIR, which uses about 200mb of ram when launched. So I doubt you would get much less ram usage, than regular ENIGMA.
Title: Re: Can enigma be a widget engine?
Post by: edsquare on August 05, 2014, 01:48:55 PM
An empty GM project is 15mb of ram right now. With all the bells and whistles of a widget, it probably be around 30mb. Taking into account I have seen rarely more than 3 widgets at the same time, then that is 90mb. Which is not that bad. The "engine" what you call shouldn't be more than a few megs in program anyway. Gathering data isn't that ram consuming. On the other hand the rendering and all that can be. From what I found widgets do use about that much ram or even more. They usually also use more CPU (like 2% to 9%) - this is from a topic I just read about Win7 gadgets.
And you said you would want to use JS and python to render them. I don't know what you can use to render JS as a widget though, I'd say Adobe AIR, which uses about 200mb of ram when launched. So I doubt you would get much less ram usage, than regular ENIGMA.

Okey gotcha, so it would be better and faster if done individually and operate individually, great! that means same stuff on windows and on linux, mac can go fuck itself, as for android... well when we can export to it I'll be more than happy to.
Title: Re: Can enigma be a widget engine?
Post by: TheExDeus on August 05, 2014, 02:10:17 PM
I cannot guarantee it will be better or faster, but I think it would be. Depends on what is the alternative, which you haven't really mentioned. Or even the resource consumption of current widget engines.
Title: Re: Can enigma be a widget engine?
Post by: edsquare on August 05, 2014, 02:18:57 PM
I cannot guarantee it will be better or faster, but I think it would be. Depends on what is the alternative, which you haven't really mentioned. Or even the resource consumption of current widget engines.

The only one I've used is the desklets engine for gnome (Python) and I don't remember it's usage of cpu and ram  :( I would need to investigate to see if it's really interesting to do it anyway, but being interpreted JS, and python, and using qt in the case of some I would imagine its not little.
Title: Re: Can enigma be a widget engine?
Post by: TheExDeus on August 05, 2014, 03:21:11 PM
That is my reasoning as well. If a widget can be programmed in JS, then it's very unlikely to eat small amount of resources. Unless you somehow don't compile that JS into a native binary. That is why ENIGMA is actually not a bad platform for widgets, as it is compiled, extensible and modular (so you can remove whatever you don't need and leave only what you do need). This ends up as low ram and cpu usage by default.