Update one Statusbar in realtime from bash? - _-Caleb-_ - 11-25-2023
Hi,
I'm trying to recreate an old utility called status in yab, this shown a statusbar and it's updated from bash...
Before start i'm asking if it's possible with yab, and if it, how is the better way? Im thinking in a program reading a file every x seconds and change this file with the % in every pass...
But sure exists a better solution.
Thanks in advanced!
RE: Update one Statusbar in realtime from bash? - bbjimmy - 11-26-2023
This looks like the way to go, but using /boot/system/var/shared_memory for weiting the info saves time and disk usage. This folder is a ramdisk supplied for just this sort of thing.
RE: Update one Statusbar in realtime from bash? - _-Caleb-_ - 11-27-2023
(11-26-2023, 11:44 AM)bbjimmy Wrote: This looks like the way to go, but using /boot/system/var/shared_memory for weiting the info saves time and disk usage. This folder is a ramdisk supplied for just this sort of thing. Hi.
Thank you very much, I didn't know that directory or its usefulness! :-)
Hopefully I'll have time this week to get into it.
Greetings!
RE: Update one Statusbar in realtime from bash? - _-Caleb-_ - 01-02-2024
Hi,
Starting with this program i've the next error:
The button isnt clickable.... just pressing alt+space but it doesn't work with the mouse click.
Any idea?
Code: #!yab
# Status
# Muestra una barra de progreso lanzable y actualizable desde un
# script o desde la Terminal.
# Licencia: Artistic 2.0 (https://opensource.org/license/artistic-2-0/)
# Versión de la aplicación:
appver$="0.0"
# Tanausú Gómez (_-Caleb-_)
# Contacto:
# Web: tanausugg.blogspot.com
# Correo: tgomez@duck.com
# Telegram: @calebin
# Otra información de interés.
# Basado en Status de Óliver Ruiz Dorantes:
# (https://urnenfeld.blogspot.com/2009/04/status-something-sleeping-in-hd.html)
# 1. Crea un archivo en el directorio /boot/system/var/shared_memory
# 2. Abre el archivo y lo lee
# 3. Cada medio segundo (A falta de prueba de reindimiento) lee el archivo. y actualiza la barra y la etiqueta.
# 4. Al llegar al 100% espera 1 segundo y lanza un Notify informando de que se ha finalizado el proceso.
# -----------------------------------------------------------------------------#
# Log de cambios:
# Versión 1.0:
# - Lanzamiento inicial
# <------- INICIO DEL PROGRAMA -------->
// Comprobación nº de argumentos
if peek("argument") > 3 then
print "[ERROR: #1] Too Many arguments."
print "Execute Status without arguments to see the usage examples. ;-)"
end
else
endif
// Comando Peek para usar argumentos
while (peek("argument"))
texto$=peek$("argument")
barra$=peek$("argument")
idioma$=peek$("argument")
wend
idioma$ = lower$(idioma$)
// Comprobamos idioma
switch idioma$
case "es"
progreso$="Progreso..."
cancelar$="Cancelar"
break
case "it"
progreso$="Progresso..."
cancelar$="Annulla"
break
case "ge"
progreso$="Fortschritt..."
cancelar$="Stornieren"
break
case "en"
progreso$="Progress..."
cancelar$="Cancel"
break
case "fr"
progreso$="Progrès..."
cancelar$="Annuler"
break
default
// Inglés por defecto
progreso$="Progress..."
cancelar$="Cancel"
break
end switch
if texto$ = "" then
uso()
else
endif
sub uso()
print ""
print "Status version " + appver$ + " - http://tanausugg.blogspot.com"
print ""
print "[INFO:] Displays a customizable statusbar from script or Terminal."
print "[USAGE:] Status \"Label\" \"Progress [0-100]\" \"Language\""
print "[USAGE:] Languages:"
print " - [EN] English (Default)"
print " - [ES] Spanish"
print " - [IT] Italian"
print " - [GE] German"
print " - [FR] French"
print ""
print "[EXAMPLES:]"
print "WIP"
end sub
# EOF
// Calculamos la posición de la ventana (Centro de la pantalla)
height=peek("desktopheight")
width=peek("desktopwidth")
width=width/2
x=width-140
x1=width+140
height=height/2
y=height-85
y1=height
// Creamos la ventana del programa"
window open x,y to x1,y1, "View", "Status"
// Se añaden los atributos de ventana no redimensionable y no zoomeable
window set "View", "flags", "not-resizable not-zoomable"
window set "View", "look", "modal"
// Se crea el contenido dentro de la ventana
view 0,10 to 550,450, "View1", "View"
BUTTON 205,60 TO 275,85, "bcancelar$", cancelar$, "View"
STATUSBAR 5, 10 TO 275, 50, ID$, "izq:", "der:", "View"
inloop = true
while(inloop)
msg$=message$
switch msg$
// Al pulsar el botón de cerrar la ventana
case "View:_QuitRequested|"
window close "View"
// Termina el programa
end
break
//Al pulsar el botón
case "bcancelar$|"
// Acaba el programa, hay que cerrar el view para que no nos aparezca el mensaje de "PROGRAMA FINALIZADO, PULSE ENTER"
window close "View"
// Termina el programa
end
break
end switch
// Termina el programa
wend
// EOF
RE: Update one Statusbar in realtime from bash? - bbjimmy - 01-02-2024
your button is in "View, but View1 is placed over top of View
I would suggest removing this line:
view 0,10 to 550,450, "View1", "View"
The main window, in this case "View" is the only view that is needed.
RE: Update one Statusbar in realtime from bash? - _-Caleb-_ - 01-07-2024
OMG true!!
Things of copy paste Code jajaja
Thanks bbjimmy!!
|