Skip to content

Instantly share code, notes, and snippets.

@rc2dev
Last active December 20, 2022 18:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rc2dev/678adc40cd75f9ea472cd3f77b63d21c to your computer and use it in GitHub Desktop.
Save rc2dev/678adc40cd75f9ea472cd3f77b63d21c to your computer and use it in GitHub Desktop.
Send files to your phone from file manager (https://rafaelc.org/posts/send-files-to-your-phone-from-file-manager/). Previously tracked on my dotfiles repository.
#!/bin/bash
#
# Send files to phone.
# It's a wrapper around KDE Connect CLI to provide
# a bit more functionality.
#
# Copyright (C) 2019-2021 Rafael Cavalcanti <https://rafaelc.org/dev>
# Licensed under GPLv3
readonly script_name="$(basename "$0")"
if (( $# == 0 )); then
printf "Usage: %s file [file...]\n" "$script_name"
exit 1
fi
readonly phone_id="$(kdeconnect-cli -l --id-only | head -1)"
while (( $# > 0 )); do
file="$1"
base="$(basename -- "$file")"
if kdeconnect-cli --device "$phone_id" --share "$file"; then
notify-send --urgency=normal "$script_name" "File sent: $base"
else
notify-send --urgency=critical "$script_name" "Failed to send file: $base"
fi
shift
done
[Nemo Action]
Name=Send to Phone
Comment=Send file to phone via KDE Connect
Exec=send2phone %F
Dependencies=send2phone;
Icon-Name=phone
Selection=notnone
Extensions=nodirs
Quote=double
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment