#!/bin/sh # dfmpeg module for status/stellar # load config . $HOME/.config/speedwm/statusrc BINDIR="$(dirname $(command -v speedwm_status))/" ARG1="$1" # click CLICK() { # values DFMPEG_CMD="speedwm-dfmpeg -s" DFMPEG_REC_PATH="$(cat /tmp/outputfilename)" ICON="$ITEM7_ICON" BUTTON="$(cat /tmp/speedwm-button)" pgrep -x ffmpeg || exit 1 case "$TERMINAL" in "") TERMINAL=st esac case "$BUTTON" in "3") speedwm-dfmpeg ; exit ;; "2") $DFMPEG_CMD ; exit ;; esac # check if recording audio if [ -e "/tmp/isaudio" ]; then DFMPEG_AUDIO="Recording audio" else DFMPEG_AUDIO="Not recording audio" fi # check if encoding if [ -e "/tmp/isencoding" ]; then if [ -e "/tmp/encoding-codec" ]; then DFMPEG_ENCODING="Encoding with $(cat /tmp/encoding-codec)" else DFMPEG_ENCODING="Encoding" fi else DFMPEG_ENCODING="Not encoding" fi # no spacing if there's no icon if [ "$ICON" != "" ]; then ICONSPACING=" " # one character spacing fi # send the notification SEND_NOTIF() { FULL_RECSTATUS="$(printf "${ICON}${ICONSPACING}Recording video $DFMPEG_REC_PATH\n${DFMPEG_AUDIO}, ${DFMPEG_ENCODING}\nMiddle click to stop recording.")" notify-send "$FULL_RECSTATUS" echo "Notification sent successfully!" echo "INFO: $FULL_RECSTATUS" exit 0 } command -v notify-send > /dev/null && SEND_NOTIF echo "FATAL: libnotify not installed, can't send notification." exit 1 } # information itself PRINT() { # Check if we're recording with dfmpeg or not if [ "$ENABLE_ITEM7" = "true" ]; then if [ -e "/tmp/dfmpeg-recording" ]; then echo "$SEPARATOR $ITEM7_ICON $ITEM7_RECORDING_TEXT" fi fi } # argument 1 case "$ARG1" in "") CLICK ;; "--print") PRINT > /tmp/module_dfmpeg ;; "--click") CLICK ;; esac