Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Execute system command and lua command successively #403

Closed
jaysonwillson opened this issue Aug 12, 2015 · 1 comment
Closed

Comments

@jaysonwillson
Copy link
Contributor

Hello.
I have the following situation in my rc.lua -- I have special keybinds for changing volume or turning it off, they use "amixer". I also need to update my volume widget's information after every execution of such command. I update volume widget's information using update_volume(volume_widget) lua command, which is provided by volume widget itself.

I tried the following configuration:
function ()
awful.util.spawn("amixer set Master 4%+ on")
update_volume(volume_widget)
end)

But I met a problem: volume widget is updated faster, than volume changes, so its information is not correct.

I have also tried the following two methods:

local f = io.popen("amixer set Master 4%+ on")
f:close()
update_volume(volume_widget)

and

os.execute("amixer set Master 4%+ on")
update_volume(volume_widget)

They both work fine, and update_volume runs just after "amixer" finishes its execution.
But one man has said, that when I use such commands as io.popen;close and os.execute, the whole Awesome freezes and waits, until "amixer" command finishes its execution. Is it so?

If it is, could you please recommend me, how should I implement the following: "Run lua command just after system command finishes its execution" in a correct way? I know that I can run "amixer ... && echo "update_volume(volume_widget)" | awesome-client", but it seems to be a slow and ungraceful solution.

@psychon
Copy link
Member

psychon commented Oct 17, 2015

It's not the best API, but we now have awful.spawn.with_line_callback("amixer, set Master 4%+ on", function() end(), function() end, function() update_volume(volume_widget) end). This needs those "empty functions" to work correctly. Hm....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants