dotfiles/dot_config/hypr/scripts/tools/executable_dynamic
punkfairie a53c7bb844
Add .config/cava/config
Add .config/dunst/dunstrc
Add .config/hypr/component/waybar/config
Add .config/hypr/component/waybar/style.css
Add .config/hypr/autostart
Add .config/hypr/hyprland.conf
Add .config/hypr/scripts/expand_toolbar
Add .config/hypr/scripts/launch_waybar
Add .config/hypr/scripts/lock
Add .config/hypr/scripts/rgb
Add .config/hypr/scripts/rgb_borders
Add .config/hypr/scripts/screenshot
Add .config/hypr/scripts/toolbar_state
Add .config/hypr/scripts/wall
Add .config/hypr/scripts/workspaces
Add .config/hypr/scripts/tools/dynamic
Add .config/hypr/scripts/tools/expand
Add .config/hypr/scripts/tools/notif
Add .config/hypr/scripts/tools/start_dyn
Add .config/hypr/store/dynamic_out.txt
Add .config/hypr/store/latest_notif
Add .config/hypr/store/prev.txt
Add .config/hypr/wallpapers/cloud.png
Add .config/hypr/wallpapers/clouds_realism.jpg
Add .config/hypr/wallpapers/evening-sky.png
Add .config/hypr/wallpapers/flower.jpg
Add .config/hypr/wallpapers/mountain.png
Add .config/hypr/wallpapers/totoro.png
Add .config/hypr/wallpapers/train.jpg
Update .config/packages/archgirlie
Add .config/wofi/config
Add .config/wofi/menu
Add .config/wofi/menu.css
Add .config/wofi/style.css
2024-05-18 14:34:14 -07:00

83 lines
No EOL
2.1 KiB
Python

#!/usr/bin/python
import subprocess
from pathlib import Path
import json
import pickle
import time
import threading
OUT = f"{Path.home()}/.config/hypr/store/dynamic_out.txt"
# PREV_PATH = f"{Path.home()}/.config/hypr/store/prev.txt"
prev = None
def print(ar):
with open(OUT,"w") as f:
f.write(json.dumps(ar))
# with open(f"{Path.home()}/.config/hypr/im_here","w") as f:
# f.write("")
global PAUSE_MEDIA
PAUSE_MEDIA = False
def notif_watcher():
with open(f"{Path.home()}/.config/hypr/store/latest_notif","rb") as f:
new = pickle.load(f)
global prev
if new != prev:
print(json.dumps({"class":"none","text":""}))
global PAUSE_MEDIA
PAUSE_MEDIA = True
urgency = "low"
if new["urgency"] == "CRITICAL":
urgency = "critical"
elif new["urgency"] == "NORMAL":
urgency = "normal"
doc = {
"class":urgency,
"text":f'[{new["app_name"]}] {new["summary"]}',
"tooltip":"notification"
}
print(doc)
time.sleep(3)
print({"class":"none","text":""})
PAUSE_MEDIA = False
prev = new
def start_watcher():
while 1:
notif_watcher()
time.sleep(0.5)
def debug():
while 1:
print(PAUSE_MEDIA)
time.sleep(0.5)
t = threading.Thread(target=start_watcher)
d = threading.Thread(target=debug)
t.start()
# d.start()
with open("test.log", "wb") as f:
process = subprocess.Popen(
"waybar-mpris --position --autofocus".split(),
stdout=subprocess.PIPE
)
print(json.dumps({"class":"none","text":""}))
for line in iter(lambda: process.stdout.readline().decode("utf-8"), b""):
dat = json.loads(line)
if not PAUSE_MEDIA:
if "text" in dat:
dat["text"] = dat["text"].replace("", "").replace("", "")
print(dat)
else:
print({"class":"none","text":""})
t.join()
# d.join()