From 7eafe5dbfed91be331b543817553800e8ab51f9d Mon Sep 17 00:00:00 2001 From: coolnsx Date: Mon, 23 Oct 2023 17:26:11 +0530 Subject: [PATCH] I will not apologize for art. --- eww/yt-music-presence.py | 45 ++++++++++++++++++++++++++++++++++ hypr/launch | 15 ++++++++++++ zsh/completions/_url_nextcloud | 2 ++ 3 files changed, 62 insertions(+) create mode 100644 eww/yt-music-presence.py create mode 100755 hypr/launch create mode 100644 zsh/completions/_url_nextcloud diff --git a/eww/yt-music-presence.py b/eww/yt-music-presence.py new file mode 100644 index 0000000..fbff96a --- /dev/null +++ b/eww/yt-music-presence.py @@ -0,0 +1,45 @@ +import socket +import time,re +from pypresence import Presence + +def update(): + # Get the duration information + time.sleep(2) + + # Update Discord Rich Presence with the end timestamp + with open("/tmp/yt-music/current", 'r') as file: + li = re.split(' >|: | - ', file.readline().strip('\n')) + file.close() + + print(li) + # Update Discord Rich Presence with the information from the file + RPC.update( + large_image=f"https://i.ytimg.com/vi/{li[-1]}/mqdefault.jpg", + details=f"{li[1]}", + large_text = "Checkmate Premium Users", + state=li[2], + start=int(time.time()), + ) + +socket_path = "/tmp/yt-music/yt-music-mpvsocket" + +# Initialize Discord Rich Presence +RPC = Presence("1165951947245879316") +RPC.connect() + +# Create a UNIX socket +mpv_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +mpv_socket.connect(socket_path) +update() +while True: + event = mpv_socket.recv(1024).decode('utf-8') + # Adjust the buffer size as needed + if not event: + break + #check if event contains "end-file" or "eof" + if "end-file" in event or "eof" in event: + print(event) + update() + +mpv_socket.close() +RPC.close() diff --git a/hypr/launch b/hypr/launch new file mode 100755 index 0000000..af6a046 --- /dev/null +++ b/hypr/launch @@ -0,0 +1,15 @@ +#!/bin/sh + +menu() { + bemenu --fn 'IBM Plex Sans 15' -i -c -W "0.${2:-5}" -B 3 -p "$1" -l 25 -P ">>" +} + +[ -z "$1" ] && dir="$HOME/repos_scripts" || dir="$1" + +[ -d "$dir" ] || exit 0 + +script=$(find "$dir" -maxdepth 1 -type f ! -name '*.md' ! -name ".*" -printf "%f\n" | menu "Run Script: " "2") + +[ -z "$script" ] && exit 0 + +sh -c "$dir/$script" diff --git a/zsh/completions/_url_nextcloud b/zsh/completions/_url_nextcloud new file mode 100644 index 0000000..ad43d1d --- /dev/null +++ b/zsh/completions/_url_nextcloud @@ -0,0 +1,2 @@ +#compdef url_nextcloud +_arguments '1:filename:_files'