]> git.rmz.io Git - dotfiles.git/blobdiff - awesome/widgets/mpc.lua
awesome: new mpd widget using mpc.lua
[dotfiles.git] / awesome / widgets / mpc.lua
index c8967c743a91290933fec3e66582945b3c0acf1a..f357f18b48b54dd85a70241b5a41dc7e2534e818 100644 (file)
@@ -203,6 +203,17 @@ function mpc:toggle_play()
     end)
 end
 
+function clamp(x, min, max)
+    return math.min(math.max(x, min), max)
+end
+
+function mpc:change_volume(change)
+    self:send("status", function(_, status)
+        new_vol = clamp(tonumber(status.volume) + change, 0, 100)
+        self:send("setvol " .. new_vol)
+    end)
+end
+
 --[[
 
 -- Example on how to use this (standalone)