elenapan/config/awesome/noodle/spotify.lua
elenapan 3f7f93822e Added spotify daemon and example spotify widget
Former-commit-id: c0cb2979b2
Former-commit-id: b49f80e039a49894ca2cd98679150fba4c091404
Former-commit-id: 785592b3bc72bebb2dad98c6f12ecaa514eaa206
Former-commit-id: 795b8b77c387b84fb24509fa97733a4b578df2d9
2019-09-19 09:22:38 +03:00

42 lines
1.1 KiB
Lua

local wibox = require("wibox")
local awful = require("awful")
local naughty = require("naughty")
-- Declare widgets
local spotify_artist = wibox.widget.textbox()
local spotify_title = wibox.widget.textbox()
-- Main widget that includes all others
local spotify_widget = wibox.widget {
-- Title widget
{
align = "center",
text = "---",
font = "sans 14",
widget = spotify_title
},
-- Artist widget
{
align = "center",
text = "---",
font = "sans 10",
widget = spotify_artist
},
spacing = 2,
layout = wibox.layout.fixed.vertical
}
-- Subcribe to spotify updates
awesome.connect_signal("evil::spotify", function(artist, title, status)
-- Do whatever you want with artist, title, status
-- ...
spotify_artist.text = artist
spotify_title.text = title
-- Example notification (might not be needed if spotify already sends one)
if status == "playing" then
naughty.notify({ title = "Spotify | Now Playing", message = title.." by "..artist })
end
end)
return spotify_widget