summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-02-02 08:32:20 -0500
committerBenjamin Chausse <benjamin@chausse.xyz>2024-02-02 08:32:20 -0500
commit32779418b1ae68e5fb86832e6f40cf3eb19d0595 (patch)
treec0c3ff08dc6fd45f4adab19e42406b4414e53148
parent566a4da12f0831572a898e0a5adc31059c55c4b9 (diff)
Restore files excluded by dropbox with lf
-rwxr-xr-x.config/lf/lfrc5
-rwxr-xr-x.local/bin/dropbox-restore31
2 files changed, 34 insertions, 2 deletions
diff --git a/.config/lf/lfrc b/.config/lf/lfrc
index bca6fc2..bc2c0e0 100755
--- a/.config/lf/lfrc
+++ b/.config/lf/lfrc
@@ -78,7 +78,7 @@ cmd moveto ${{
for x in $fx; do
eval mv -iv \"$x\" \"$dest\"
done &&
- notify-send "🚚 File(s) moved." "File(s) moved to $dest."
+ notify-send "󰪹 File(s) moved." "File(s) moved to $dest."
}}
cmd copyto ${{
@@ -89,7 +89,7 @@ cmd copyto ${{
for x in $fx; do
eval cp -ivr \"$x\" \"$dest\"
done &&
- notify-send "📋 File(s) copied." "File(s) copies to $dest."
+ notify-send " File(s) copied." "File(s) copies to $dest."
}}
cmd setbg "$1"
@@ -143,6 +143,7 @@ map V push :!nvim<space>
map W $setsid -f $TERMINAL >/dev/null 2>&1
map Y $printf "%s" "$fx" | xclip -selection clipboard
map E $dropbox-cli exclude add "$f" && notify-send -a "ï…« Dropbox" "Excluded $f from computer"
+map R $dropbox-restore "$f"
map S $dropbox-cli sharelink "$f" | xsel -b && notify-send -a "ï…« Dropbox" "Link copied to clipboard."
# Source Bookmarks
diff --git a/.local/bin/dropbox-restore b/.local/bin/dropbox-restore
new file mode 100755
index 0000000..3c1fcc7
--- /dev/null
+++ b/.local/bin/dropbox-restore
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# Usage: dropbox-exclude <initial-path>
+# This script is meant to be run within a file manager such as lf or ranger.
+# When in a directory, you can view which files are not being synced by Dropbox
+# as a dmenu prompt. You can then select a file to start syncing that file again.
+# For readability, the script will only show files in the current directory.
+# If you want to see all excluded files in the Dropbox directory, you can use the
+# `dropbox-cli exclude list` command.
+
+# if $1 is a file, get the directory of the file
+# if $1 is a directory, use it as the directory
+# exit if something else
+if [ -d "$1" ]; then
+ cd "$1" || exit 1
+elif [ -f "$1" ]; then
+ cd "$(dirname "$1")" || exit 1
+else
+ exit 1
+fi
+
+excluded_files=$(dropbox-cli exclude list | awk '{print $1}' | sed 's/\/$//')
+
+if [ -z "$excluded_files" ]; then
+ notify-send -a "ï…« Dropbox" "No files are excluded in this directory."
+ exit 1
+fi
+
+echo "$excluded_files" | dmenu -w "$(xdotool getactivewindow)" -p "ï…« Select a file to restore:" | while read -r file; do
+ dropbox-cli exclude remove "$file"
+done