From 1c4710145727ef0603c649991507fe27198abb6c Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 4 Jul 2025 08:40:45 +0545 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(indicators,=20screen-capture):?= =?UTF-8?q?=20display=20and=20track=20recording=20time=20in=20RecordingInd?= =?UTF-8?q?icator=20and=20screen-capture.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dock/components/indicators.py | 39 ++++++++++++++++++++++++--- scripts/screen-capture.sh | 14 ++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/modules/dock/components/indicators.py b/modules/dock/components/indicators.py index 1c8c883..305ad94 100644 --- a/modules/dock/components/indicators.py +++ b/modules/dock/components/indicators.py @@ -1,4 +1,5 @@ import subprocess +import time from fabric.bluetooth import BluetoothClient from fabric.utils import get_relative_path @@ -178,9 +179,17 @@ class RecordingIndicator(Button): super().__init__(name="button-bar-recording", **kwargs) self.script_path = get_relative_path("../../../scripts/screen-capture.sh") + self.recording_start_time = None self.recording_label = Label(name="recording-label", markup=icons.screenrecord) - self.add(self.recording_label) + self.time_label = Label(name="recording-time-label", markup="00:00") + + self.recording_box = Box( + orientation="h", + spacing=4, + children=[self.recording_label, self.time_label] + ) + self.add(self.recording_box) self.connect("clicked", self.on_stop_recording) @@ -199,18 +208,42 @@ class RecordingIndicator(Button): if is_recording: if not self.get_visible(): self.show() - self.set_tooltip_text("Recording in progress - Click to stop") + + # Get the recording start time if we don't have it + if self.recording_start_time is None: + self.recording_start_time = self.get_recording_start_time() + + # Update the recording time display + if self.recording_start_time: + elapsed_seconds = int(time.time() - self.recording_start_time) + minutes = elapsed_seconds // 60 + seconds = elapsed_seconds % 60 + time_text = f"{minutes:02d}:{seconds:02d}" + self.time_label.set_markup(time_text) + self.set_tooltip_text(f"Recording in progress ({time_text}) - Click to stop") + else: + self.set_tooltip_text("Recording in progress - Click to stop") else: if self.get_visible(): self.hide() + self.recording_start_time = None except Exception: # If we can't check status, hide the indicator if self.get_visible(): self.hide() + self.recording_start_time = None return True # Continue the timeout + def get_recording_start_time(self): + """Get the recording start time from the file""" + try: + with open("/tmp/recording_start_time.txt", "r") as f: + return float(f.read().strip()) + except Exception: + return None + def on_stop_recording(self, *args): try: subprocess.Popen([self.script_path, "record", "stop"]) @@ -234,8 +267,8 @@ class Indicators(Box): children=[ WifiIndicator(), BluetoothIndicator(), - self.recording_indicator, self.notifications, + self.recording_indicator, ], **kwargs, ) diff --git a/scripts/screen-capture.sh b/scripts/screen-capture.sh index 0005d07..4d3958a 100755 --- a/scripts/screen-capture.sh +++ b/scripts/screen-capture.sh @@ -111,6 +111,8 @@ wf-recorder_check() { else notify-send "Recording stopped" "wf-recorder process terminated" fi + # Clean up recording start time file + rm -f /tmp/recording_start_time.txt exit 0 fi } @@ -267,16 +269,19 @@ case "$COMMAND" in "selection") wf-recorder_check echo "$VID" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt record_video "$VID" -g "$(slurp)" ;; "eDP-1") wf-recorder_check echo "$VID" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt record_video "$VID" -a -o eDP-1 ;; "HDMI-A-1") wf-recorder_check echo "$VID" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt record_video "$VID" -a -o HDMI-A-1 ;; *) @@ -294,16 +299,19 @@ case "$COMMAND" in "selection") wf-recorder_check echo "$VID" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt record_video_noaudio "$VID" -g "$(slurp)" ;; "eDP-1") wf-recorder_check echo "$VID" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt record_video_noaudio "$VID" -o eDP-1 ;; "HDMI-A-1") wf-recorder_check echo "$VID" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt record_video_noaudio "$VID" -o HDMI-A-1 ;; *) @@ -324,18 +332,21 @@ case "$COMMAND" in "selection") wf-recorder_check echo "$VID_HQ" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt notify-send "High Quality Recording" "Starting YouTube-quality recording..." record_high_quality "$VID_HQ" -g "$(slurp)" ;; "eDP-1") wf-recorder_check echo "$VID_HQ" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt notify-send "High Quality Recording" "Starting YouTube-quality recording on eDP-1..." record_high_quality "$VID_HQ" -a -o eDP-1 ;; "HDMI-A-1") wf-recorder_check echo "$VID_HQ" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt notify-send "High Quality Recording" "Starting YouTube-quality recording on HDMI-A-1..." record_high_quality "$VID_HQ" -a -o HDMI-A-1 ;; @@ -357,18 +368,21 @@ case "$COMMAND" in "selection") wf-recorder_check echo "$GIF" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt notify-send "GIF Recording" "Starting GIF recording (15 FPS)..." record_gif "$GIF" -g "$(slurp)" ;; "eDP-1") wf-recorder_check echo "$GIF" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt notify-send "GIF Recording" "Starting GIF recording on eDP-1..." record_gif "$GIF" -o eDP-1 ;; "HDMI-A-1") wf-recorder_check echo "$GIF" >/tmp/recording.txt + date +%s >/tmp/recording_start_time.txt notify-send "GIF Recording" "Starting GIF recording on HDMI-A-1..." record_gif "$GIF" -o HDMI-A-1 ;;