updated fuz script

Very messy
This commit is contained in:
mintycube 2024-05-21 13:59:16 +05:00
parent 9ab330bc43
commit 2b8cee2e35
2 changed files with 61 additions and 136 deletions

View File

@ -257,9 +257,8 @@ static const char* volume_ui_cmd[] = { "st", "-c", "volume-ui", "-g=80x15+353+20
static const Key on_empty_keys[] = { static const Key on_empty_keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{0, XK_e, spawn, SHCMD("st fuz -lf") }, {0, XK_e, spawn, SHCMD("st fuz") },
{0, XK_f, spawn, SHCMD("st fuz") }, {0, XK_f, spawn, SHCMD("st fuz") },
{0, XK_t, spawn, SHCMD("st fuz-test") },
{0, XK_w, spawn, {.v = (const char*[]){"firefox", NULL } } }, {0, XK_w, spawn, {.v = (const char*[]){"firefox", NULL } } },
{0, XK_grave, spawn, {.v = (const char*[]){"dmenunerdsymbols", NULL } } }, {0, XK_grave, spawn, {.v = (const char*[]){"dmenunerdsymbols", NULL } } },
{0, XK_BackSpace, spawn, {.v = (const char*[]){"sysact", NULL } } }, {0, XK_BackSpace, spawn, {.v = (const char*[]){"sysact", NULL } } },
@ -309,7 +308,7 @@ static const Key keys[] = {
{ MODKEY, XK_q, killclient, {0} }, { MODKEY, XK_q, killclient, {0} },
{ MODKEY|ShiftMask, XK_q, killunsel, {0} }, { MODKEY|ShiftMask, XK_q, killunsel, {0} },
{ MODKEY, XK_w, spawn, {.v = (const char*[]){ "firefox", NULL } } }, { MODKEY, XK_w, spawn, {.v = (const char*[]){ "firefox", NULL } } },
{ MODKEY, XK_e, spawn, SHCMD("st fuz -lf") }, { MODKEY, XK_e, spawn, SHCMD("st fuz") },
{ ALTKEY, XK_e, spawn, {.v = (const char*[]){ "networkmanager_dmenu", NULL } } }, { ALTKEY, XK_e, spawn, {.v = (const char*[]){ "networkmanager_dmenu", NULL } } },
{ MODKEY, XK_r, spawn, {.v = (const char*[]){ "st", "-e", "lf", NULL } } }, { MODKEY, XK_r, spawn, {.v = (const char*[]){ "st", "-e", "lf", NULL } } },
{ MODKEY|ShiftMask, XK_r, spawn, {.v = (const char*[]){ "thunar", NULL } } }, { MODKEY|ShiftMask, XK_r, spawn, {.v = (const char*[]){ "thunar", NULL } } },
@ -321,8 +320,7 @@ static const Key keys[] = {
{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } }, { MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } },
{ MODKEY, XK_a, spawn, {.v = (const char*[]){ "dmenu_hub", NULL } } }, { MODKEY, XK_a, spawn, {.v = (const char*[]){ "dmenu_hub", NULL } } },
{ MODKEY, XK_d, spawn, {.v = dmenu_run_cmd } }, { MODKEY, XK_d, spawn, {.v = dmenu_run_cmd } },
{ MODKEY, XK_f, spawn, SHCMD("st fuz") }, { MODKEY, XK_f, togglefakefullscreen, {0} },
{ ALTKEY, XK_f, togglefakefullscreen, {0} },
{ MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } },

View File

@ -1,102 +1,36 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Dependencies
DIRCOLORS_CMD="/usr/bin/dircolors"
DIRNAME_CMD="/usr/bin/dirname"
DISPLAY_CMD="/usr/bin/display"
FD_CMD="/usr/bin/fd"
FILE_CMD="/usr/bin/file"
FZFP_CMD="/usr/bin/fzfp" # comes from AUR (stpv-git)
GIMP_CMD="/usr/bin/gimp"
LF_CMD="/usr/bin/lf"
LIBREOFFICE_CMD="/usr/bin/zaread"
MPV_CMD="/usr/bin/mpv"
NSXIV_CMD="/usr/bin/nsxiv"
NVIM_CMD="/usr/bin/nvim"
READLINK_CMD="/usr/bin/readlink"
ZATHURA_CMD="/usr/bin/zathura"
# ZSH_CMD="/usr/bin/zsh"
echo -ne '\e[3 q' # Use underline shape cursor on startup. echo -ne '\e[3 q' # Use underline shape cursor on startup.
eval "$($DIRCOLORS_CMD --sh)" # Setup correct colors eval "$(dircolors --sh)" # Setup correct colors
dwmc setlayoutex 2
FD_COMMAND=( selection=$(fd --hidden --color=always -E .cache -E .git -E \*github\* -E .local/state -E .ssh -E .android -E GIMP -E Thunar -E .config/blender -E .config/mpv/script_modules -E .config/mpv/scripts -E .config/tmux/plugins -E fontforge -E fzf-tab-completion -E .gnupg -E libreoffice -E node_modules -E \*obsidian -E qBittorrent -E subversion -E \*terminfo |
"$FD_CMD" "--hidden" "--color=always" fzfp --ansi --prompt " All  " \
"-E" "*.cache" --bind "alt-1:transform:[[ ! \$FZF_PROMPT =~ All ]] &&
"-E" "*.git" echo 'change-prompt( All  )+reload(fd --hidden --color=always -E .cache -E .git -E \*github\* -E .local/state -E .ssh -E .android -E GIMP -E Thunar -E .config/blender -E .config/mpv/script_modules -E .config/mpv/scripts -E .config/tmux/plugins -E fontforge -E fzf-tab-completion -E .gnupg -E libreoffice -E node_modules -E \*obsidian -E qBittorrent -E subversion -E \*terminfo)' ||
"-E" "*.github" echo 'change-prompt( Folders  )+reload(fd --color=always --hidden --type directory -E .cache -E .git -E \*github\* -E .local/state -E .ssh -E .android -E GIMP -E Thunar -E .config/blender -E .config/mpv/script_modules -E .config/mpv/scripts -E .config/tmux/plugins -E fontforge -E fzf-tab-completion -E .gnupg -E libreoffice -E node_modules -E \*obsidian -E qBittorrent -E subversion -E \*terminfo)'" \
"-E" "*.local/state" --bind "alt-2:change-prompt( Git  )+reload( fd --color=always -HI '^.git$' --type d --base-directory ~ -E .cache -E \*github\* -E .local/state -E .ssh -E .android -E GIMP -E Thunar -E .config/blender -E .config/mpv/script_modules -E .config/mpv/scripts -E .config/tmux/plugins -E fontforge -E fzf-tab-completion -E .gnupg -E libreoffice -E node_modules -E \*obsidian -E qBittorrent -E subversion -E \*terminfo | sed 's|\\[1\;34m\.git\\[0m\\[1\;34m\/\\[0m||')" \
"-E" "*.ssh" --bind "alt-3:change-prompt( Documents  )+reload(fd --color=always --hidden -e pdf -e epub -e djvu -E .cache -E .git -E \*github\* -E .local/state -E .ssh -E .android -E GIMP -E Thunar -E .config/blender -E .config/mpv/script_modules -E .config/mpv/scripts -E .config/tmux/plugins -E fontforge -E fzf-tab-completion -E .gnupg -E libreoffice -E node_modules -E \*obsidian -E qBittorrent -E subversion -E \*terminfo)" \
"-E" "*.android" --bind "alt-4:change-prompt( Images  )+reload(fd --color=always --hidden -e jpg -e jpg -e jpeg -e png -e webp -e bmp -e tiff -e tif -e raw -e ico -e exif -e heic -e heif -e gif -e avif -e jxl -e JPG -e PNG -E .cache -E .git -E \*github\* -E .local/state -E .ssh -E .android -E GIMP -E Thunar -E .config/blender -E .config/mpv/script_modules -E .config/mpv/scripts -E .config/tmux/plugins -E fontforge -E fzf-tab-completion -E .gnupg -E libreoffice -E node_modules -E \*obsidian -E qBittorrent -E subversion -E \*terminfo)" \
"-E" "*GIMP" --bind "alt-5:change-prompt( Videos  )+reload(fd --color=always --hidden -e mkv -e mp4 -e mkv -e webm -e avi -E .cache -E .git -E \*github\* -E .local/state -E .ssh -E .android -E GIMP -E Thunar -E .config/blender -E .config/mpv/script_modules -E .config/mpv/scripts -E .config/tmux/plugins -E fontforge -E fzf-tab-completion -E .gnupg -E libreoffice -E node_modules -E \*obsidian -E qBittorrent -E subversion -E \*terminfo)" \
"-E" "*Thunar" --header " Prefix:Alt :: 1:All/Folders :: 2:Git :: 3:Documents :: 4:Images :: 5:Videos" \
"-E" "*config/blender" --color="fg:#c0caf5,bg:#1a1b26,hl:#ff9e64" \
"-E" "*config/mpv/script_modules" --color="fg+:#c0caf5,bg+:#292e42,hl+:#ff9e64" \
"-E" "*config/mpv/scripts" --color="info:#7aa2f7,prompt:#7dcfff,pointer:#7dcfff" \
"-E" "*config/tmux/plugins" --color="marker:#9ece6a,spinner:#9ece6a,header:#9ece6a" \
"-E" "*fontforge" --height=100% --pointer=" " --ellipsis= --no-info --header-first --scheme=path --algo=v2 \
"-E" "*fzf-tab-completion" --preview-window "border-vertical" --border=horizontal)
"-E" "*gnupg"
"-E" "*libreoffice"
"-E" "*node_modules"
"-E" "*obsidian"
"-E" "*qBittorrent"
"-E" "*subversion"
"-E" "*terminfo"
)
FZF_COMMAND=( [ -n "$selection" ] &&
"$FZFP_CMD" case $(file --mime-type "$(readlink -f "$selection")" -b) in
"--scheme=path" "--algo=v2" image/vnd.djvu | application/pdf | application/postscript | application/epub*) zathura "$selection" >/dev/null 2>&1 ;;
"--height=100%" "--prompt=  " "--pointer= " "--ellipsis=" text/html) nvim "$selection" ;;
"--border=horizontal" "--margin=5%,10%,5%,10%" "--scrollbar=▐" "--preview-window=border-vertical" text/* | application/json | inode/x-empty | application/x-subrip | application/javascript) nvim "$selection" ;;
"--color=fg:#c0caf5,bg:#1a1b26,hl:#ff9e64" image/x-xcf) gimp "$selection" >/dev/null 2>&1 ;;
"--color=fg+:#c0caf5,bg+:#292e42,hl+:#ff9e64" image/svg+xml) display -- "$selection" ;;
"--color=info:#7aa2f7,prompt:#7dcfff,pointer:#7dcfff"
"--color=marker:#9ece6a,spinner:#9ece6a,header:#9ece6a"
"--keep-right" "--info=hidden" "--scroll-off=10" "--ansi" "--tabstop=2" "--reverse"
)
case "$1" in
"-doc")
# FZF_COMMAND+=("--query=pdf$ | epub$ | djvu$ ")
FD_COMMAND+=("-e" "pdf" "-e" "epub" "-e" "djvu")
selection="$("${FD_COMMAND[@]}" | "${FZF_COMMAND[@]}")"
# export selection
[ -n "$selection" ] && $ZATHURA_CMD "$selection"
;;
"-lf")
selection="$("${FD_COMMAND[@]}" | "${FZF_COMMAND[@]}")"
# export selection
[ -n "$selection" ] && $LF_CMD -command "set hidden" "$selection"
;;
"-video")
# FZF_COMMAND+=("--query=mp4$ | mkv$ | webm$ | avi$ ")
FD_COMMAND+=("-e" "mp4" "-e" "mkv" "-e" "webm" "-e" "avi")
selection="$("${FD_COMMAND[@]}" | "${FZF_COMMAND[@]}")"
# export selection
[ -n "$selection" ] && "$MPV_CMD" --loop-file "$selection" -quiet
;;
"-image")
# FZF_COMMAND+=("--query=jpg$ | jpeg$ | png$ | webp$ | bmp$ | tiff$ | tif$ | raw$ | ico$ | exif$ | heic$ | heif$ | gif$ | avif$ | jxl$ | JPG$ | PNG$ ")
FD_COMMAND+=("jpg" "-e" "jpeg" "-e" "png" "-e" "webp" "-e" "bmp" "-e" "tiff" "-e" "tif" "-e" "raw" "-e" "ico" "-e" "exif" "-e" "heic" "-e" "heif" "-e" "gif" "-e" "avif" "-e" "jxl" "-e" "JPG" "-e" "PNG")
selection="$("${FD_COMMAND[@]}" | "${FZF_COMMAND[@]}")"
# export selection
[ -n "$selection" ] && "$MPV_CMD" --loop-file "$selection" -quiet
;;
*)
selection="$("${FD_COMMAND[@]}" | "${FZF_COMMAND[@]}")"
# export selection
[ -n "$selection" ] &&
case $($FILE_CMD --mime-type "$($READLINK_CMD -f "$selection")" -b) in
image/vnd.djvu | application/pdf | application/postscript | application/epub*) "$ZATHURA_CMD" "$selection" >/dev/null 2>&1 ;;
text/html) "$NVIM_CMD" "$selection" ;;
text/* | application/json | inode/x-empty | application/x-subrip | application/javascript) "$NVIM_CMD" "$selection" ;;
image/x-xcf) "$GIMP_CMD" "$selection" >/dev/null 2>&1 ;;
image/svg+xml) $DISPLAY_CMD -- "$selection" ;;
image/*) image/*)
shopt -s nullglob shopt -s nullglob
dir="$($DIRNAME_CMD "$selection")" dir="$(dirname "$selection")"
selected_file="$selection" selected_file="$selection"
images=() images=()
for file in "$dir"/*.{jpg,jpeg,png,webp,bmp,tiff,tif,raw,ico,exif,heic,heif,gif,avif,jxl,JPG,PNG}; do for file in "$dir"/*.{jpg,jpeg,png,webp,bmp,tiff,tif,raw,ico,exif,heic,heif,gif,avif,jxl,JPG,PNG}; do
@ -108,30 +42,23 @@ case "$1" in
done < <(printf "%s\n" "${images[@]}" | sort -fV) done < <(printf "%s\n" "${images[@]}" | sort -fV)
for ((i = 0; i < ${#sorted_images[@]}; i++)); do for ((i = 0; i < ${#sorted_images[@]}; i++)); do
[[ "${sorted_images[i]}" = "$selected_file" ]] && { [[ "${sorted_images[i]}" = "$selected_file" ]] && {
setsid $NSXIV_CMD -aon "$((i + 1))" "${sorted_images[@]}" setsid nsxiv -aon "$((i + 1))" "${sorted_images[@]}"
break break
} }
done done
;; ;;
audio/* | video/x-ms-asf) "$MPV_CMD" --loop-file --profile=builtin-pseudo-gui "$selection" ;; audio/* | video/x-ms-asf) mpv --loop-file --profile=builtin-pseudo-gui "$selection" ;;
video/*) "$MPV_CMD" --loop-file "$selection" -quiet >/dev/null 2>&1 ;; video/*) mpv --loop-file "$selection" -quiet >/dev/null 2>&1 ;;
application/pgp-encrypted) "$NVIM_CMD" "$selection" ;; application/pgp-encrypted) nvim "$selection" ;;
application/vnd.openxmlformats-officedocument.wordprocessingml.document | application/vnd.oasis.opendocument.text | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | application/vnd.oasis.opendocument.spreadsheet | application/vnd.oasis.opendocument.spreadsheet-template | application/vnd.openxmlformats-officedocument.presentationml.presentation | application/vnd.oasis.opendocument.presentation-template | application/vnd.oasis.opendocument.presentation | application/vnd.ms-powerpoint | application/vnd.oasis.opendocument.graphics | application/vnd.oasis.opendocument.graphics-template | application/vnd.oasis.opendocument.formula | application/vnd.oasis.opendocument.database) "$LIBREOFFICE_CMD" "$selection" >/dev/null 2>&1 ;; application/vnd.openxmlformats-officedocument.wordprocessingml.document | application/vnd.oasis.opendocument.text | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | application/vnd.oasis.opendocument.spreadsheet | application/vnd.oasis.opendocument.spreadsheet-template | application/vnd.openxmlformats-officedocument.presentationml.presentation | application/vnd.oasis.opendocument.presentation-template | application/vnd.oasis.opendocument.presentation | application/vnd.ms-powerpoint | application/vnd.oasis.opendocument.graphics | application/vnd.oasis.opendocument.graphics-template | application/vnd.oasis.opendocument.formula | application/vnd.oasis.opendocument.database) libreoffice "$selection" >/dev/null 2>&1 ;;
application/octet-stream) case ${selection##*.} in application/octet-stream)
doc | docx | xls | xlsx | odt | ppt | pptx) "$LIBREOFFICE_CMD" "$selection" >/dev/null 2>&1 ;; case ${selection##*.} in
ts) "$MPV_CMD" "$selection" -quiet >/dev/null 2>&1 ;; doc | docx | xls | xlsx | odt | ppt | pptx) libreoffice "$selection" >/dev/null 2>&1 ;;
*) "$ZATHURA_CMD" "$selection" >/dev/null 2>&1 ;; ts) mpv "$selection" -quiet >/dev/null 2>&1 ;;
esac ;; *) zathura "$selection" >/dev/null 2>&1 ;;
*) $LF_CMD -command "set hidden" "$selection" ;;
esac esac
;; ;;
esac *) lf -command "set hidden" "$selection" ;;
esac
dwmc setlayoutex 0
# if [ -d "$selection" ]; then
# cd "$selection" && exec $ZSH_CMD
# elif [ -f "$selection" ]; then
# cd "$($DIRNAME_CMD "$selection")" && exec $ZSH_CMD
# else
# exec $ZSH_CMD
# fi