Get output from rofi-script #1895
-
Hi, I'm making a rofi script which is basically a filebrowser but it only lets me navigate inside a specific directory (I can go deeper into the subdirectories but not outside the specified directory). The idea is to use it to ask for a filename for another program (ffcast) and check if it's unique or if I'm overwriting an existing file. This is my code: #!/bin/sh
echo -e "\0prompt\x1fRecordings"
if [[ -n $ROFI_DATA ]]; then
rec_dir="$ROFI_DATA"
else
rec_dir="$SCREEN_RECS"
fi
rec_dir="${rec_dir%%/}"
full_selection="$rec_dir/$1"
if [ -d "$full_selection" ]; then
rec_dir=$(realpath "$full_selection")
elif [ -f "$full_selection" ]; then
# Here will go a rofi confirmation pop up
echo "Overwriting: $full_selection"
elif [ ! -e "$full_selection" ]; then
# ffcast -s rec "$full_selection" # This doesn't work because ffcast needs user input to execute
echo "$full_selection" # This reruns the current script with $full_selection as an element
exit 1
fi
if [[ "${rec_dir%%/}" != "${SCREEN_RECS%%/}" ]]; then
echo ".."
fi
echo -e "\0data\x1f$rec_dir"
echo -e "\0message\x1fCurrent dir: $rec_dir"
recs=()
for filename in $(ls -1 "$rec_dir"); do
path="$rec_dir/$filename"
recs+=("$filename")
if [ -d "$path" ]; then
echo -e "$filename\0icon\x1ffolder"
else
echo "$filename"
fi
done The script works fine, my problem is outputting the chosen/custom option so that another program can use it. Is it possible to tell the script to stop capturing its own output and just output to stdout and quit? My usage would be to have something like this in another script: filename=$(rofi -show record -theme screenrec_filename.rasi)
ffcast -s rec "$filename" Edit: Well, right after posting this I realized I can just echo the output into stderr and then exit. That works, but it's ugly so I'd still like to know if there is a proper way to do it |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Script mode is not intended to be part of another script. Or if you want to re-use existing rofi feature:
(We might need to tune filebrowser to be more useful for this, ill put that on the todo list. |
Beta Was this translation helpful? Give feedback.
Script mode is not intended to be part of another script.
If you need to use the output, use 'dmenu' emulation.
Or if you want to re-use existing rofi feature:
(We might need to tune filebrowser to be more useful for this, ill put that on the todo list.
Realize it works for opening, but not saving.)