add script for ytfzf

This commit is contained in:
Adithya 2023-07-11 22:12:30 +05:30
parent 20ca30ba46
commit b1566efd63
Signed by: adtya
GPG key ID: 48FC9915FFD326D0
2 changed files with 22 additions and 2 deletions

View file

@ -7,11 +7,11 @@
tmux, tmux,
kitty, kitty,
imagemagick, imagemagick,
sway,
hyprland, hyprland,
swww, swww,
jq, jq,
curl, curl,
ytfzf,
}: }:
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {
pname = "scripts"; pname = "scripts";
@ -25,7 +25,7 @@ stdenvNoCC.mkDerivation {
mkdir -p $out/bin mkdir -p $out/bin
cp power-menu.sh $out/bin/power-menu cp power-menu.sh $out/bin/power-menu
chmod +x $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 cp tmux-sessions.sh $out/bin/tmux-sessions
chmod +x $out/bin/tmux-sessions chmod +x $out/bin/tmux-sessions
@ -38,5 +38,9 @@ stdenvNoCC.mkDerivation {
cp wallhaven.sh $out/bin/wallhaven cp wallhaven.sh $out/bin/wallhaven
chmod +x $out/bin/wallhaven chmod +x $out/bin/wallhaven
wrapProgram $out/bin/wallhaven --prefix PATH : ${lib.makeBinPath [imagemagick libnotify jq curl]} 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]}
''; '';
} }

16
packages/scripts/youtube.sh Executable file
View file

@ -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}"