Compare commits

...

3 Commits

Author SHA1 Message Date
48ece24a4d Change to wayland-recorder 2025-05-17 13:26:34 +02:00
ddce9e5d40 Add wayland-recorder 2025-05-17 13:25:45 +02:00
94a0492e6d Fix open screenshot with ristretto 2025-05-17 13:25:21 +02:00
3 changed files with 86 additions and 5 deletions

View File

@ -96,7 +96,7 @@ bindsym $mod+n exec --no-startup-id pcmanfm
bindsym $mod+p exec --no-startup-id ~/.config/sway/wofi/wofi_run bindsym $mod+p exec --no-startup-id ~/.config/sway/wofi/wofi_run
bindsym $mod+g exec --no-startup-id geany bindsym $mod+g exec --no-startup-id geany
bindsym $mod+m exec --no-startup-id telegram bindsym $mod+m exec --no-startup-id telegram
bindsym $mod+z exec --no-startup-id kitty -e wf-recorder bindsym $mod+z exec --no-startup-id ~/.config/sway/wayland-recorder
#bindsym $mod+u exec --no-startup-id xterm #bindsym $mod+u exec --no-startup-id xterm
bindsym $mod+u exec --no-startup-id ~/.config/sway/xterm-wayland bindsym $mod+u exec --no-startup-id ~/.config/sway/xterm-wayland
bindsym $mod+t exec --no-startup-id ~/.config/sway/wayland-screenshot bindsym $mod+t exec --no-startup-id ~/.config/sway/wayland-screenshot

79
.config/sway/wayland-recorder Executable file
View File

@ -0,0 +1,79 @@
#!/bin/bash
export GTK_THEME=Arc-Dark
FILEDIR=~/Recordings
OPTION=()
mkdir -p $FILEDIR
#audio_sources=$(pw-dump | jq -r '.[] | select(.type == "source") | .name' | tr '\n' '|')
audio_sources=$(pactl list sources short | awk '{print $2}' | tr '\n' '|')
audio_sources="none|default|$audio_sources"
values=$(zenity \
--title=wayland-recorder \
--text="Option" \
--forms \
--add-combo="Mode" \
--combo-values="Specific area|Specific window|All screen" \
--add-entry="time to wait[default: 0s]" \
--add-combo="Audio source" \
--combo-values="$audio_sources" \
)
result=$?
mode=$(echo $values | cut -d '|' -f 1)
wait=$(echo $values | cut -d '|' -f 2)
audio_source=$(echo $values | cut -d '|' -f 3)
if [ "$result" -eq 1 ]; then # select cancel
echo "canceling"
exit
fi
if [ -z "$mode" ]; then # select nothing
echo "mode is null"
zenity \
--title=wayland-recorder \
--width=200 \
--warning \
--text="Specific area"
exit
fi
if [ ! -z "$wait" ]; then
sleep $wait
fi
if [ "$mode" == "All screen" ]; then # select All screen
GEO=""
elif [ "$mode" == "Specific window" ]; then # select specify window
GEO="$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)"
elif [ "$mode" == "Specific area" ]; then # select specify area
GEO="$(slurp)"
else # error
echo $mode
exit 1
fi
# Recording
name_record="$FILEDIR/Recording_$(date +%F_%H.%M.%S).mp4"
if [ -z "$GEO" ]; then
if [ "$audio_source" != "none" ]; then
foot -T wf-recorder wf-recorder -f "$name_record" -a"$audio_source"
else
foot -T wf-recorder wf-recorder -f "$name_record"
fi
else
if [ "$audio_source" != "none" ]; then
foot -T wf-recorder wf-recorder -g "$GEO" -f "$name_record" -a"$audio_source"
else
foot -T wf-recorder wf-recorder -g "$GEO" -f "$name_record"
fi
fi
# Play recording
if [ -f /usr/bin/mpv ]; then
mpv "$name_record"
fi

View File

@ -66,14 +66,16 @@ if [ -z "$clipboard" ] || [ "$clipboard" == yes ];then
fi fi
else else
if [ -z "$GEO" ]; then if [ -z "$GEO" ]; then
grim $OPTION $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png name_screenshot="$FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png"
grim $OPTION "$name_screenshot"
if [ -f /usr/bin/ristretto ] ; then if [ -f /usr/bin/ristretto ] ; then
ristretto $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png ristretto "$name_screenshot"
fi fi
else else
grim $OPTION -g "$GEO" $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png name_screenshot="$FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png"
grim $OPTION -g "$GEO" "$name_screenshot"
if [ -f /usr/bin/ristretto ] ; then if [ -f /usr/bin/ristretto ] ; then
ristretto $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png ristretto "$name_screenshot"
fi fi
fi fi
fi fi