You are not logged in.

#1 2022-09-13 10:19:20

xctp21kkde
Member
Registered: 2022-09-13
Posts: 4

question about opening files with lf file manager

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 d

Thanks.

Offline

#2 2022-09-13 11:18:19

jonno2002
Member
Registered: 2016-11-21
Posts: 887

Re: question about opening files with lf file manager

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-open

set up xdg-open to do what you want.

info here: https://wiki.archlinux.org/title/XDG_MIME_Applications

Offline

#3 2022-09-13 15:20:51

xctp21kkde
Member
Registered: 2022-09-13
Posts: 4

Re: question about opening files with lf file manager

jonno2002 wrote:
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-open

set 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

#4 2022-09-13 16:11:55

tucuxi
Member
From: Switzerland
Registered: 2020-03-08
Posts: 291

Re: question about opening files with lf file manager

Add a few echo statements.

Offline

#5 2022-09-14 03:28:37

jonno2002
Member
Registered: 2016-11-21
Posts: 887

Re: question about opening files with lf file manager

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

#6 2022-09-14 09:47:22

xctp21kkde
Member
Registered: 2022-09-13
Posts: 4

Re: question about opening files with lf file manager

jonno2002 wrote:

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

#7 2022-09-14 11:26:42

CarbonChauvinist
Member
Registered: 2012-06-16
Posts: 413
Website

Re: question about opening files with lf file manager


"the wind-blown way, wanna win? don't play"

Offline

#8 2022-09-14 16:11:02

jonno2002
Member
Registered: 2016-11-21
Posts: 887

Re: question about opening files with lf file manager

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 10

this is the bit your after:

set ifs "\n"

will fix your problem like magic !

Offline

#9 2022-09-14 16:12:00

tucuxi
Member
From: Switzerland
Registered: 2020-03-08
Posts: 291

Re: question about opening files with lf file manager

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

#10 2022-09-14 21:53:44

xctp21kkde
Member
Registered: 2022-09-13
Posts: 4

Re: question about opening files with lf file manager

jonno2002 wrote:

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 10

this 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

Board footer

Powered by FluxBB