Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send with KDE connect #1625

Closed
2 of 3 tasks
moshpirit opened this issue Sep 9, 2024 · 8 comments
Closed
2 of 3 tasks

Send with KDE connect #1625

moshpirit opened this issue Sep 9, 2024 · 8 comments
Labels
invalid This doesn't seem right

Comments

@moshpirit
Copy link

moshpirit commented Sep 9, 2024

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?

  • Yes, I'll give it a shot

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

  • I have searched the existing issues
  • The latest nightly build of Yazi doesn't already have this feature
@moshpirit moshpirit added the feature New feature request label Sep 9, 2024
@sxyazi
Copy link
Owner

sxyazi commented Sep 10, 2024

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.

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2024
@sxyazi sxyazi added invalid This doesn't seem right and removed feature New feature request labels Sep 10, 2024
@moshpirit
Copy link
Author

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 😅. 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
Copy link
Owner

sxyazi commented Sep 10, 2024

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
Copy link
Author

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
Copy link
Owner

sxyazi commented Sep 11, 2024

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
Copy link
Author

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

@sxyazi sxyazi mentioned this issue Sep 12, 2024
4 tasks
@sxyazi
Copy link
Owner

sxyazi commented Sep 12, 2024

Added to yazi-rs/plugins#9

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

@moshpirit
Copy link
Author

Thanks a lot!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants