From ffa535bccaee439e525cbbe804f04e943095fc81 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 24 Jun 2025 04:44:57 +0545 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(indicators,=20recording):=20ad?= =?UTF-8?q?d=20recording=20indicator=20with=20screen-capture=20support=20a?= =?UTF-8?q?nd=20status=20checking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dock/components/indicators.py | 72 ++++++++++++++++++++++++++- services/__init__.py | 2 - styles/indicators.css | 26 +++++++++- 3 files changed, 96 insertions(+), 4 deletions(-) diff --git a/modules/dock/components/indicators.py b/modules/dock/components/indicators.py index 14858b8..b8ecad7 100644 --- a/modules/dock/components/indicators.py +++ b/modules/dock/components/indicators.py @@ -1,3 +1,4 @@ +import subprocess import config.data as data import utils.icons as icons from fabric.bluetooth import BluetoothClient @@ -6,6 +7,8 @@ from fabric.widgets.button import Button from fabric.widgets.circularprogressbar import CircularProgressBar from fabric.widgets.label import Label from fabric.widgets.overlay import Overlay +from fabric.utils import get_relative_path +from gi.repository import GLib from services.network import NetworkClient @@ -167,13 +170,80 @@ class BluetoothIndicator(Button): self.update_state() +class RecordingIndicator(Button): + def __init__(self, **kwargs): + super().__init__(name="button-bar-recording", **kwargs) + + # Path to the screen-capture script + self.script_path = get_relative_path("../../../scripts/screen-capture.sh") + + self.recording_label = Label(name="recording-label", markup=icons.screenrecord) + self.add(self.recording_label) + + # Connect click to stop recording + self.connect("clicked", self.on_stop_recording) + + # Start with indicator hidden + self.hide() + + # Set up periodic checking for recording status + self.check_recording_status() + self.timeout_id = GLib.timeout_add(1000, self.check_recording_status) # Check every second + + def check_recording_status(self): + """Check if recording is currently active and update visibility.""" + try: + result = subprocess.run( + [self.script_path, "status"], + capture_output=True, + text=True, + timeout=2 + ) + is_recording = result.stdout.strip() == "true" + + if is_recording: + if not self.get_visible(): + self.show() + self.set_tooltip_text("Recording in progress - Click to stop") + else: + if self.get_visible(): + self.hide() + + except Exception as e: + # If we can't check status, hide the indicator + if self.get_visible(): + self.hide() + + return True # Continue the timeout + + def on_stop_recording(self, *args): + """Stop the current recording.""" + try: + subprocess.Popen([self.script_path, "record", "stop"]) + # The indicator will hide automatically on next status check + except Exception as e: + print(f"Error stopping recording: {e}") + + def cleanup(self): + """Clean up the timeout when the indicator is destroyed.""" + if hasattr(self, 'timeout_id'): + GLib.source_remove(self.timeout_id) + + class Indicators(Box): def __init__(self, **kwargs): + self.recording_indicator = RecordingIndicator() + super().__init__( name="indicator", orientation="h" if not data.VERTICAL else "v", spacing=4, - children=[WifiIndicator(), BluetoothIndicator()], + children=[WifiIndicator(), BluetoothIndicator(), self.recording_indicator], **kwargs, ) self.show_all() + + def cleanup(self): + """Clean up all indicators when the dock is destroyed.""" + if hasattr(self, 'recording_indicator'): + self.recording_indicator.cleanup() diff --git a/services/__init__.py b/services/__init__.py index 97246c2..1ab977c 100644 --- a/services/__init__.py +++ b/services/__init__.py @@ -4,7 +4,5 @@ Contains background services and utilities for the shell. """ from .notification import CustomNotifications -from .weather import WeatherService notification_service = CustomNotifications() -weather_service = WeatherService() diff --git a/styles/indicators.css b/styles/indicators.css index b938e64..883596b 100644 --- a/styles/indicators.css +++ b/styles/indicators.css @@ -14,7 +14,31 @@ border: 3px solid var(--primary); } +#button-bar-recording { + border-radius: 12px; + padding:4px; + animation: recording-blink 1.5s ease-in-out infinite; +} + +#button-bar-recording:hover { + background-color: var(--red); +} + + +@keyframes recording-blink { + 0% { + background-color: var(--red-dim); + } + 50% { + background-color: var(--red-dim); + } + 100% { + background-color: var(--red-dim); + } +} + #network-label, -#bluetooth-label { +#bluetooth-label, +#recording-label { font-size: 20px; }