]> git.rmz.io Git - dotfiles.git/commitdiff
awesome/mpd_widget: put scroll widget part of mpd_widget
authorSamir Benmendil <me@rmz.io>
Wed, 5 Aug 2020 20:12:31 +0000 (21:12 +0100)
committerSamir Benmendil <me@rmz.io>
Sat, 8 Aug 2020 10:48:41 +0000 (11:48 +0100)
awesome/topbar.lua
awesome/widgets/mpd_widget.lua

index 62ca934da3af859064bf43b91fbaeb99793770d8..3d73e11034b13fc3e7fd38abb698d026b3b15002 100644 (file)
@@ -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 {
index f5f0ce74f640a32424504a1fc27d53e8bb539202..180705492ec564a8336eede662a13fbdceb0b241 100644 (file)
@@ -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