mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-05 02:53:38 -08:00
update
This commit is contained in:
35
.config/rofi/scripts/mpv-buffer.py
Executable file
35
.config/rofi/scripts/mpv-buffer.py
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
from subprocess import Popen
|
||||
from sys import exit as sysexit
|
||||
|
||||
from pyperclip import paste
|
||||
|
||||
|
||||
def notify(title, message, icon=None):
|
||||
"""Use dunstify to send notifications"""
|
||||
if icon:
|
||||
Popen(["dunstify", title, message, "-i", icon])
|
||||
else:
|
||||
Popen(["dunstify", title, message])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
url = paste()
|
||||
if not url:
|
||||
sysexit(1)
|
||||
if not url.startswith("https://www.youtube.com/"):
|
||||
notify(
|
||||
"ERROR",
|
||||
"URL is not from YouTube",
|
||||
"/usr/share/icons/Dracula/scalable/apps/YouTube-youtube.com.svg",
|
||||
)
|
||||
sysexit(1)
|
||||
with Popen(["/usr/bin/mpv", url]) as proc:
|
||||
notify(
|
||||
"rofi-mpv",
|
||||
"Playing video",
|
||||
"/usr/share/icons/Dracula/scalable/apps/YouTube-youtube.com.svg",
|
||||
)
|
||||
proc.wait()
|
||||
if proc.returncode != 0:
|
||||
sysexit(1)
|
||||
Reference in New Issue
Block a user