The officially official Devuan Forum!

You are not logged in.

#1 2025-10-26 18:26:50

greenjeans
Member
Registered: 2017-04-07
Posts: 1,284  
Website

Right-click extensions for file-managers to play music/video

I'm fond of right-click context menus, makes for an easy way to add some nice
functionality to file-managers. These are intended for PcmanFM but most FM's have
some mechanism for adding entries. For reference new .desktop entries for this
purpose go into ~/.local/share/file-manager/actions in PcmanFM. Both extensions
require ffmpeg, and the music one requires yad as well. Hopefully somebody might
find these useful, I like 'em a lot.

Play/Preview song: This one needs a script in addition to a .desktop in order to
provide the tiny gui which just gives the name of the file being played and an
exit button to stop.

playsong.desktop:

[Desktop Entry]
Type=Action
Name=Play audio file
Comment=Play entire audio file
Icon=audio-speakers
Profiles=fullsong;

[X-Action-Profile fullsong]
Exec=playsong %f
MimeTypes=audio/aac;audio/ac3;audio/mp2;audio/mp3;audio/mp4;audio/mpeg;audio/ogg;audio/flac;audio/wav;audio/vorbis;audio/3gpp;audio/x-ape;audio/x-musepack;audio/x-wavpack;

The playsong script, make it executable and put it in your $PATH:

#!/bin/bash

# Script to play a single song using ffplay.
# copyleft (c) greenjeans 2025
# Depends: yad, ffmpeg

# Check if file is provided
if [ -z "$1" ]; then
    echo "Usage: $0 <audio_file>"
    exit 1
fi

file="$1"
filename=$(basename "$file")

# Run ffplay in background
ffplay -nodisp -autoexit -loglevel quiet "$file" &
ffplay_pid=$!

# If ffplay fails to start, show error and exit
if ! kill -0 $ffplay_pid 2>/dev/null; then
    yad --title="Error" --text="Failed to start playback for $filename." \
        --window-icon=error --borders=10 --fixed --width=300 --height=100
    exit 1
fi

# Run yad dialog in background
yad --title="Now Playing" --text="Playing: $filename" --window-icon=audio-speakers --borders=10 --text-align=center --width=350 --button="Exit:20" --center &
yad_pid=$!

# Trap to ensure cleanup on script exit
trap 'kill $ffplay_pid 2>/dev/null; kill $yad_pid 2>/dev/null; killall yad 2>/dev/null; exit 0' EXIT

# Monitor ffplay process
while kill -0 $ffplay_pid 2>/dev/null; do
    # Check if yad is still running
    if ! kill -0 $yad_pid 2>/dev/null; then
        # Yad closed (e.g., X button), kill ffplay and exit
        kill $ffplay_pid 2>/dev/null
        exit 0
    fi
    sleep 0.5
done

# Ensure yad is closed when ffplay exits
kill $yad_pid 2>/dev/null
killall yad 2>/dev/null
exit 0

For the video player all we need is a .desktop, the video will open and start
playing automatically. It will have standard min/max/close buttons in the titlebar,
but ffplay also has a number of hotkeys to control the video, esc or q to stop,
p for pause/play etc. Check the ffplay man page for a full list.

playvid.desktop:

[Desktop Entry]
Type=Action
Name=Play video file
Comment=Play entire video file
Icon=emblem-multimedia
Profiles=fullvid;

[X-Action-Profile fullvid]
Exec=ffplay -autoexit -loglevel quiet %f
MimeTypes=video/mp4;video/mpeg;video/ogg;video/quicktime;video/webm;video/x-matroska;video/x-msvideo;video/3gpp

https://sourceforge.net/projects/vuu-do/ New Vuu-do isos uploaded October 2025!
Vuu-do GNU/Linux, minimal Devuan-based Openbox and Mate systems to build on. Also a max version for OB.
Devuan 5 mate-mini iso, pure Devuan, 100% no-vuu-do. wink Devuan 6 version also available for testing.
Please donate to support Devuan and init freedom! https://devuan.org/os/donate

Offline

Board footer