vivien / i3blocks-contrib

Official repository for community contributed blocklets

Home Page:https://github.com/vivien/i3blocks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A gif screen recorder

karta0807913 opened this issue · comments

Hi, I made a "block" to record the screen as a GIF.
But there are some problems.

Expected behavior

copy the result file (or filename) to clipboard

Actual behavior

xclip keep working in the background, blocking the entire i3.

bash

#!/bin/sh

ROOT="$(dirname "$0")"
RECORD_TMP_FILE="${ROOT}/.recording"

if [ -f "${RECORD_TMP_FILE}" ]; then
    read filename < ${RECORD_TMP_FILE}
    rm "${RECORD_TMP_FILE}"
    # remove this line to solve the problem
    echo ${filename} | xclip -selection clipboard
    notify-send "Record Done" "Screen record filename is in the clipboard"
    echo "⭕ ready"
elif [ ! "$BLOCK_BUTTON" = "1" ]; then
    # notify-send "Record Message" "Left Button to start record"
    echo "⭕ ready"
else
    filename="$(mktemp)"
    position="$(slop -o -f "--x=%x --y=%y --width=%w --height=%h")"
    if [ "$position" = "" ]; then
        echo "⭕ ready"
        rm "$filename"
    else
        echo $filename > "${RECORD_TMP_FILE}"
        nohup byzanz-record ${position} -e "tail --follow=name ${RECORD_TMP_FILE}" $filename >/dev/null 2>&1 &
        echo "🔴 recording (click to stop)"
    fi
fi

config

[screen_gif]
interval=once

Can anyone give me some suggestions?
Thanks a lot.

Let the recorded file be opened in the browser to solve this problem