Project

General

Profile

Script to delete currently playing track

Added by Daniel Bedrenko almost 8 years ago

It has been nagging me for a while that deleting a song using the "Service -> Delete Selected Files" plugin wasn't convenient enough.

So I want to share a small script I wrote to delete the currently playing song from the filesystem and from the playlist. You can bind it to a keyboard shortcut.

#!/bin/bash
# Deletes the currently playing song from the filesystem and from the playlist.
set -eu
set -o pipefail

# Avoid accidentally deleting next song if pressed delete too late and it
# already advanced to the next song.
seconds_playing="$(audtool current-song-output-length-seconds)" 
if [ $seconds_playing -gt 5 ]; then
    fpath="$(audtool current-song-filename)" 
    mv "$fpath" ~/.local/share/Trash/files
    playlist_pos="$(audtool playlist-position)" 
    audtool playlist-delete "$playlist_pos" 
    notify-send -t 3000 "DELETED: $fpath" 
fi

Replies (1)

RE: Script to delete currently playing track - Added by Daniel Bedrenko almost 8 years ago

The `notify-send` line shows a notification on what file you deleted just so you're sure you deleted the right thing. If you don't have `libnotify` installed you can comment it out.

    (1-1/1)