summaryrefslogtreecommitdiff
path: root/src/caelestia/subcommands
diff options
context:
space:
mode:
Diffstat (limited to 'src/caelestia/subcommands')
-rw-r--r--src/caelestia/subcommands/record.py35
-rw-r--r--src/caelestia/subcommands/scheme.py3
-rw-r--r--src/caelestia/subcommands/screenshot.py29
3 files changed, 25 insertions, 42 deletions
diff --git a/src/caelestia/subcommands/record.py b/src/caelestia/subcommands/record.py
index a4fa51d..dd0a5d0 100644
--- a/src/caelestia/subcommands/record.py
+++ b/src/caelestia/subcommands/record.py
@@ -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)
diff --git a/src/caelestia/subcommands/scheme.py b/src/caelestia/subcommands/scheme.py
index c8842f7..b326e5d 100644
--- a/src/caelestia/subcommands/scheme.py
+++ b/src/caelestia/subcommands/scheme.py
@@ -13,6 +13,9 @@ class Set:
def run(self) -> None:
scheme = get_scheme()
+ if self.args.notify:
+ scheme.notify = True
+
if self.args.random:
scheme.set_random()
apply_colours(scheme.colours, scheme.mode)
diff --git a/src/caelestia/subcommands/screenshot.py b/src/caelestia/subcommands/screenshot.py
index a535f6f..acd1725 100644
--- a/src/caelestia/subcommands/screenshot.py
+++ b/src/caelestia/subcommands/screenshot.py
@@ -4,6 +4,7 @@ from argparse import Namespace
from datetime import datetime
from caelestia.utils import hypr
+from caelestia.utils.notify import notify
from caelestia.utils.paths import screenshots_cache_dir, screenshots_dir
@@ -59,22 +60,16 @@ class Command:
screenshots_cache_dir.mkdir(exist_ok=True, parents=True)
dest.write_bytes(sc_data)
- action = subprocess.check_output(
- [
- "notify-send",
- "-i",
- "image-x-generic-symbolic",
- "-h",
- f"STRING:image-path:{dest}",
- "-a",
- "caelestia-cli",
- "--action=open=Open",
- "--action=save=Save",
- "Screenshot taken",
- f"Screenshot stored in {dest} and copied to clipboard",
- ],
- text=True,
- ).strip()
+ action = notify(
+ "-i",
+ "image-x-generic-symbolic",
+ "-h",
+ f"STRING:image-path:{dest}",
+ "--action=open=Open",
+ "--action=save=Save",
+ "Screenshot taken",
+ f"Screenshot stored in {dest} and copied to clipboard",
+ )
if action == "open":
subprocess.Popen(["swappy", "-f", dest], start_new_session=True)
@@ -82,4 +77,4 @@ class Command:
new_dest = (screenshots_dir / dest.name).with_suffix(".png")
new_dest.parent.mkdir(exist_ok=True, parents=True)
dest.rename(new_dest)
- subprocess.run(["notify-send", "Screenshot saved", f"Saved to {new_dest}"])
+ notify("Screenshot saved", f"Saved to {new_dest}")