2021-09-06 21:54:14 -04:00
# `wayland-recorder`
2024-11-22 06:29:02 -05:00
Scripts to use with `wf-recorder` and `waybar` for screen recording.
2021-09-06 21:54:14 -04:00
## Dependencies
2024-11-22 06:29:02 -05:00
- [`slurp` ](https://github.com/emersion/slurp )
- [`wf-recorder` ](https://github.com/ammen99/wf-recorder )
2021-09-06 21:54:14 -04:00
2024-11-22 06:29:02 -05:00
[`waybar` ](https://github.com/Alexays/Waybar ) can optionally be used to show that a recording is in progress, but is not strictly necessary.
2021-09-06 21:54:14 -04:00
## Setup
2024-11-22 06:29:02 -05:00
[`record-screen` ](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.
```bash
./record-screen
```
- **To stop an ongoing recording**:
Running the script again will stop the recording.
```bash
./record-screen
```
2021-09-06 21:54:14 -04:00
2024-11-22 06:29:02 -05:00
- **To start an audio-only recording**:
Pass the `-a` or `--audio` flag to the script to start recording audio only (no screen capture).
2021-09-06 21:54:14 -04:00
2024-11-22 06:29:02 -05:00
```bash
./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.
```bash
./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:
```bash
bindsym $mod+print exec exec < path to record-screen >
```
This will start/stop the screen recording upon each key press.
2021-09-06 21:54:14 -04:00
## Waybar integration
2024-11-22 06:29:02 -05:00
[`record-screen -c` ](record-screen ) can be used to create a custom waybar widget that shows if a recording is in progress.
2021-09-06 21:54:14 -04:00
2024-11-22 06:29:02 -05:00
Here's an example configuration for `waybar` :
2021-09-06 21:54:14 -04:00
```json
2024-11-22 06:29:02 -05:00
"custom/recording": {
"exec": "~/.local/bin/record-screen -c",
"interval": 1,
"tooltip-format": "Recording ON!",
"on-click": "~/.local/bin/record-screen"
}
2021-09-06 21:54:14 -04:00
```
2024-11-22 06:29:02 -05:00
### 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.
2021-09-06 21:54:14 -04:00
2024-11-22 06:29:02 -05:00
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.