Prev: 9.3. Hooking into Aqualung Events[ home ]Next: 9.5. Custom Remote Commands

9.4. Custom Playlist Menu Commands

You can add custom playlist menu commands to Aqualung by calling the `add_playlist_menu_command' function with a string and a function. The string is the label of the playlist menu entry, and the function is the function to call when the playlist menu entry is clicked. You can include `/''s inside the string to create submenus (there is currently no support for a `/' to appear inside a label). The function should accept 0 arguments.

Example 1: Exiting Aqualung immediately with an error code

add_playlist_menu_command("Exit Immediately!!", function ()
os.exit(1)
end)

Using this example is not recommended.

Example 2: Printing selected files to standard output

add_playlist_menu_command("Print Filenames", function ()
for k, v in pairs(selected_files()) do
print(v)
end
end)

Example 3: Running commands on file names, under a Database submenu

add_playlist_menu_command("Database/Add Favorite Tracks", function ()
for k, v in pairs(selected_files()) do
os.execute("add_favorite_track '" .. string.gsub(v, "'", "'\''") .. "'")
end
end)
add_playlist_menu_command("Database/Remove Favorite Tracks", function ()
for k, v in pairs(selected_files()) do
os.execute("remove_favorite_track '" .. string.gsub(v, "'", "'\''") .. "'")
end
end)

The string.gsub call is for escaping filenames, since Lua's os.execute sends the string argument to the shell.


Prev: 9.3. Hooking into Aqualung Events[ home ]Next: 9.5. Custom Remote Commands