Created
June 18, 2023 20:52
-
-
Save VonHeikemen/abe763f277c34ba7a4e524f237d187f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/lua | |
--[[* | |
* test case: cmus-notify status playing file path title hola artist qace album ok | |
* | |
* installation: | |
* - Set the status_display_program variable in cmus | |
* :set status_display_program=/path-to/cmus-notify.lua | |
* | |
* - Save the changes using | |
* :save | |
*]] | |
local function q(str) | |
return string.gsub(str, "'", "'\"'\"'") | |
end | |
local message = '<b>Artist:</b> Unknown' | |
local title = '' | |
for i=3, #arg, 2 do | |
local key = arg[i] | |
local value = arg[i + 1] | |
if key == 'file' then | |
title = value:match("^.+/(.+)$") | |
end | |
if key == 'title' and value then | |
title = value | |
end | |
if key == 'artist' and value then | |
message = string.format('<b>Artist:</b> %s', value) | |
end | |
if key == 'album' and value then | |
message = string.format('%s\\n<b>Album:</b> %s', message, value) | |
end | |
end | |
local cmd = "notify-send '%s' '%s'" | |
os.execute(string.format(cmd, q(title), q(message))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment