~tardypad/dotfiles

ref: 00c0c349a1b8960152233f11caa9ea1a40e395a3 dotfiles/files/scripts/shell/weechat-fifo -rwxr-xr-x 508 bytes
00c0c349 — Damien Tardy-Panis Add presentation mode to mako to hide notifications 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

init_variables() {
  COMMAND=${0##*/}

  FIFO_FILE="${XDG_RUNTIME_DIR:-/tmp}/weechat/weechat_fifo"

  BUFFER=
}

parse_command_line() {
  BUFFER=$1
}

validate_command_line() {
  if [ ! -p "${FIFO_FILE}" ]; then
    exit_error "FIFO file not present"
  fi
}

exit_error() {
  [ -z "$1" ] || echo "${COMMAND}: $1"
  exit 1
} >&2

fifo_send() {
  while read -r LINE; do
    echo "${BUFFER} *${LINE}" > "${FIFO_FILE}"
  done
}

init_variables
parse_command_line "$@"
validate_command_line

fifo_send