You are not logged in.
Hello, everyone. I created a textbox, named "battext", to tell me my current battery percentage. I use the execute_command function to give me the output of a Perl script, which retrieves only the battery percentage from the output of acpi.
function execute_command(command)
local fh = io.popen(command)
local str = ""
for i in fh:lines() do
str = str .. i
end
io.close(fh)
return str
end
battext = widget({ type = "textbox", name = "battext" })
battext.text = execute_command("/home/babkock/bin/batterypercent")This is /home/babkock/bin/batterypercent, the Perl script I mentioned:
#!/usr/bin/perl
print '',( `acpi` =~ /(\d+)%/ )[ 0 ] // '??', "%\n";Now, the problem is, the battery percentage changes, but the textbox stays the same. When I start Awesome, the textbox will say something like "85%", and after a few minutes, the Perl script outputs "80%", so the textbox is wrong. How do I update the textbox? I've read about "signals" and "hooks", but those are tied to events. I just want an endless while loop that changes the textbox to run in the background. How do I go about doing this? Can I use a signal or a hook with a standard boolean logic conditional, so I can just compare the output of the Perl script to the content of the textbox?
Thanks.
Offline
Your code is executed only once. You need a timer to fire periodically. Read up https://awesome.naquadah.org/wiki/Widge … me#textbox
You need to install an RTFM interface.
Offline
Thanks anrxc, that worked ![]()
Offline