LukeSmithxyz / voidrice

My dotfiles (deployed by LARBS)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential for Minimizing Lfrc

emrakyz opened this issue · comments

With the latest version of "lfrc", some file types cause problems.

For example, some text files that should be opened with an editor, are opened with "Libreoffice Writer". Morever spreadsheet files can't even be opened while "xdg-open" or similar commands can open those files with correct applications.

Normally, we set our environment by mime-types. Why do we specify programs in "lfrc" by increasing the complexity, instead of using a minimal configuration file that can open files with default set applications?

I understand the use case of "sxiv" with rotdir script. We also want to open some applications (scripts) as texts rather than running them. But for others I find the extra configuration, unnecessary and complex.

I won't open a PR for this since I am not sure about the specific use case. Maybe Luke has some specific use case or explanation for the extra lines.

I use this minimized function with the exact same functionality (for my use case):

cmd open ${{
    case $(file --mime-type "$(readlink -f $f)" -b) in
        text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
	image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
		setsid -f sxiv -aio 2>/dev/null | while read -r file; do
			[ -z "$file" ] && continue
			lf -remote "send select \"$file\""
			lf -remote "send toggle"
		done &
		;;
        *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
    esac
}}

Rather than this huge block:

cmd open ${{
    case $(file --mime-type "$(readlink -f $f)" -b) in
	application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
	image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;;
        text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
	image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;;
	image/svg+xml) display -- $f ;;
	image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
		setsid -f sxiv -aio 2>/dev/null | while read -r file; do
			[ -z "$file" ] && continue
			lf -remote "send select \"$file\""
			lf -remote "send toggle"
		done &
		;;
	audio/*|video/x-ms-asf) mpv --audio-display=no $f ;;
	video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;;
	application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;;
	application/pgp-encrypted) $EDITOR $fx ;;
	application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f libreoffice $fx >/dev/null 2>&1 ;;
        *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;;
    esac
}}