diff --git a/desktopenvs/hyprlua/hypr/usr/binds.lua b/desktopenvs/hyprlua/hypr/usr/binds.lua index 09c38b5..4c68fa6 100644 --- a/desktopenvs/hyprlua/hypr/usr/binds.lua +++ b/desktopenvs/hyprlua/hypr/usr/binds.lua @@ -51,8 +51,12 @@ hl.bind(mainMod .. " + SHIFT + RETURN", hl.dsp.exec_cmd(winswitch)) hl.bind(mainMod .. " + SHIFT + R", hl.dsp.exec_cmd("wofi --show drun")) hl.bind("CTRL + SHIFT + R", hl.dsp.exec_cmd(menu)) -hl.bind(mainMod .. " + F", hl.dsp.exec_cmd("~/.config/scripts/wofi-file-search.sh")) -hl.bind(mainMod .. " + SHIFT + F", hl.dsp.exec_cmd("~/.config/scripts/foldersearch.sh")) +-- File picker dialog -> clipboard (path / contents) +hl.bind(mainMod .. " + F", hl.dsp.exec_cmd("~/.config/scripts/filepicker-clipboard.sh path")) +hl.bind(mainMod .. " + SHIFT + F", hl.dsp.exec_cmd("~/.config/scripts/filepicker-clipboard.sh content")) +-- old: +-- hl.bind(mainMod .. " + F", hl.dsp.exec_cmd("~/.config/scripts/wofi-file-search.sh")) +-- hl.bind(mainMod .. " + SHIFT + F", hl.dsp.exec_cmd("~/.config/scripts/foldersearch.sh")) hl.bind(mainMod .. " + ALT + F", hl.dsp.exec_cmd("wofi-calc")) hl.bind(mainMod .. " + S", hl.dsp.exec_cmd("[tag +mixer] pavucontrol")) diff --git a/desktopenvs/hyprlua/scripts/filepicker-clipboard.sh b/desktopenvs/hyprlua/scripts/filepicker-clipboard.sh new file mode 100755 index 0000000..35af8f7 --- /dev/null +++ b/desktopenvs/hyprlua/scripts/filepicker-clipboard.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# File picker dialog -> clipboard. +# path (default): copy the selected file's absolute path +# content : copy the selected file's contents +# Bound to Super+F (path) and Super+Shift+F (content) in usr/binds.lua. + +set -euo pipefail + +mode="${1:-path}" + +# zenity exits non-zero on cancel/close -> treat as a no-op. +file="$(zenity --file-selection --title="Copy file ${mode} to clipboard")" || exit 0 +[ -n "$file" ] || exit 0 + +case "$mode" in + content) + if [ ! -r "$file" ]; then + notify-send -u critical "File picker" "Cannot read: $file" + exit 1 + fi + wl-copy < "$file" + notify-send "Copied file contents" "$(basename "$file")" + ;; + path | *) + # Collapse the home dir to ~ + case "$file" in + "$HOME"/*) file="~${file#"$HOME"}" ;; + "$HOME") file="~" ;; + esac + printf '%s' "$file" | wl-copy + notify-send "Copied file path" "$file" + ;; +esac