configuration.nix/extra-packages/scripts/youtube/youtube.sh

17 lines
541 B
Bash
Raw Normal View History

2023-07-11 22:12:30 +05:30
#!/bin/sh
set -eu
XDG_CACHE_HOME=${XDG_CACHE_HOME:-}
if [ -n "$XDG_CACHE_HOME" ] ; then
HISTORY_FILE="$XDG_CACHE_HOME/ytfzf/search_hist"
2023-07-11 22:12:30 +05:30
else
HISTORY_FILE="$HOME/.cache/ytfzf/search_hist"
2023-07-11 22:12:30 +05:30
fi
if [ ! -e "$HISTORY_FILE" ] ; then
touch "$HISTORY_FILE"
fi
2024-05-11 21:06:32 +05:30
HISTORY="$(awk -F' ' '{$1="";$2="";$3="";print $0}' "$HISTORY_FILE" | sed 's/^\s*//g' | uniq)"
SEARCH_TERM="$(echo "$HISTORY" | rofi -dmenu -p "Search Youtube:")"
2023-07-11 22:12:30 +05:30
kitty --class=ytfzf --title "YouTube Search: ${SEARCH_TERM}" -- ytfzf -f -tT kitty --async-thumbnails "${SEARCH_TERM}"