External User commands
-
External User commands would bring a lot of functionality to Strawberry. A placeholder for the URL of the currently played track, another one for the selected tracks and a menubar entry "User commands" to store and launch them would be enough for me.
Having this would be awesome: we could check integrity of the tracks, Realplay Gain them, open them in editors, move files to other locations according to rules, tweak the sound system, schedule the reproduction, display a spectrogram or the images on the directory, query the database... anything achievable with external commands or scripts would be two clics away. And users could share here some of their scripts.
Years ago, I managed to insert in Clementine a contextual menu entry that opened a kdialog menu with my favorite actions for the selected tracks and I used it a lot, so I'm think more people would welcome proper User commands. They mean lots of power at zero cost for the player!
And I'm not sure of this, but I guess such a feature could also make possible a few suggestions of this forum.
</car_seller>
-
To integrate user-defined commands into Strawberry Music Player without requiring programming changes to its code, we can leverage UNIX concepts like shell scripting, command-line utilities, and inter-process communication.
Tools like zenity can be useful for creating a GUI
#!/bin/bash # Define actions ACTION=$(zenity --list --title="Strawberry Actions" \ --column="Action" --height=300 \ "Check Integrity" \ "Normalize Volume (ReplayGain)" \ "Open in Editor" \ "Move Files" \ "Display Spectrogram" \ "Query Database" \ "Cancel") case $ACTION in "Check Integrity") echo "Checking integrity of files..." # Implement your integrity check command here ;; "Normalize Volume (ReplayGain)") echo "Normalizing volume..." # Add replaygain command here ;; "Open in Editor") echo "Opening files in editor..." # Example: open the currently selected file in a text editor xdg-open "$CURRENT_FILE" ;; "Move Files") echo "Moving files..." # Example: mv selected files to another directory mv "$CURRENT_FILE" /path/to/destination/ ;; "Display Spectrogram") echo "Generating spectrogram..." # Example: display spectrogram for current track sox "$CURRENT_FILE" -n spectrogram ;; "Query Database") echo "Querying database..." # Custom query logic here ;; *) echo "Cancelled." ;; esac
Integrate with Strawberry Use Strawberry's command-line options to pass information about the current track or playlist. Strawberry supports commands like:
--playuri <uri>: Play a specific track.
--stop: Stop playback.
--next: Play the next track.Combine this with environment variables to pass the currently playing track:
CURRENT_FILE=$(strawberry --playuri | awk '{print $1}')
Create a Keybinding Use a global hotkey (e.g., via your desktop environment or a tool like xbindkeys) to trigger the script. This avoids modifying Strawberry itself.
Share Scripts Create a shared directory (e.g., ~/.strawberry-scripts) where users can place their custom commands. Your main script could dynamically load commands from this directory.
Benefits
- MOSTLY No coding changes to Strawberry itself.
- Highly flexible: users can define their commands.
- Simple integration using existing UNIX tools.
- Community-friendly: users can share scripts.
EDIT> It just occured to me that this approach would not be good for Windows users, shucks
-
Yes, that's a good option for the currently played track. But as far as I know, it won't work for the selected track(s): we can't get that list with Strawberry commands or from dbus.
That's why I had done that dirty hack to Clementine's context menu. It got and sent the selection to kdialog, a KDE's zenity alternative that worked like you propose. Another option, which I still use, is drag & drop to a .desktop file or plasma widget that deals with the list.
And you're also right that it would be harder for less experienced and non *nix users to do it. Much easier is "Hey, download my .bat file and create a new User command called ReplayGain that executes C:\somewhere\file.bat %S".