feat(hypr): recording script

recording script using wf-recorder; also made a module for waybar to show an icon when recording
This commit is contained in:
Sergio Laín 2023-10-09 17:20:06 +02:00
parent b9234e1469
commit e3c0ab94c0
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
4 changed files with 59 additions and 12 deletions

View file

@ -64,6 +64,9 @@ bind=SUPERSHIFT,w,exec, ~/.config/hypr/scripts/rofi/wallpaper_selection
# Keybindings Cheatsheet # Keybindings Cheatsheet
bind=SUPER,i,exec, ~/.config/hypr/scripts/rofi/keybindings bind=SUPER,i,exec, ~/.config/hypr/scripts/rofi/keybindings
# Recording
bind=SUPERSHIFT,r,exec, ~/.config/hypr/scripts/rofi/recording
## Windows ## Windows
## Focusing on windows ## Focusing on windows
bind=SUPER,left,movefocus,l bind=SUPER,left,movefocus,l

View file

@ -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

View file

@ -10,7 +10,12 @@
"margin-left": 17, "margin-left": 17,
"margin-bottom": 0, "margin-bottom": 0,
"margin-right": 17, "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-center": ["custom/music"],
"modules-right": [ "modules-right": [
"custom/updates", "custom/updates",
@ -20,6 +25,15 @@
"pulseaudio", "pulseaudio",
"custom/notifications" "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": { "hyprland/window": {
"format": "{}", "format": "{}",
"max-length": 50, "max-length": 50,
@ -51,16 +65,6 @@
"return-type": "json", "return-type": "json",
"on-click": "xdg-open https://www.eltiempo.es/alicante.html" "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": { "custom/notifications": {
"tooltip": false, "tooltip": false,
"format": "{} {icon}", "format": "{} {icon}",

View file

@ -20,7 +20,7 @@
#custom-fans, #custom-fans,
#clock, #clock,
#idle_inhibitor, #idle_inhibitor,
#language, #custom-wf-recorder,
#pulseaudio, #pulseaudio,
#backlight, #backlight,
#battery, #battery,
@ -166,6 +166,10 @@ window#waybar.hidden {
color: #8bd5ca; color: #8bd5ca;
} }
#custom-wf-recorder {
color: #ed8796;
}
#custom-gpu-temp { #custom-gpu-temp {
background-color: #24273a; background-color: #24273a;
color: #f5a97f; color: #f5a97f;