summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hypr/.config/hypr/hyprland.conf3
-rwxr-xr-xscripts/Scripts/clipboard-primary45
2 files changed, 48 insertions, 0 deletions
diff --git a/hypr/.config/hypr/hyprland.conf b/hypr/.config/hypr/hyprland.conf
index c66be30..400404c 100644
--- a/hypr/.config/hypr/hyprland.conf
+++ b/hypr/.config/hypr/hyprland.conf
@@ -37,6 +37,8 @@ exec-once = hyprpaper
exec-once = dunst
exec-once = wl-paste --type text --watch cliphist store
exec-once = wl-paste --type image --watch cliphist store
+exec-once = wl-paste --primary --type text --watch cliphist -db-path ~/.cache/cliphist/primary.db store
+exec-once = wl-paste --primary --type image --watch cliphist -db-path ~/.cache/cliphist/primary.db store
# ╔════════════════════════════════════════╗
# ║ 🌿 ENVIRONMENT VARIABLES ║
@@ -190,6 +192,7 @@ bind = SUPER, E, exec, emacs
# 📜 Scripts
bind = SUPER, V, exec, ~/Scripts/clipboard
+bind = SUPER SHIFT, V, exec, ~/Scripts/clipboard-primary
bind = SUPER, R, exec, ~/Scripts/run
bind = SUPER, S, exec, ~/Scripts/screenshot
bind = SUPER SHIFT, S, exec, ~/Scripts/screenshot snip
diff --git a/scripts/Scripts/clipboard-primary b/scripts/Scripts/clipboard-primary
new file mode 100755
index 0000000..4d65f81
--- /dev/null
+++ b/scripts/Scripts/clipboard-primary
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+
+tmp_dir="/tmp/cliphist-rofi-primary"
+db_path="$HOME/.cache/cliphist/primary.db"
+
+clipboard_mode() {
+ if [ "$ROFI_RETV" = "0" ]; then
+ rm -rf "$tmp_dir"
+ mkdir -p "$tmp_dir"
+
+ cliphist -db-path "$db_path" list | while IFS=$'\t' read -r id content; do
+ if [[ "$content" == *"[[ binary data"* ]]; then
+ ext="png"
+
+ if [[ "$content" =~ image/(jpeg|jpg|png|bmp|gif|webp) ]]; then
+ ext="${BASH_REMATCH[1]}"
+ fi
+
+ if [[ "$ext" == "jpeg" ]]; then
+ ext="jpg"
+ fi
+
+ imgfile="$tmp_dir/$id.$ext"
+ printf '%s' "$id" | cliphist -db-path "$db_path" decode > "$imgfile"
+ printf '󰋩 IMAGE: %s\0icon\x1fthumbnail://%s\0info\x1f%s\n' "$id" "$imgfile" "$id"
+ else
+ printf '%s\0info\x1f%s\n' "$content" "$id"
+ fi
+ done
+ else
+ printf '%s' "$ROFI_INFO" | cliphist -db-path "$db_path" decode | wl-copy --primary
+ exit 0
+ fi
+}
+
+export -f clipboard_mode
+
+if [ -z "$ROFI_RETV" ]; then
+ rofi -modi "clipboard:$0" \
+ -show clipboard \
+ -show-icons \
+ -theme ~/.config/rofi/clipboard.rasi
+else
+ clipboard_mode "$@"
+fi