A very handy thing to have in your file manager is an option to send files directly to your phone.
If you happen to use KDE Connect and Dolphin, this is already there out of the box. Just right click a file and will see an option to send it to your devices.
But what if you use other file manager? You could replicate that functionality, and this post aims to help you on that.
The general idea is to:
- Craft the right command to send the file.
- Instruct the file manager to have it as a context menu item.
So let’s do it.
Step 1 - Install and configure KDE Connect
First of all, if you haven’t already, you need to install KDE Connect (both on your computer and your phone) and do the pairing.
Step 2 - Craft the command
KDE Connect has a CLI,
kdeconnect-cli. Running it with
-l provides a list of paired devices:
$ kdeconnect-cli -l
To send them a file, you can run:
$ kdeconnect-cli -d DEVICE_ID --share FILE_PATH
kdeconnect-cli -n DEVICE_NAME --share FILE_PATH
Take a look at the output of the first command and replace
FILE_PATH should be replaced by the full path of the file.
Step 3 - Setting the command on the file manager
Now you are able to send files to your phone by typing a command. The next step is to configure your file manager to offer that same command when you select a file.
The precise way to do that depends on which file manager you are using. I’ll briefly explain it for Thunar and Nemo.
On Thunar, add a custom action.
Click on Edit - Configure custom actions. After clicking the
+ icon, paste the command you got from Step 2, replacing the file path by
%f. You’ll have something like this:
kdeconnect-cli -d DEVICE_ID --share %f
In the tab “Appearance conditions” be sure to check all file types except “Directories”, as
kdeconnect-cli can’t handle them.
On Nemo, you can create a Nemo action. These are files very similar to desktop entries and are placed at
A sample file describing the options available is here .
Place the command from Step 2 in the
Exec= line. Replace the file path for
Also, you should use
kdeconnect-cli can’t handle directories or multiple files.
If everything went well, you can now send a file to your phone just by right clicking it and selecting the option. Cool, uh?
However, there is room for improvement. As I said, this setup doesn’t allow you to send more than one file per time. That’s a limitation from
To solve this, you can write a small wrapper script around
kdeconnect-cli, to receive all the file paths as arguments and iterate through them. You then make the file manager call it, instead of calling
Besides that, you need to configure the file manager so send the paths for all files selected. On Thunar, you do this by replacing
%F in the command. On Nemo, you set
Selection=m to allow multiple selection and
Quotes=double so the script receives a path per argument.
Additionally, you may want a notification if the action was successful.
A wrapper script can also achieve that. Check the return value from
kdeconnect-cli and call
notify-send with a friendly message.
It may be useful for you to take a look at my setup.