From b1566efd636f6c0f6bee37f8fcccc8966b04c9e5 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Tue, 11 Jul 2023 22:12:30 +0530 Subject: [PATCH] add script for ytfzf --- packages/scripts/default.nix | 8 ++++++-- packages/scripts/youtube.sh | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100755 packages/scripts/youtube.sh diff --git a/packages/scripts/default.nix b/packages/scripts/default.nix index 36c1231..4a82d4b 100644 --- a/packages/scripts/default.nix +++ b/packages/scripts/default.nix @@ -7,11 +7,11 @@ tmux, kitty, imagemagick, - sway, hyprland, swww, jq, curl, + ytfzf, }: stdenvNoCC.mkDerivation { pname = "scripts"; @@ -25,7 +25,7 @@ stdenvNoCC.mkDerivation { mkdir -p $out/bin cp power-menu.sh $out/bin/power-menu chmod +x $out/bin/power-menu - wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [libnotify rofi-wayland sway hyprland]} + wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [libnotify rofi-wayland hyprland]} cp tmux-sessions.sh $out/bin/tmux-sessions chmod +x $out/bin/tmux-sessions @@ -38,5 +38,9 @@ stdenvNoCC.mkDerivation { cp wallhaven.sh $out/bin/wallhaven chmod +x $out/bin/wallhaven wrapProgram $out/bin/wallhaven --prefix PATH : ${lib.makeBinPath [imagemagick libnotify jq curl]} + + cp youtube.sh $out/bin/youtube + chmod +x $out/bin/youtube + wrapProgram $out/bin/youtube --prefix PATH : ${lib.makeBinPath [kitty ytfzf rofi-wayland]} ''; } diff --git a/packages/scripts/youtube.sh b/packages/scripts/youtube.sh new file mode 100755 index 0000000..af828f7 --- /dev/null +++ b/packages/scripts/youtube.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -eu +XDG_CACHE_HOME=${XDG_CACHE_HOME:-} +if [ -n "$XDG_CACHE_HOME" ] ; then + HISTORY_FILE="$XDG_CACHE_HOME/youtube_history" +else + HISTORY_FILE="$HOME/.cache/youtube_history" +fi +if [ ! -e "$HISTORY_FILE" ] ; then + touch "$HISTORY_FILE" +fi +SEARCH_TERM="$(rofi -dmenu -p "Search Youtube:" < "$HISTORY_FILE")" +echo "$SEARCH_TERM" >> $HISTORY_FILE +kitty --class=ytfzf --title "YouTube Search: ${SEARCH_TERM}" -- ytfzf -f -tT kitty --async-thumbnails "${SEARCH_TERM}" +