Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An Extremely Simple and Efficient Script I Think You All Like #1308

Closed
wants to merge 12 commits into from
22 changes: 22 additions & 0 deletions .local/bin/videosearch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

command -v locate >/dev/null || {
notify-send "Locate not found. Installing..."
sudo pacman -S mlocate
} || {
notify-send "Failed. Run the script once on terminal OR change sudo permissions."
exit 1
}

[ -s "$HOME/.config/.mymlocate.db" ] || {
notify-send "You have no database. Creating it..."
disk_path=$(echo "" | rofi -dmenu -l 0 -p "Enter the disk path (e.g '/mnt/harddisk'): ")
sudo updatedb -o ~/.config/.mymlocate.db -U "$disk_path" || {
notify-send "Failed. Run the script once on terminal OR change sudo permissions."
exit 1
}
}

video_files=$(locate -d ~/.config/.mymlocate.db -b -r '.*\.\(mp4\|mkv\|webm\|mov\|m4v\|wmv\|flv\|avi\)$')
chosen_file=$(echo "$video_files" | sed 's|.*/||; s/\.[^.]*$//' | rofi -dmenu -p "Select Video")
mpv "$(echo "$video_files" | grep -F "/$chosen_file.")"