Removed music lua
This commit is contained in:
parent
edf1cd6989
commit
8020f654dd
103
music.lua
103
music.lua
|
@ -1,103 +0,0 @@
|
|||
local naughty = require("naughty")
|
||||
local wibox = require("wibox")
|
||||
local awful = require("awful")
|
||||
local su = require('su')
|
||||
|
||||
local ret = {}
|
||||
ret.text_widget = wibox.widget.textbox()
|
||||
ret.text_widget:set_align("right")
|
||||
ret.text_widget.font = "Ubuntu Mono"
|
||||
|
||||
ret.icon_widget = wibox.widget.textbox()
|
||||
ret.icon_widget:set_align("right")
|
||||
ret.icon_widget.font = "Ubuntu Mono"
|
||||
|
||||
|
||||
local icon = ""
|
||||
local total_text = ""
|
||||
local position = 1
|
||||
local width = 30
|
||||
local dots = 3
|
||||
|
||||
local function set_text(text)
|
||||
total_text = text
|
||||
|
||||
if string.len(total_text) >= width then
|
||||
position = math.floor((width - string.len(total_text)) / 2)
|
||||
end
|
||||
end
|
||||
|
||||
local function try_noop()
|
||||
|
||||
awful.spawn.easy_async_with_shell('sleep 2s && music-client noop', function(stdout, stderr, reason, code)
|
||||
|
||||
if code == 1 then
|
||||
try_noop()
|
||||
elseif code == 0 then
|
||||
ret.execute_command('noop')
|
||||
end
|
||||
end);
|
||||
|
||||
end
|
||||
|
||||
ret.execute_command = function(command, arg)
|
||||
|
||||
awful.spawn.easy_async({'music-client', command, arg}, function(stdout, stderr, reason, code)
|
||||
|
||||
local text = su.split(stdout, '\n')
|
||||
local active_command =
|
||||
su.starts_with(command, 'file') or
|
||||
su.starts_with(command, 'next') or
|
||||
su.starts_with(command, 'previous')
|
||||
|
||||
local start_server_command = active_command or
|
||||
su.starts_with(command, 'play') or
|
||||
su.starts_with(command, 'pause')
|
||||
|
||||
if code == 0 then
|
||||
|
||||
if active_command then
|
||||
set_text(text[1])
|
||||
elseif su.starts_with(command, 'noop') then
|
||||
total_text = text[1]
|
||||
position = math.floor((width - string.len(total_text)) / 2)
|
||||
end
|
||||
|
||||
elseif start_server_command then
|
||||
-- Start the server and re-exec the command
|
||||
awful.spawn.easy_async({'music-server', 'command', command, arg}, function(stdout, stderr, reason, code)
|
||||
end)
|
||||
else
|
||||
set_text('music-server not running')
|
||||
end
|
||||
|
||||
if text[2] ~= nil then
|
||||
icon = text[2]
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
function update_widget()
|
||||
ret.icon_widget:set_text(' ' .. icon .. ' ')
|
||||
if string.len(total_text) < width then
|
||||
ret.text_widget:set_text(' ' .. su.pad(total_text, width + 1, ' '))
|
||||
else
|
||||
local pos = math.min(position, string.len(total_text) - width)
|
||||
pos = math.max(1, pos)
|
||||
ret.text_widget:set_text(' ' .. string.sub(total_text, pos, pos + width))
|
||||
position = position + 1
|
||||
if position > string.len(total_text) then
|
||||
position = math.floor((width - string.len(total_text)) / 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ret.execute_command('noop')
|
||||
|
||||
ret.timer = timer({timeout=0.2})
|
||||
ret.timer:connect_signal("timeout", update_widget)
|
||||
ret.timer:start()
|
||||
|
||||
return ret
|
4
rc.lua
4
rc.lua
|
@ -210,7 +210,6 @@ local tasklist_buttons = awful.util.table.join(
|
|||
end))
|
||||
|
||||
local launchbar = require('launchbar')
|
||||
local music = require('music')
|
||||
-- local background = require('background_widget')
|
||||
local delimiter = wibox.widget.textbox(" | ")
|
||||
local delimiter2 = wibox.widget.textbox(" ")
|
||||
|
@ -274,9 +273,6 @@ awful.screen.connect_for_each_screen(function(s)
|
|||
{ -- Right widgets
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
delimiter,
|
||||
music.icon_widget,
|
||||
music.text_widget,
|
||||
delimiter,
|
||||
email_widget.icon,
|
||||
delimiter2,
|
||||
email_widget.widget,
|
||||
|
|
Loading…
Reference in New Issue