kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.44k stars 150 forks source link

mimetype.toml absolute path #208

Open Mageas opened 2 years ago

Mageas commented 2 years ago

I want to open .dlc files with jdownloader (jdownloader -co "/absolute/path/file.dlc").

dlc.app_list    = [
    { command = "jdownloader", args = [ "-co" ], fork = true, silent = true } ]

However, I wonder if there is a workaround to change the relative path to an absolute path (I tried some workarounds but without success).

life00 commented 6 months ago

I have the same problem except in my case I have an application that does not really like relative paths after initial file is opened - Sioyek. Basically after I open the first PDF file from Joshuto using Sioyek, it does not want to open other PDF files as new-window because it considers all paths provided relative to that initial file. It might be an issue with the PDF viewer, however it can be argued that absolute paths are expected as input.

It would be nice if it would be possible to toggle absolute or relative path, or I would even suggest making absolute path the default option.

life00 commented 6 months ago

I wish Joshuto used something more customizable instead of mimetype.toml . For example in rifle.conf from ranger the command itself and input arguments are directly exposed in the config. I don't need to make any separate scripts.

@Mageas the only solution is to make a separate script that properly handles relative paths and expands it into absolute ones. To solve my problem I had to create another executable and put it as program for PDFs in mimetype.toml with this inside:

#!/bin/sh

if [ -e "${1}" ]; then
  sioyek --new-window $(realpath -s "${1}")
else
  printf "File does not exist\n"
  exit 1
fi

Again, I would like to emphasize that in rifle.conf it would be just this that would do the trick:

ext pdf, has sioyek,   X, flag f = sioyek --new-window $(realpath -s "$1")

It is not perfect but it would work.