Files
repos_scripts/.functions
T
2026-05-02 23:53:20 +05:30

69 lines
1.7 KiB
Bash

#!/bin/sh
#shellcheck disable=SC2086,SC2068
menu_droid() {
fzf --prompt="$1" $2
}
menu_linux() {
bemenu --fn 'IBM Plex Sans 15' -i -c -W "0.${3:-6}" -B 3 -l 25 -p "$1" --bdr="#$GLOBAL_ACCENT" --tf="#$GLOBAL_ACCENT" --hf="#$GLOBAL_ACCENT" -R 20
}
search_droid() {
printf "%s" "$1" && read -r query
}
search_linux() {
query=$(: | menu_linux "$1 ")
export query
}
torrent_linux() {
setsid -f "$TERMINAL" -e "${0%/*}/torrent" $@
}
torrent_droid() {
"${0%/*}/torrent" $@
}
info_droid() {
printf "\n\r\033[1;36m%s" "$1"
}
info_linux() {
notify-send -e "$1" -r '10' -i "$2" $3
}
error_droid() {
printf "\33[2K\r\033[1;31m%s" "$1"
}
error_linux() {
notify-send -e -u "critical" "$1" -r '10'
}
player_droid() {
dir="/storage/emulated/0/.mpv"
file="$dir/mpv.config.mp4"
if [ -w "${dir%*/.mpv}" ]; then
[ -d "${dir}" ] || mkdir "${dir}"
printf "%s" "$3" | sed 's| --|\n|g; s|^--||g' > "$file"
sleep 10 && : > "$file" &
else
printf "\n\033[1;31mCannot write\033[0m → $file\n"
printf "\033[1;36mRun:\033[0m termux-setup-storage\n\n"
printf "\033[1;36mThen:\033[0m\n"
printf "> allow storage permission\n"
printf "> add → include='$file'\n"
printf " to MPV → Settings > Advanced > mpv.conf\n"
printf " Make sure to press enter after pasting the content above for MPV to recognise it.."
fi
am start --user 0 -a android.intent.action.VIEW -d "$1" -n is.xyz.mpv/.MPVActivity -e "title" "$2" >/dev/null 2>&1
#am start --user 0 -a android.intent.action.VIEW -d "$1" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e "title" "$2" >/dev/null 2>&1
}
player_linux() {
setsid -f mpv "$1" --force-media-title="$2" $3
}