forked from erlehmann/uii
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuii
executable file
·37 lines (29 loc) · 1.17 KB
/
uii
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
37
#!/bin/sh
IRC="${XDG_DATA_HOME:-$HOME/.local/share}/uii/logs"
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/uii"
test -d "$CONFIG" || mkdir -p "$CONFIG"
LOGINS="$CONFIG"/logins
test -f "$LOGIN" || touch "$LOGINS"
CONFIGUSER=`cat "$LOGINS" | grep "$1" | cut -f2 -d' '`
CONFIGPASS=`cat "$LOGINS" | grep "$1" | cut -f3 -d' '`
PASS="${4-${CONFIGPASS-0000}}"
IN="$IRC/$1/in"
PIDS=`pgrep -x ii | sed 's/^/p/'`
(test -e "$IN" && lsof -Fc "$IN" | grep -q "$PIDS") || ( \
ping -c1 -w10 "$1" || exit
test -d "$IRC" || mkdir -p "$IRC"
nohup ii -i "$IRC" -s "$1" \
-n "${3-${CONFIGUSER-$USER}}" \
-k PASS > /dev/null 2>&1 &
inotifywait "$IRC/$1/out" -e modify
) || exit
pgrep iiinotify > /dev/null 2>&1 || nohup iiinotify "$IRC" > /dev/null 2>&1 &
(test -n "$2" && lsof -Fc "$IRC/$1/$2/in" | grep -q "$PIDS" ) || ( \
echo "/j $2 \a" > "$IN"
touch "$IRC/$1/$2/out"
)
echo "$2" | head -c1 | grep -q "[#&!+]" &&
HIGHLIGHT="${3-${CONFIGUSER-$USER}}" || HIGHLIGHT="<$2>"
T=`tput tsl -T xterm+sl`; F=`tput fsl -T xterm+sl`; D=`tput dsl -T xterm+sl`
trap 'echo -n "$D"; exit 0' 0 2 11 15; echo -n "$T$2 @ $1$F"
uiipager "$IRC/$1/$2/out" "$IRC/$1/$2/in" "$HIGHLIGHT" "$2"