# under the terms of the GNU General Public License as published by the
# Free Software Foundation, version 3.
+from dataclasses import dataclass
import subprocess
from typing import Callable
from gi.repository import Gtk # nopep8 pylint: disable=wrong-import-position
-recording = None
+@dataclass
+class Recording:
+ process: subprocess.Popen[bytes]
+
+
+recording: Recording | None = None
def on_start_recording(_: Gtk.Button, stack: Gtk.Stack) -> None:
'-f', 'pulse', '-ac', '2', '-i', 'default',
'screen-recording.mkv'] # nopep8
# pylint: disable=consider-using-with
- recording = subprocess.Popen(command, stdin=subprocess.PIPE)
+ recording = Recording(
+ process=subprocess.Popen(command, stdin=subprocess.PIPE))
stack.set_visible_child_name("recording")
def on_stop_recording(_: Gtk.Button, stack: Gtk.Stack) -> None:
global recording # pylint: disable=global-statement
assert recording is not None
- stdin = recording.stdin
+ stdin = recording.process.stdin
assert stdin is not None
stdin.write(b'q')
stdin.flush()
- recording.wait()
+ recording.process.wait()
recording = None
stack.set_visible_child_name("not_recording")