Sway : Add screen recording.

This commit is contained in:
Dmitry Voronin 2024-08-22 19:13:40 +03:00
parent ff83c5a6a8
commit 5b709e1947
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
4 changed files with 31 additions and 6 deletions

View file

@ -1,9 +1,16 @@
{ ... }: {
{ config, ... }: let
color = config.style.color;
opacity = "26";
selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000";
in {
text = ''
# Fullscreen screenshot.
bindsym --to-code $mod+shift+v exec grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - | wl-copy -t image/png
# bindsym --to-code $mod+shift+v exec grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - | wl-copy -t image/png
# Select screenshot.
bindsym --to-code $mod+v exec grim -g "$(slurp -d)" - | wl-copy
bindsym --to-code $mod+v exec grim -g "$(${selection})" - | wl-copy
# Select recording.
bindsym --to-code $mod+shift+v exec 'pkill -SIGINT wf-recorder || wf-recorder --geometry "$(${selection})" --codec libsvtav1 --file $HOME/media/video/"$(date +%Y-%m-%d_%H-%M-%S)".mkv --framerate 10'
'';
}

View file

@ -77,6 +77,19 @@
rm -d out/
}
# Rotate the video clock-wise.
# Usage: ffmpeg_rotate <ANGLE> <TARGET>
function ffmpeg_rotate() {
if [[ "''${2}" = "" ]]; then
help ffmpeg_rotate
fi
local angle="''${1}"
local target="''${2}"
ffmpeg -display_rotation ''${angle} -i ''${target} -c copy _''${target} && mv _''${target} ''${target} || rm _''${target}
}
# Get video FPS.
function _ffprobe_fps() {
local fps=$(ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate "''${1}")

View file

@ -64,7 +64,7 @@
desktop = with pkgs; [
foot # Terminal emulator.
fuzzel # Application launcher.
grim slurp # Screenshot.
grim slurp wf-recorder # Screenshot.
mako # Notification system.
networkmanagerapplet # Internet configuration.
pamixer pavucontrol pulseaudio # Audio.

View file

@ -34,13 +34,14 @@
function monbar() {
local __monstate=$(_monstate)
local __gamingstate=$(_gamingstate)
local __recording=$(_recording)
local class=""
if [[ "''${__monstate}" = "off" ]] || [[ "''${__gamingstate}" = "on" ]]; then
if [[ "''${__monstate}" = "off" ]] || [[ "''${__gamingstate}" = "on" ]] || [[ "''${__recording}" = "on" ]]; then
class="modified"
fi
printf "{\"text\": \"󰍹\", \"tooltip\": \"Monitor: ''${__monstate^} / Gaming: ''${__gamingstate^}\", \"class\": \"''${class}\"}\n"
printf "{\"text\": \"󰍹\", \"tooltip\": \"Monitor: ''${__monstate^} / Gaming: ''${__gamingstate^} / Recording: ''${__recording^}\", \"class\": \"''${class}\"}\n"
}
function _monstate() {
@ -50,5 +51,9 @@
echo "''${*}" > /tmp/.monstate
fi
}
function _recording() {
[[ "$(ps cax | rg wf-recorder)" = "" ]] && echo off || echo on
}
'';
}