#!/bin/bash

# Reverse the playlist and pause playback
audtool --playlist-reverse
audtool --playback-pause

# Prompt user with Zenity dialog
selection=$(zenity --list "OUI" "NON" "RÉÉCOUTER" --column="$(audtool --current-song)" --text="$(fortune -s)" --title="As-tu aimé ?" --width=500 --height=250 --window-icon=/home/user/Ressources/Icons/audacious_0.png & sleep 0.4 && xdotool key Down)

case "$selection" in
"OUI")
    # Execute script to delete the currently playing song
    fpath="$(audtool current-song-filename)"
    playlist_pos="$(audtool playlist-position)" 
    audtool playlist-delete "$playlist_pos" 
    notify-send -t 9000 "REMOVED: $fpath"
    echo "REMOVED: $fpath" >> ~/Audacious.log
    audtool --playback-play
    ;;
"NON")
    # Execute script to delete the currently playing song
    fpath="$(audtool current-song-filename)" 
    gio trash "$fpath"
    playlist_pos="$(audtool playlist-position)" 
    audtool playlist-delete "$playlist_pos" 
    notify-send -t 9000 "DELETED: $fpath" 
    echo "DELETED: $fpath" >> ~/Audacious.log
    audtool --playback-play
    ;;
"RÉÉCOUTER")
    # Resume playback from the beginning of the song
    audtool --playback-seek 0 --playback-play
    ;;
esac
