mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-01-11 09:11:01 +08:00
Support some MPD option evil signals
Currently `loop` and `random` options are monitored
This commit is contained in:
parent
be5367f7f2
commit
dbae9e2416
1 changed files with 31 additions and 0 deletions
|
|
@ -5,6 +5,9 @@
|
|||
-- paused (boolean)
|
||||
-- evil::mpd_volume
|
||||
-- value (integer from 0 to 100)
|
||||
-- evil::mpd_options
|
||||
-- loop (boolean)
|
||||
-- random (boolean)
|
||||
local awful = require("awful")
|
||||
|
||||
local function emit_info()
|
||||
|
|
@ -80,3 +83,31 @@ awful.spawn.easy_async_with_shell("ps x | grep \"mpc idleloop mixer\" | grep -v
|
|||
end
|
||||
})
|
||||
end)
|
||||
|
||||
local mpd_options_script = [[
|
||||
sh -c "
|
||||
mpc idleloop options
|
||||
"]]
|
||||
|
||||
local function emit_options_info()
|
||||
awful.spawn.easy_async_with_shell("mpc | tail -1",
|
||||
function(stdout)
|
||||
local loop = stdout:match('repeat: (.*)')
|
||||
local random = stdout:match('random: (.*)')
|
||||
awesome.emit_signal("evil::mpd_options", loop:sub(1, 2) == "on", random:sub(1, 2) == "on")
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
-- Run once to initialize widgets
|
||||
emit_options_info()
|
||||
|
||||
-- Kill old mpc idleloop options process
|
||||
awful.spawn.easy_async_with_shell("ps x | grep \"mpc idleloop options\" | grep -v grep | awk '{print $1}' | xargs kill", function ()
|
||||
-- Emit song info with each line printed
|
||||
awful.spawn.with_line_callback(mpd_options_script, {
|
||||
stdout = function()
|
||||
emit_options_info()
|
||||
end
|
||||
})
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue