I have this script (from the internet) to cut media files:
#!/bin/bash
INPUT=$(kdialog --getopenfilename '*.m4a *.ogg *.mp3 *.mp4 *.avi *.aac *.flac *.avi *.mkv *.mp4')
eval $(yad --width=400 --form --field=start --field=end --field=output:SFL "00:00:00" "00:00:00" "${INPUT/%.*}-out.${INPUT##*.}" | awk -F'|' '{printf "START=%s\nEND=%s\nOUTPUT=\"%s\"\n", $1, $2, $3}')
[[ -z $START || -z $END || -z $OUTPUT ]] && exit 1
DIFF=$(($(date +%s --date="$END")-$(date +%s --date="$START")))
OFFSET=""$(($DIFF / 3600)):$(($DIFF / 60 % 60)):$(($DIFF % 60))
$(ffmpeg -ss "$START" -t "$OFFSET" -i "$INPUT" -c copy "$OUTPUT")
(for i in $(seq 0 3 100); do echo "$i"; sleep 0.1; done) | yad --progress --width=400 --auto-close
if [ $? -eq 0 ]; then
kdialog --msgbox "Process completed successfully!"
else
kdialog --msgbox "SOMETHING WENT WRONG!"
fi
The main part is based on yad
, but the first (selection) and last one (finish messages) are using kdialog
because I’m in Plasma.
When run, the script is meant to open a file selection dialog. My intention though is to skip the first part by running the script as a Dolphin service menu or from a launcher. Thus, I can simply select the file in Dolphin:
But, run in this way, the script does not select the file, although the --getopenfilename
option and arguments allow kdialog
to already open the location of the file and restrict the files listed to media files. Although I have already selected the file in Dolphin, kdialog
is in this way asking me to select again:
and only after selecting again I get the yad
window I would like to see directly:
Can I modify the script so that INPUT=
sends the file to the yad
process directly, without the need for the kdialog
selection, so that when I select the file in Dolphin the window in last image is immediately available?