From 8308de4e6cb44a84bd326cccd74a1017648aaabd Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 25 May 2025 19:14:21 +0530 Subject: modified dwm luastatus scripts --- .config/luastatus-scripts-dwm/mpd.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .config/luastatus-scripts-dwm/mpd.lua (limited to '.config/luastatus-scripts-dwm/mpd.lua') diff --git a/.config/luastatus-scripts-dwm/mpd.lua b/.config/luastatus-scripts-dwm/mpd.lua new file mode 100644 index 0000000..32cddc6 --- /dev/null +++ b/.config/luastatus-scripts-dwm/mpd.lua @@ -0,0 +1,32 @@ +-- you need to install 'utf8' module (e.g. with luarocks) if using Lua <=5.2. +utf8 = require 'utf8' + +titlewidth = 40 + +widget = { + plugin = 'mpd', + cb = function(t) + if t.what == 'update' then + local title + if t.song.Title then + title = t.song.Title + if t.song.Artist then + title = t.song.Artist .. ': ' .. title + end + else + title = t.song.file or '' + end + title = (utf8.len(title) <= titlewidth) + and title + or utf8.sub(title, 1, titlewidth - 1) .. '…' + + return string.format('%s %s', + ({play = '▶', pause = '‖', stop = '■'})[t.status.state], + title + ) + else + -- 'connecting' or 'error' + return t.what + end + end +} -- cgit v1.2.3