From e3c0ab94c0cfb15170a73d99f747a1a64f626819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Mon, 9 Oct 2023 17:20:06 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(hypr):=20recording=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit recording script using wf-recorder; also made a module for waybar to show an icon when recording --- .config/hypr/keybinds/binds.conf | 3 +++ .config/hypr/scripts/rofi/recording | 36 +++++++++++++++++++++++++++++ .config/waybar/config.jsonc | 26 ++++++++++++--------- .config/waybar/style.css | 6 ++++- 4 files changed, 59 insertions(+), 12 deletions(-) create mode 100755 .config/hypr/scripts/rofi/recording diff --git a/.config/hypr/keybinds/binds.conf b/.config/hypr/keybinds/binds.conf index 2ed1e8a8..bd3ab9bf 100644 --- a/.config/hypr/keybinds/binds.conf +++ b/.config/hypr/keybinds/binds.conf @@ -64,6 +64,9 @@ bind=SUPERSHIFT,w,exec, ~/.config/hypr/scripts/rofi/wallpaper_selection # Keybindings Cheatsheet bind=SUPER,i,exec, ~/.config/hypr/scripts/rofi/keybindings +# Recording +bind=SUPERSHIFT,r,exec, ~/.config/hypr/scripts/rofi/recording + ## Windows ## Focusing on windows bind=SUPER,left,movefocus,l diff --git a/.config/hypr/scripts/rofi/recording b/.config/hypr/scripts/rofi/recording new file mode 100755 index 00000000..c33b2aca --- /dev/null +++ b/.config/hypr/scripts/rofi/recording @@ -0,0 +1,36 @@ +#!/usr/bin/bash + +wf-recorder_check() { + if pgrep -x "wf-recorder" >/dev/null; then + pkill -INT -x wf-recorder + notify-send "Saved recording at " "$(cat /tmp/recording.txt)" + pkill -RTMIN+8 waybar + wl-copy <"$(cat /tmp/recording.txt)" + exit 0 + fi +} + +wf-recorder_check + +SCREEN=$(echo "$(hyprctl monitors | awk '/^Monitor/ {print $2} END { print "selection" }')" | rofi -dmenu -theme ~/.config/rofi/style.rasi) + +AUDIO=$(echo "$(pactl list sources | grep Name | grep -v easyeffects | awk -F ": " '{print $2}' | awk '{$1=$1};1')" | rofi -dmenu -theme ~/.config/rofi/style.rasi) + +VID="$HOME/Videos/Escritorio/$(date +%Y-%m-%d-%s).mp4" + +if [ "$SCREEN" = "selection" ]; then + echo "$VID" >/tmp/recording.txt + sleep 1 + wf-recorder -c hevc_vaapi --audio="$AUDIO" -d /dev/dri/renderD128 -g "$(slurp)" -f "$VID" &>/dev/null & + while pgrep -x slurp >/dev/null; do + sleep 1 + done + notify-send "Recording started" "Selection\nAudio: $AUDIO" + pkill -RTMIN+8 waybar +elif [ -n "$SCREEN" ]; then + echo "$VID" >/tmp/recording.txt + sleep 1 + wf-recorder -c hevc_vaapi --audio="$AUDIO" -d /dev/dri/renderD128 -o "$SCREEN" -f "$VID" &>/dev/null & + notify-send "Recording started" "Screen: $SCREEN\nAudio: $AUDIO" + pkill -RTMIN+8 waybar +fi diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc index 1987b300..3a3be1b5 100644 --- a/.config/waybar/config.jsonc +++ b/.config/waybar/config.jsonc @@ -10,7 +10,12 @@ "margin-left": 17, "margin-bottom": 0, "margin-right": 17, - "modules-left": ["custom/arch", "hyprland/workspaces", "cava"], + "modules-left": [ + "custom/arch", + "hyprland/workspaces", + "cava", + "custom/wf-recorder" + ], "modules-center": ["custom/music"], "modules-right": [ "custom/updates", @@ -20,6 +25,15 @@ "pulseaudio", "custom/notifications" ], + "custom/wf-recorder": { + "format": "{}", + "interval": "once", + "exec": "echo ''", + "tooltip": "false", + "exec-if": "pgrep 'wf-recorder'", + "on-click": "exec $HOME/.config/hypr/scripts/rofi/recording", + "signal": 8 + }, "hyprland/window": { "format": "{}", "max-length": 50, @@ -51,16 +65,6 @@ "return-type": "json", "on-click": "xdg-open https://www.eltiempo.es/alicante.html" }, - "custom/updates": { - "format": "{} {icon}", - "return-type": "json", - "format-icons": { - "has-updates": "󱍷", - "updated": "󰂪" - }, - "exec-if": "which waybar-module-pacman-updates", - "exec": "waybar-module-pacman-updates" - }, "custom/notifications": { "tooltip": false, "format": "{} {icon}", diff --git a/.config/waybar/style.css b/.config/waybar/style.css index 0d843ee0..6072d550 100644 --- a/.config/waybar/style.css +++ b/.config/waybar/style.css @@ -20,7 +20,7 @@ #custom-fans, #clock, #idle_inhibitor, -#language, +#custom-wf-recorder, #pulseaudio, #backlight, #battery, @@ -166,6 +166,10 @@ window#waybar.hidden { color: #8bd5ca; } +#custom-wf-recorder { + color: #ed8796; +} + #custom-gpu-temp { background-color: #24273a; color: #f5a97f;