Skip to content

Instantly share code, notes, and snippets.

@harababurel
Last active June 17, 2024 13:37
Show Gist options
  • Save harababurel/f7a7354c4be88fae9d9e620f11e85591 to your computer and use it in GitHub Desktop.
Save harababurel/f7a7354c4be88fae9d9e620f11e85591 to your computer and use it in GitHub Desktop.
Small script for sending notifications to phone using kde-connect.
#!/bin/bash
command -v kdeconnect-cli >/dev/null 2>&1 || { echo >&2 "kdeconnect is not installed. Aborting."; exit 1; }
if [ $# -eq 0 ]; then
echo "Usage: $0 <message>"
exit 1
fi
device=`kdeconnect-cli -a --id-only 2>/dev/null | head`
if [ "$device" = "" ]; then
echo "No paired devices. Will try to search and pair automatically."
feedback=`kdeconnect-cli -l | tail -n 1`
echo "$feedback."
device=`kdeconnect-cli -l --id-only 2>/dev/null | head`
if [ "$device" = "" ]; then
echo "Stopping."
exit 1
fi
echo "Trying to pair to $device. Please accept on device."
kdeconnect-cli -d $device --pair
fi
kdeconnect-cli -d $device --ping-msg "$*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment