Fix PC Load Letter Error

This commit is contained in:
coolnsx
2023-09-16 18:18:25 +05:30
parent e5965d8697
commit c95bcc2e2c
10 changed files with 32 additions and 58 deletions

View File

@@ -77,9 +77,9 @@
(label :tooltip "${song.name}" :halign "center" :class "song" :wrap "false" :limit-width 20 :text "${song.name}")
(label :halign "center" :class "artist" :wrap "false" :limit-width 20 :text "${song.artist}")
(box :orientation "h" :spacing 35 :halign "center" :space-evenly "true" :vexpand "false" :hexpand "false"
(button :class "btn_controls" :onclick "./script prev" "󰒮")
(button :class "btn_controls" :onclick "./script seek '-1'" "")
(button :class "btn_controls" :tooltip "History : ${song.prev}" :onclick "./script prev" "󰒮")
(button :class "btn_controls" :tooltip "Seek -1%" :onclick "./script seek '-1'" "")
(button :class "btn_play" :onclick "./script play_toggle" STATUS)
(button :class "btn_controls" :onclick "./script seek '1'" "")
(button :class "btn_controls" :tooltip "Seek +1%" :onclick "./script seek '1'" "")
(button :class "btn_controls" :tooltip "Upcoming : ${song.next}" :onclick "./script next" "󰒭"))
(label :justify "left" :wrap "true" :class "lyrics" :text LYRICS))))

View File

@@ -1,13 +0,0 @@
from pypresence import Presence
import re, json
from time import time
RPC = Presence("1086258743823564903")
RPC.connect()
with open("/tmp/yt-music/current",'r') as file:
li = re.split(' >|: | - ',file.readline().strip('\n'))
file.close()
RPC.update(large_image=f"https://i.ytimg.com/vi/{li[-1]}/mqdefault.jpg",details=f"{li[1]}",state=li[2],small_image="/home/tanveer/Downloads/kisspng-mpv-logo-computer-software-5b0b2bfe514221.6053513215274588143328.png",start=time.time())

View File

@@ -2,15 +2,15 @@
case $1 in
songdata)
out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - /tmp/mpvsocket 2>/dev/null)
out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - /tmp/yt-music/yt-music-mpvsocket 2>/dev/null)
if [ -n "$out" ] && pgrep -f mpvsocket >/dev/null 2>&1;then
printf '{"name":"%s","artist":"%s","cover":"/tmp/yt-music/default.jpg","next":"%s"}' "$(cut -d'>' -f1 < "/tmp/yt-music/current" | cut -d':' -f2 | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')" "$(cut -d'>' -f1 < "/tmp/yt-music/current" | sed 's_.* - __;s| $||')" "$(sed -n "/$(cut -d'>' -f2 < /tmp/yt-music/current )/{n;p}" /tmp/yt-music/next | cut -f1)"
printf '{"name":"%s","artist":"%s","cover":"/tmp/yt-music/default.jpg","next":"%s","prev":"%s"}' "$(cut -d'>' -f1 < "/tmp/yt-music/current" | cut -d':' -f2 | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')" "$(cut -d'>' -f1 < "/tmp/yt-music/current" | sed 's_.* - __;s| $||')" "$(sed -n "/$(cut -d'>' -f2 < /tmp/yt-music/current )/{n;p}" /tmp/yt-music/next | cut -f1)" "$(sed -n "$(cat /tmp/yt-music/counter)p" /tmp/yt-music/next | cut -f1)"
else
printf '{"name":"OFFLINE","artist":"offline","cover":"%s/.config/eww/music.png"}' "$HOME"
fi
;;
status)
out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - /tmp/mpvsocket 2>/dev/null)
out=$(printf '{ "command": ["get_property", "pause"]}\n' | socat - /tmp/yt-music/yt-music-mpvsocket 2>/dev/null)
if [ -z "$out" ];then
printf ""
elif printf "%s" "$out" | grep -q "true";then
@@ -21,17 +21,17 @@ case $1 in
;;
lyrics)
if [ -f "/tmp/yt-music/lyrics" ]; then
awk -F'\t' -v value="$(echo '{ "command": ["get_property", "time-pos"] }' | socat - /tmp/mpvsocket | sed -nE 's|.*data":([^,]*).*|\1|p')" '$1 > value*1000 {print $2;exit}' /tmp/yt-music/lyrics
awk -F'\t' -v value="$(echo '{ "command": ["get_property", "time-pos"] }' | socat - /tmp/yt-music/yt-music-mpvsocket | sed -nE 's|.*data":([^,]*).*|\1|p')" '$1 > value*1002 {print $2;exit}' /tmp/yt-music/lyrics
else
printf "Lyrics will show here"
fi
;;
time)
out=$(echo '{"command" :["get_property" , "percent-pos"]}' | socat - /tmp/mpvsocket 2>/dev/null | sed -nE 's_.*data":([^,]*).*_\1_p')
out=$(echo '{"command" :["get_property" , "percent-pos"]}' | socat - /tmp/yt-music/yt-music-mpvsocket 2>/dev/null | sed -nE 's_.*data":([^,]*).*_\1_p')
printf '%s' "${out:-100}"
;;
play_toggle)
echo cycle pause | socat - "/tmp/mpvsocket"
echo cycle pause | socat - "/tmp/yt-music/yt-music-mpvsocket"
;;
next)
pgrep -f mpvsocket >/dev/null 2>&1 && "$HOME/repos_scripts/yt-music" play_next
@@ -40,9 +40,9 @@ case $1 in
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)")
pgrep -f mpvsocket >/dev/null 2>&1 && counter=$(cat /tmp/yt-music/counter) && [ "$counter" -gt 0 ] && "$HOME/repos_scripts/yt-music" play "$(sed -n "${counter}p" /tmp/yt-music/next)" && printf "%s" "$((counter-1))" > /tmp/yt-music/counter &
;;
seek)
echo "{\"command\" :[\"seek\" ,\"$2\",\"relative-percent\"]}" | socat - /tmp/mpvsocket
echo "{\"command\" :[\"seek\" ,\"$2\",\"relative-percent\"]}" | socat - /tmp/yt-music/yt-music-mpvsocket
;;
esac