sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
16.46k stars 383 forks source link

Send with KDE connect #1625

Closed moshpirit closed 2 months ago

moshpirit commented 2 months ago

yazi --debug output

Yazi
    Version: 0.3.3 (Arch Linux 2024-09-05)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.3 (Arch Linux 2024-09-05)

Emulator
    Emulator.via_env: ("xterm-256color", "")
    Emulator.via_csi: Ok(Kitty)
    Emulator.detect : Kitty

Adapter
    Adapter.matches: Kitty

Desktop
    XDG_SESSION_TYPE           : Some("x11")
    WAYLAND_DISPLAY            : None
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL              : Some("/bin/bash")
    EDITOR             : Some("nvim")
    VISUAL             : None
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None

Text Opener
    default: Some(Opener { run: "${EDITOR} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "${EDITOR} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : 3.4
    ZELLIJ_SESSION_NAME: None
    Zellij version     : 0.40.1

Dependencies
    file             : 5.45
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: 2.2.2
    magick           : 7.1.1-38
    fzf              : 0.54.3
    fd               : 10.2.0
    rg               : 14.1.0
    chafa            : 1.14.2
    zoxide           : 0.9.4
    7z               : 17.05
    7zz              : No such file or directory (os error 2)
    jq               : 1.7.1

--------------------------------------------------
When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time.
You can find it in the "/home/alberto/.local/state/yazi" directory.

Please describe the problem you're trying to solve

I would like to be able to send files with KDE connect.

Would you be willing to contribute this feature?

Describe the solution you'd like

I created this script and I think it would be very cool to integrate it with yazi by selecting the files there and with a shortcut selecting the device and sending them.

#!/bin/bash

fsend() {
    local confirmation=true  # Change to false if you don't want device confirmation

    if [ "$confirmation" = true ]; then
        # Show the list of available devices (ID and Name) and allow the user to select one
        local device_info
        device_info=$(kdeconnect-cli --list-available --id-name-only | fzf --prompt "Select Device: ")
        if [ -z "$device_info" ]; then
            echo "No device selected. Exiting."
            return 1
        fi

        # Extract the device ID from the selected result
        local device_id
        device_id=$(echo "$device_info" | awk '{print $1}')
    else
        # Use the first available device by default
        local device_id
        device_id=$(kdeconnect-cli --list-available --id-only | head -n 1)
    fi

    # Get the files selected by fzf
    local files_to_share
    files_to_share=$(fzf --multi)

    # Check if any files were selected
    if [ -n "$files_to_share" ]; then
        # Iterate over each file and send it
        while IFS= read -r file; do
            kdeconnect-cli -d "$device_id" --share "$PWD/$file"
        done <<< "$files_to_share"
    else
        echo "No files selected. Exiting."
    fi
}

# Execute the function
fsend

Additional context

No response

Validations

sxyazi commented 2 months ago

Hi, this is an already supported feature. You can run your shell script through the shell command:

{ on = "<C-s>", run = "shell 'bash /path/to/fsend' --block --confirm" }

Doc of shell command: https://yazi-rs.github.io/docs/configuration/keymap#manager.shell

Closing as already supported.

moshpirit commented 2 months ago

Hi again, my issue wasn't that much about making my script to work when running yazi, but about to officially support it (maybe with a plugin). I only shared the script just in case it somehow helps, the script is not intended to work in yazi as it is :sweat_smile:. In fact, it doesn't even work when running it in the shell mode (it runs in the background, but it is supposed to be interactive).

sxyazi commented 2 months ago

but about to officially support it (maybe with a plugin)

Are you referring to including it as a builtin plugin in Yazi? Or as a third-party plugin officially maintained by us?

it doesn't even work when running it in the shell mode (it runs in the background, but it is supposed to be interactive)

Have you added the --block option to run in block mode? Block mode behaves exactly like your actual shell—if something works in your shell, it will work in Yazi.

moshpirit commented 2 months ago

Are you referring to including it as a builtin plugin in Yazi? Or as a third-party plugin officially maintained by us?

I meant including a builtin plugin in Yazi. I think it is a great feature to add

Have you added the --block option to run in block mode? Block mode behaves exactly like your actual shell—if something works in your shell, it will work in Yazi.

Yes, I have. Both with and without the --block option

sxyazi commented 2 months ago

Sorry, I'm afraid I can't accept this because it would require adding kdeconnect-cli as a dependency for Yazi, and recommending all users to install it in the documentation/downstream packaging.

Also it's not available on Windows platform, which would introduce new cross-platform issues - all dependencies for Yazi should be cross-platform since Yazi itself is cross-platform.

moshpirit commented 2 months ago

Oh, I didn't think about this. You are absolutely right. Maybe then a third-party plugin officially maintained by you?

sxyazi commented 2 months ago

Added to https://github.com/yazi-rs/plugins/issues/9

To set expectations, I've never used kdeconnect-cli myself, so it might take some time to figure out how it works.

moshpirit commented 2 months ago

Thanks a lot!

github-actions[bot] commented 1 month ago

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.