From 2d2b19b2dbcace91919d6c87838d73d85ffeb051 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Mon, 20 Apr 2026 13:19:37 -0700 Subject: [PATCH] syncthing.sh: add ignored folder display and un-ignore option to pending folders menu --- syncthing.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/syncthing.sh b/syncthing.sh index 09a5b45..12064dc 100755 --- a/syncthing.sh +++ b/syncthing.sh @@ -84,6 +84,59 @@ for device_id, info in devices.items(): fi } +show_ignored_folders() { + local config + config=$(st_get /rest/config) + local ignored + ignored=$(echo "$config" | python3 -c ' +import sys,json +d=json.load(sys.stdin) +folders = d.get("ignoredFolders", []) +for f in folders: + print(f.get("id","?") + " — " + f.get("label","(no label)")) +' 2>/dev/null || true) + if [ -z "$ignored" ]; then + info "No ignored folders." + return + fi + echo "" + warn "Ignored folders (click Ignore in WUI causes this):" + echo "$ignored" | sed 's/^/ /' + echo "" + read -rp "Un-ignore a folder? [y/N]: " UNIGNORE + UNIGNORE="${UNIGNORE:-n}" + if [[ "${UNIGNORE,,}" != "y" ]]; then return; fi + + local folder_ids + folder_ids=$(echo "$config" | python3 -c ' +import sys,json +d=json.load(sys.stdin) +for f in d.get("ignoredFolders",[]): + print(f.get("id","")) +' 2>/dev/null || true) + + echo "Ignored folder IDs:" + local i=1 + while IFS= read -r fid; do + echo " $i) $fid" + i=$((i+1)) + done <<< "$folder_ids" + read -rp "Choose folder number to un-ignore: " CHOICE + local TARGET_ID + TARGET_ID=$(echo "$folder_ids" | sed -n "${CHOICE}p") + [ -n "$TARGET_ID" ] || { warn "Invalid choice."; return; } + + local new_config + new_config=$(echo "$config" | python3 -c " +import sys,json +d=json.load(sys.stdin) +d['ignoredFolders'] = [f for f in d.get('ignoredFolders',[]) if f.get('id') != sys.argv[1]] +print(json.dumps(d)) +" "$TARGET_ID") + st_put /rest/config "$new_config" + info "Folder $TARGET_ID removed from ignored list. It should now appear as pending." +} + show_pending_folders() { header "Pending Folders" local pending @@ -92,6 +145,11 @@ show_pending_folders() { count=$(echo "$pending" | python3 -c 'import sys,json; d=json.load(sys.stdin); print(len(d))') if [ "$count" -eq 0 ]; then warn "No pending folders." + echo "" + read -rp "Check ignored folders? [y/N]: " CHECK_IGNORED + if [[ "${CHECK_IGNORED,,}" == "y" ]]; then + show_ignored_folders + fi return fi echo "$pending" | python3 -c ' @@ -103,8 +161,12 @@ for fid,info in d.items(): print(f" Offered by: {offered_by}") print("") ' - read -rp "Accept a pending folder? [y/N]: " ACCEPT + read -rp "Accept a pending folder? [y/N/R (retry/check ignored)]: " ACCEPT ACCEPT="${ACCEPT:-n}" + if [[ "${ACCEPT,,}" == "r" ]]; then + show_ignored_folders + return + fi if [[ "${ACCEPT,,}" != "y" ]]; then return; fi local folder_ids