scheme: add notify opt

For sending a notification on error
This commit is contained in:
2 * r + 2 * t
2025-06-17 12:49:16 +10:00
parent f0c892749d
commit 2c94c42cbd
7 changed files with 52 additions and 42 deletions
+10 -25
View File
@@ -3,6 +3,7 @@ import time
from argparse import Namespace
from datetime import datetime
from caelestia.utils.notify import notify
from caelestia.utils.paths import recording_notif_path, recording_path, recordings_dir
@@ -48,20 +49,10 @@ class Command:
# Send notif if proc hasn't ended after a small delay
time.sleep(0.1)
if proc.poll() is None:
notif = subprocess.check_output(
["notify-send", "-p", "-a", "caelestia-cli", "Recording started", "Recording..."], text=True
).strip()
notif = notify("-p", "Recording started", "Recording...")
recording_notif_path.write_text(notif)
else:
subprocess.run(
[
"notify-send",
"-a",
"caelestia-cli",
"Recording failed",
f"Recording failed to start: {proc.communicate()[1]}",
]
)
notify("Recording failed", f"Recording failed to start: {proc.communicate()[1]}")
def stop(self) -> None:
subprocess.run(["pkill", "wl-screenrec"])
@@ -87,19 +78,13 @@ class Command:
except IOError:
pass
action = subprocess.check_output(
[
"notify-send",
"-a",
"caelestia-cli",
"--action=watch=Watch",
"--action=open=Open",
"--action=delete=Delete",
"Recording stopped",
f"Recording saved in {new_path}",
],
text=True,
).strip()
action = notify(
"--action=watch=Watch",
"--action=open=Open",
"--action=delete=Delete",
"Recording stopped",
f"Recording saved in {new_path}",
)
if action == "watch":
subprocess.Popen(["app2unit", "-O", new_path], start_new_session=True)