Need help with 'yad --html'

485 visningar
Hoppa till det första olästa meddelandet

Gavin Whitehead

oläst,
18 aug. 2021 12:30:412021-08-18
till yad-common

I am trying to write a simple application to run on Ubuntu (18.04) to display certain system information to the user.  The app would have two views, a table of simple information and an alternative table with more complex information.  The app would have four buttons; “Switch to simple view”, “Switch to complex view”, “Refresh data”, “Exit”.

I would like to do this with “yad --html” as I believe that this will give me better formatting options than plain yad (or yad with pango).

I’ve even got a wireframe up and working with hardcoded data and all the buttons (HTML not yad buttons) hooked up and working. But then the penny drops.  I am (effectively) running in a browser so I won’t have access to local resources!  Is there anyway I can get details such as MAC, hostname, uptime, volume settings, attached USB devices etc. via javascript in my yad app?  Can I even read local files or run local commands (‘lsusb’)? 

These things would be simple if I did it all in bash and used yad without --html but it just wouldn’t look as good.

 Any help would be greatly appreciated.

 Gavin

 

Милош Павловић

oläst,
22 aug. 2021 11:04:182021-08-22
till yad-common
You cannot get MAC, hostname, uptime, volume settings, attached USB devices etc. via javascript.
Javascript is very limited for security reasons, you wouldn't want your browser to access such info.
yad html dialog will be frontend while bash will be the backend fetching that data.
Javascript can be used in thge frontend and print out data to the command line which script can read.
If html dialog is empty that means it's not enabled at compile time by your distribution and you will have to install webkit development library and compile yad yourself.
I've installed package libwebkit2gtk-4.0-dev before compiling the latest yad 10.90 from source code in Debian 11 and this example still works.
alarm.gif
I forgot I have another more complex script: https://gist.github.com/Misko-2083/2b2fff6fbdadaf88319ff3f4196d02fa
That one works too. It's not even a decorated yad window, it uses xdotool and wmctrl to minimize, maximize, move and close window.
alarm.gif

Gavin Whitehead

oläst,
23 aug. 2021 13:01:022021-08-23
till yad-common
Thanks for the reply.  I think I'll look at some other technologies/frameworks/tools etc.  I just want to write a couple of quite simple GUI applications using technologies that I and my colleges understand.  Javascript, HTML, CSS seemed like an obvious place to start, but maybe it's not right for this.
Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden