The script can now be run with optional flag to enable audio in the screen recording. The flag can be passed to check if the recording is on (for the waybar module). This allows only one script to be used for everything.
2.8 KiB
wayland-recorder
Scripts to use with wf-recorder
and waybar
for screen recording.
Dependencies
waybar
can optionally be used to show that a recording is in progress, but is not strictly necessary.
Setup
record-screen
is the main script. It is intended to be bound to a hotkey. Upon the first invocation, it runs slurp
to let you select an area of the screen to record, and then runs wf-recorder
in the background. By default, it records to ~/vids/recordings
, but this can be changed by editing the script. On a second invocation, it stops the recording.
New Flags:
-c
or--check
: Checks if a recording is in progress and prints the status.-a
or--audio
: Records audio only (no screen recording).- Default behavior (without flags) starts a screen recording after selecting the area via
slurp
.
Usage:
-
To start a screen recording:
Simply run the script or bind it to a hotkey. The first time you run it, it will prompt you to select the screen area and start the recording../record-screen
-
To stop an ongoing recording:
Running the script again will stop the recording../record-screen
-
To start an audio-only recording:
Pass the-a
or--audio
flag to the script to start recording audio only (no screen capture)../record-screen --audio
-
To check if a recording is currently in progress:
Use the-c
or--check
flag to see if a recording is currently active../record-screen --check
Example Keybinding for sway
:
You can configure the script to be executed via a hotkey, for example with the following line in your sway
configuration:
bindsym $mod+print exec exec <path to record-screen>
This will start/stop the screen recording upon each key press.
Waybar integration
record-screen -c
can be used to create a custom waybar widget that shows if a recording is in progress.
Here's an example configuration for waybar
:
"custom/recording": {
"exec": "~/.local/bin/record-screen -c",
"interval": 1,
"tooltip-format": "Recording ON!",
"on-click": "~/.local/bin/record-screen"
}
Explanation:
"exec"
runs the script with the-c
flag every second to check if a recording is in progress."on-click"
will execute the script without flags, which will stop the current recording when clicked."interval": 1
updates the status every second.
This configuration also allows you to terminate the current recording by simply clicking the widget.
Note that the script attempts to display an icon with Font Awesome. If this is not desired, the script could be edited to remove the icon.