diff options
author | Vikas Kushwaha <dev@vikas.rocks> | 2024-11-21 13:30:52 +0530 |
---|---|---|
committer | Vikas Kushwaha <dev@vikas.rocks> | 2024-11-21 13:30:52 +0530 |
commit | 5c916d69d457101326803eb076a746060e3618cf (patch) | |
tree | d6fce3256eede1c1bf78fb6a1be75b9cc4b84cee /.local/bin/desktop/dmenu-syncthing-devices |
Moved from github
Diffstat (limited to '.local/bin/desktop/dmenu-syncthing-devices')
-rwxr-xr-x | .local/bin/desktop/dmenu-syncthing-devices | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/.local/bin/desktop/dmenu-syncthing-devices b/.local/bin/desktop/dmenu-syncthing-devices new file mode 100755 index 0000000..bb93f6d --- /dev/null +++ b/.local/bin/desktop/dmenu-syncthing-devices @@ -0,0 +1,25 @@ +#!/bin/sh + +pidof -q syncthing || { + echo "ERROR: Syncthing is not running" >&2 + exit 2 +} + +get_devices() { + for device_id in $(syncthing cli config devices list); do + printf '%-10s %s\n' \ + "$(syncthing cli config devices "$device_id" name get)" \ + "$device_id" + done | nl -w1 -s'. ' +} + +device="$(get_devices | dmenu -l 10 -p "Syncthing devices")" +device_id="${device##* }" +[ -z "$device_id" ] && exit 1 + +if [ -n "$1" ]; then + xdotool type "$device_id" +else + printf '%s\n' "$device_id" | xclip -selection clipboard + notify-send "📋 Copied to clipboard" "$device_id" +fi |