mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-01-15 11:08:00 +08:00
evil daemon system, dependency list update, README improvements.
Former-commit-id: db310f8e49
Former-commit-id: 4f25f9200c3ac9f9385daca5a68378249ff0329e
Former-commit-id: 69fa3954e5738446a59b409b7e326233e7c3ef55
Former-commit-id: 673176f7857e39f3455f4ccb426eef2789c0e891
46 lines
1.3 KiB
Lua
46 lines
1.3 KiB
Lua
-- Provides:
|
|
-- evil::mpd
|
|
-- artist (string)
|
|
-- song (string)
|
|
-- paused (boolean)
|
|
local awful = require("awful")
|
|
|
|
local function emit_info()
|
|
awful.spawn.easy_async({"mpc", "-f", "[[%artist%@@%title%@]]"},
|
|
function(stdout)
|
|
local artist = stdout:match('(.*)@@')
|
|
local title = stdout:match('@@(.*)@')
|
|
title = string.gsub(title, '^%s*(.-)%s*$', '%1')
|
|
local status = stdout:match('%[(.*)%]')
|
|
status = string.gsub(status, '^%s*(.-)%s*$', '%1')
|
|
|
|
local paused
|
|
if status == "playing" then
|
|
paused = false
|
|
else
|
|
paused = true
|
|
end
|
|
|
|
awesome.emit_signal("evil::mpd", artist, title, paused)
|
|
end
|
|
)
|
|
end
|
|
|
|
-- Run once to initialize widgets
|
|
emit_info()
|
|
|
|
-- Sleeps until mpd changes state (pause/play/next/prev)
|
|
local mpd_script = [[
|
|
sh -c '
|
|
mpc idleloop player
|
|
']]
|
|
|
|
-- Kill old mpc idleloop player process
|
|
awful.spawn.easy_async_with_shell("ps x | grep \"mpc idleloop player\" | grep -v grep | awk '{print $1}' | xargs kill", function ()
|
|
-- Emit song info with each line printed
|
|
awful.spawn.with_line_callback(mpd_script, {
|
|
stdout = function(line)
|
|
emit_info()
|
|
end
|
|
})
|
|
end)
|