✨ feat(indicators, screen-capture): display and track recording time in RecordingIndicator and screen-capture.sh

This commit is contained in:
sankalp committed 2025-07-04 08:40:45 +05:45
1 parent aac7296d92
commit 1c47101457
2 files changed
+50 -3

No files matched your search

+36 -3
View File
@@ -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,
)
+14
View File
@@ -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
;;