mirror of
https://github.com/CoolnsX/hyprdots.git
synced 2025-12-20 07:15:23 +05:30
62 lines
1.8 KiB
Bash
Executable File
62 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - /tmp/mpvsocket 2>/dev/null)
|
|
case $1 in
|
|
song)
|
|
if [ -n "$out" ] && pgrep -f mpvsocket >/dev/null 2>&1;then
|
|
cut -d'>' -f1 < "/tmp/yt-music/current" | cut -d':' -f2 | sed 's|[^-]*$||;s|[-| ]$||'
|
|
else
|
|
printf "OFFLINE"
|
|
fi
|
|
;;
|
|
artist)
|
|
if [ -n "$out" ] && pgrep -f mpvsocket >/dev/null 2>&1;then
|
|
cut -d'>' -f1 < "/tmp/yt-music/current" | sed 's_.* -__;s| $||'
|
|
else
|
|
printf "Offline"
|
|
fi
|
|
;;
|
|
cover)
|
|
if [ -n "$out" ] && pgrep -f mpvsocket >/dev/null 2>&1;then
|
|
printf "/tmp/yt-music/default.jpg"
|
|
else
|
|
printf "%s/.config/eww/music.png" "$HOME"
|
|
fi
|
|
;;
|
|
status)
|
|
if [ -z "$out" ];then
|
|
printf ""
|
|
elif printf "%s" "$out" | grep -q "true";then
|
|
printf "喇"
|
|
else
|
|
printf ""
|
|
fi
|
|
;;
|
|
play_toggle)
|
|
echo cycle pause | socat - "/tmp/mpvsocket"
|
|
;;
|
|
next)
|
|
pgrep -f mpvsocket >/dev/null 2>&1 && "$HOME/repos_scripts/yt-music" play_next
|
|
;;
|
|
next_song)
|
|
sed -n "$(cat /tmp/yt-music/counter){n;p}" /tmp/yt-music/next | cut -f1
|
|
;;
|
|
prev)
|
|
pgrep -f mpvsocket >/dev/null 2>&1 && ("$HOME/repos_scripts/yt-music" play "$(sed 's| >|\t|g' /tmp/yt-music/prev | cut -d':' -f2)")
|
|
;;
|
|
time)
|
|
out=$(echo '{"command" :["get_property" , "percent-pos"]}' | socat - /tmp/mpvsocket 2>/dev/null | sed -nE 's_.*data":([^,]*).*_\1_p')
|
|
printf '%s' "${out:-100}"
|
|
;;
|
|
seek)
|
|
echo "{\"command\" :[\"seek\" ,\"$2\",\"relative-percent\"]}" | socat - /tmp/mpvsocket
|
|
;;
|
|
lyrics)
|
|
if [ -f "/tmp/yt-music/lyrics" ]; then
|
|
sed -n "/^$(awk -v value="$(echo '{ "command": ["get_property", "time-pos"] }' | socat - /tmp/mpvsocket | sed -nE 's|.*data":([^,]*).*|\1|p')" '$1 > value*1000 {print $1;exit}' /tmp/yt-music/lyrics)\t/p" /tmp/yt-music/lyrics | cut -f2
|
|
else
|
|
printf "Lyrics will show here"
|
|
fi
|
|
;;
|
|
esac
|