From: Samir Benmendil Date: Wed, 5 Aug 2020 20:12:31 +0000 (+0100) Subject: awesome/mpd_widget: put scroll widget part of mpd_widget X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/97ac5f3183850ca04f7db935f2a7220618005953 awesome/mpd_widget: put scroll widget part of mpd_widget --- diff --git a/awesome/topbar.lua b/awesome/topbar.lua index 62ca934..3d73e11 100644 --- a/awesome/topbar.lua +++ b/awesome/topbar.lua @@ -103,16 +103,7 @@ awful.screen.connect_for_each_screen(function(s) separator, require("widgets/pomodoro"), separator, - -- TODO move to mpd_widget - wibox.widget { - layout = wibox.container.scroll.horizontal, - max_size = 200, - step_function = wibox.container.scroll.step_functions.linear_increase, - speed = 20, - { - widget = require("widgets/mpd_widget") - } - }, + require("widgets/mpd_widget"), separator, require("widgets/volume_widget"), utils.has_battery() and { diff --git a/awesome/widgets/mpd_widget.lua b/awesome/widgets/mpd_widget.lua index f5f0ce7..1807054 100644 --- a/awesome/widgets/mpd_widget.lua +++ b/awesome/widgets/mpd_widget.lua @@ -4,6 +4,7 @@ local gears = require("gears") local awful = require("awful") local naughty = require("naughty") local timer = require("gears.timer") +local wibox = require("wibox") --TODO remove local dbg = require("gears.debug") @@ -12,6 +13,19 @@ local widget = {} widget._textbox = textbox() widget._currentsong = {} +widget.scroll = wibox.widget { + layout = wibox.container.scroll.horizontal, + forced_width = 200, + expand = true, + step_function = wibox.container.scroll.step_functions.linear_increase, + speed = 20, + { + widget = widget._textbox, + align = 'center', + valign = 'center' + } +} + function widget:update_widget() local text = "" local artist = self._currentsong.artist @@ -131,13 +145,13 @@ function widget:run() self._timer:connect_signal("timeout", function() self:popup_update() end) self._hover = false; - self._textbox:connect_signal("mouse::enter", function() self._hover = true; self:popup_show() end) - self._textbox:connect_signal("mouse::leave", function() self._hover = false; self:popup_hide(2) end) + self.scroll:connect_signal("mouse::enter", function() self._hover = true; self:popup_show() end) + self.scroll:connect_signal("mouse::leave", function() self._hover = false; self:popup_hide(2) end) end widget:run() -widget._textbox:buttons(gears.table.join( +widget.scroll:buttons(gears.table.join( awful.button({}, 1, function() widget._connection:toggle_play() end) , awful.button({}, 4, function() widget._connection:change_volume(5) end) , awful.button({}, 5, function() widget._connection:change_volume(-5) end)) @@ -153,4 +167,4 @@ globalkeys = gears.table.join(globalkeys, awful.key({ modkey }, ".", function() widget._connection:send("next") end, { description = "next track", group = "mpd" }) ) -return widget._textbox +return widget.scroll