]> git.rmz.io Git - dotfiles.git/blobdiff - awesome/widgets/mpc.lua
mutt: fix F macro to not write message to home
[dotfiles.git] / awesome / widgets / mpc.lua
index c8967c743a91290933fec3e66582945b3c0acf1a..d870f2f8f3cc374b63be48fd23f43a65a5a4450c 100644 (file)
@@ -203,6 +203,26 @@ 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
+
+function mpc:currentsong()
+    local currentsong
+    self:send("currentsong", function(err, song)
+        if err then error(err) end
+        currentsong = song
+    end)
+    return currentsong
+end
+
 --[[
 
 -- Example on how to use this (standalone)