wrap widget in a function
This commit is contained in:
parent
0e1d31ad6f
commit
30199568c6
|
@ -19,7 +19,7 @@ local TOGGLE_MPD_CMD = "playerctl play-pause"
|
||||||
local PAUSE_MPD_CMD = "playerctl pause"
|
local PAUSE_MPD_CMD = "playerctl pause"
|
||||||
local STOP_MPD_CMD = "playerctl stop"
|
local STOP_MPD_CMD = "playerctl stop"
|
||||||
local NEXT_MPD_CMD = "playerctl next"
|
local NEXT_MPD_CMD = "playerctl next"
|
||||||
local PREV_MPD_CMD = "playerctl prev"
|
local PREV_MPD_CMD = "playerctl previous"
|
||||||
|
|
||||||
local PATH_TO_ICONS = "/usr/share/icons/Arc"
|
local PATH_TO_ICONS = "/usr/share/icons/Arc"
|
||||||
local PAUSE_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_pause.png"
|
local PAUSE_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_pause.png"
|
||||||
|
@ -27,8 +27,13 @@ local PLAY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_play.png"
|
||||||
local STOP_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_stop.png"
|
local STOP_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_stop.png"
|
||||||
local LIBRARY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/music-library.png"
|
local LIBRARY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/music-library.png"
|
||||||
|
|
||||||
|
|
||||||
|
local mpdarc_widget = {}
|
||||||
|
|
||||||
|
local function worker(args)
|
||||||
|
|
||||||
-- retriving song info
|
-- retriving song info
|
||||||
current_song, artist = nil, nil
|
local current_song, artist, mpdstatus
|
||||||
|
|
||||||
local icon = wibox.widget {
|
local icon = wibox.widget {
|
||||||
id = "icon",
|
id = "icon",
|
||||||
|
@ -107,7 +112,7 @@ mpdarc:connect_signal("button::press", function(_, _, _, button)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local notification
|
local notification
|
||||||
function show_MPD_status()
|
local function show_MPD_status()
|
||||||
spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _)
|
spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _)
|
||||||
notification = naughty.notify {
|
notification = naughty.notify {
|
||||||
text = current_song .. " by " .. artist,
|
text = current_song .. " by " .. artist,
|
||||||
|
@ -127,10 +132,16 @@ mpdarc:connect_signal("mouse::leave",
|
||||||
|
|
||||||
watch(GET_MPD_CMD, 1, update_graphic, mpdarc)
|
watch(GET_MPD_CMD, 1, update_graphic, mpdarc)
|
||||||
|
|
||||||
local mpdarc_widget = wibox.widget {
|
mpdarc_widget = wibox.widget {
|
||||||
screen = 'primary',
|
screen = 'primary',
|
||||||
mpdarc_icon_widget,
|
mpdarc_icon_widget,
|
||||||
mpdarc_current_song_widget,
|
mpdarc_current_song_widget,
|
||||||
layout = wibox.layout.align.horizontal
|
layout = wibox.layout.align.horizontal
|
||||||
}
|
}
|
||||||
return mpdarc_widget
|
return mpdarc_widget
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(mpdarc_widget, { __call = function(_, ...)
|
||||||
|
return worker(...)
|
||||||
|
end })
|
Loading…
Reference in New Issue