2022-10-08 13:17:32 +02:00
#!/bin/sh
# dfmpeg module for status/stellar
2022-11-27 01:12:14 +01:00
command -v speedwm-dfmpeg > /dev/null || exit
2022-10-08 13:17:32 +02:00
2022-11-27 01:12:14 +01:00
# load config
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
2022-10-08 18:07:28 +02:00
2022-10-21 13:35:02 +02:00
# click
CLICK() {
# values
2022-11-27 01:12:14 +01:00
DFMPEG_STOP_CMD="speedwm-dfmpeg -s" # command to run to stop recording
2022-10-21 13:35:02 +02:00
ICON="$ITEM7_ICON"
2022-11-27 01:12:14 +01:00
DFMPEG_ENCODING="Not encoding" # placeholder, we can override this later
[ -e "/tmp/outputfilename" ] && DFMPEG_REC_PATH="$(cat /tmp/outputfilename)"
[ -e "/tmp/speedwm-button" ] && BUTTON="$(cat /tmp/speedwm-button)"
[ -z "$TERMINAL" ] && TERMINAL=st
2022-10-21 13:35:02 +02:00
2022-11-27 01:12:14 +01:00
pgrep -x ffmpeg > /dev/null || return
2022-10-21 13:35:02 +02:00
case "$BUTTON" in
"3") speedwm-dfmpeg ; exit ;;
2022-11-27 01:12:14 +01:00
"2") $DFMPEG_STOP_CMD ; exit ;;
2022-10-21 13:35:02 +02:00
esac
2022-11-27 01:12:14 +01:00
# check a few things
[ -e "/tmp/isaudio" ] && DFMPEG_AUDIO="Recording audio" || DFMPEG_AUDIO="Not recording audio"
[ -e "/tmp/isencoding" ] && DFMPEG_ENCODING="Encoding"
[ -e "/tmp/encoding-codec" ] && DFMPEG_ENCODING="Encoding with $(cat /tmp/encoding-codec)"
[ ! -z "$ICON" ] && ICONSPACING=" " # one character spacing
2022-10-21 13:35:02 +02:00
# 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"
2022-11-27 01:12:14 +01:00
# some output
2022-10-21 13:35:02 +02:00
echo "Notification sent successfully!"
echo "INFO: $FULL_RECSTATUS"
2022-11-27 01:12:14 +01:00
return
2022-10-21 13:35:02 +02:00
}
2022-11-27 01:12:14 +01:00
command -v notify-send > /dev/null && SEND_NOTIF || echo "FATAL: libnotify not installed, can't send notification."
return
2022-10-08 13:17:32 +02:00
}
2022-10-21 13:35:02 +02:00
# information itself
PRINT() {
2022-11-27 01:12:14 +01:00
# check if we're recording with dfmpeg or not
[ "$ENABLE_ITEM7" = "true" ] && [ -e "/tmp/dfmpeg-recording" ] && echo "$ITEM7_SEPARATOR $ITEM7_ICON $ITEM7_RECORDING_TEXT"
2022-10-21 13:35:02 +02:00
}
2022-10-08 13:17:32 +02:00
2022-10-21 13:35:02 +02:00
# argument 1
2022-11-27 01:12:14 +01:00
case "$1" in
2022-10-21 13:35:02 +02:00
"") CLICK ;;
2022-11-26 19:16:22 +01:00
"--print-file") PRINT > /tmp/module_dfmpeg ;;
"--print") PRINT ;;
2022-10-21 13:35:02 +02:00
"--click") CLICK ;;
esac