You are not logged in.
I want to open .webm, .mp3, .flac kind of files with lf but I didn't manage to it. here my lfrc config.
# Basic vars
#set icons
set cleaner '~/.config/lf/cleaner'
set previewer '~/.config/lf/scope'
set drawbox
set ignorecase true
cmd open ${{
case $(file --mime-type $f -b) in
image/vnd.djvu|application/pdf|application/octet-stream) setsid -f mupdf $fx >/dev/null 2>&1 ;;
text/*) $EDITOR $fx;;
image/x-xcf|image/svg+xml) setsid -f gimp $f >/dev/null 2>&1 ;;
image/*) nsxiv $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\)\(_large\)*$" | sxiv -aio 2>/dev/null | lf-select ;;
audio/*) mpv --audio-display=no $f ;;
video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
application/pdf|application/vnd*|application/epub*) setsid -f mupdf $fx >/dev/null 2>&1 ;;
*) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
esac
}}
cmd mkdir ${{
printf "Directory Name: "
read ans
mkdir $ans
}}
cmd mkfile ${{
printf "File Name: "
read ans
$EDITOR $ans
}}
cmd delete ${{
clear; tput cup $(($(tput lines)/3)); tput bold
set -f
printf "%s\n\t" "$fx"
printf "delete?[y/N]"
read ans
[ $ans = "y" ] && rm -rf -- $fx
}}
#bindings
map . set hidden!
map p paste
map x cut
map y copy
map <enter> open
map A rename
map r push A<a-b><a-b><a-f>
map D delete
map m
map o
map n
map "'"
map '"'
map dThanks.
Offline
OPENER
If this variable is set in the environment, use the same value, otherwise set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others.
echo $OPENER
xdg-openset up xdg-open to do what you want.
info here: https://wiki.archlinux.org/title/XDG_MIME_Applications
Offline
man lf wrote:OPENER
If this variable is set in the environment, use the same value, otherwise set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others.
echo $OPENER xdg-openset up xdg-open to do what you want.
info here: https://wiki.archlinux.org/title/XDG_MIME_Applications
Okay everything works well expect audio files .mp3 .flac still not opening when I press open button nothing happens. my latest lfrc config:
cmd open ${{
test -L $f && f=$(readlink -f $f)
case "$(file --mime-type "$f" -b)" in
text/*) nvim $fx;;
audio/*) mpv --audio-display=no $f ;;
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
esac
}} Offline
Add a few echo statements.
Offline
i just tried your config and it works fine so you've got somthing else going wrong somewhere
EDIT: just to clarify i used your 'open' config not your whole lfrc
Last edited by jonno2002 (2022-09-14 03:33:21)
Offline
i just tried your config and it works fine so you've got somthing else going wrong somewhere
EDIT: just to clarify i used your 'open' config not your whole lfrc
I think it is about file names. I have file named "Vengaboys - Boom, Boom, Boom, Boom!!.flac" I tried opening that, it gave this error:
--: line 2: test: syntax error: `-' unexpected
I changed name to "boom.flac" for testing, now I can open the file. Any idea why this happens?
Offline
"the wind-blown way, wanna win? don't play"
Offline
i figured it out, i have this at the top of my lfrc which is part of the lfrc example (/usr/share/doc/lf/lfrc.example):
# interpreter for shell commands
set shell sh
# set '-eu' options for shell commands
# These options are used to have safer shell commands. Option '-e' is used to
# exit on error and option '-u' is used to give error for unset variables.
# Option '-f' disables pathname expansion which can be useful when $f, $fs, and
# $fx variables contain names with '*' or '?' characters. However, this option
# is used selectively within individual commands as it can be limiting at
# times.
set shellopts '-eu'
# set internal field separator (IFS) to "\n" for shell commands
# This is useful to automatically split file names in $fs and $fx properly
# since default file separator used in these variables (i.e. 'filesep' option)
# is newline. You need to consider the values of these options and create your
# commands accordingly.
set ifs "\n"
# leave some space at the top and the bottom of the screen
set scrolloff 10this is the bit your after:
set ifs "\n"will fix your problem like magic !
Offline
Additionally, set ifs to "\n" in case you want $fx to work correctly when multiple files are selected.
EDIT: Too slow.
Last edited by tucuxi (2022-09-14 16:13:18)
Offline
i figured it out, i have this at the top of my lfrc which is part of the lfrc example (/usr/share/doc/lf/lfrc.example):
# interpreter for shell commands set shell sh # set '-eu' options for shell commands # These options are used to have safer shell commands. Option '-e' is used to # exit on error and option '-u' is used to give error for unset variables. # Option '-f' disables pathname expansion which can be useful when $f, $fs, and # $fx variables contain names with '*' or '?' characters. However, this option # is used selectively within individual commands as it can be limiting at # times. set shellopts '-eu' # set internal field separator (IFS) to "\n" for shell commands # This is useful to automatically split file names in $fs and $fx properly # since default file separator used in these variables (i.e. 'filesep' option) # is newline. You need to consider the values of these options and create your # commands accordingly. set ifs "\n" # leave some space at the top and the bottom of the screen set scrolloff 10this is the bit your after:
set ifs "\n"will fix your problem like magic !
it really fixed my problem like magic, thanks a lot!
Offline