Skip to content

Commit

Permalink
rename n - network to s - server
Browse files Browse the repository at this point in the history
  • Loading branch information
c00kiemon5ter committed Jan 11, 2013
1 parent abb584d commit 4c53a70
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions iii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

: "${u:=$USER}" # the user's nickname
: "${i:=$HOME/irc}" # root irc dir
: "${n:=irc.freenode.net}" # network
: "${c:=""}" # channel - empty for network (default)
: "${s:=irc.freenode.net}" # server
: "${c:=""}" # channel
: "${m:=12}" # max nick lenght
: "${h:=20}" # lines from history
: "${p:=1}" # pretify - colors and stuff
: "${l:=3}" # highlight color
: "${f:=120}" # max characters per mesg - fold after limit

[ "$1" != "-r" ] && exec rlwrap -a -s 0 -r -b "(){}[],+=^#;|&%" -S "${c:-$n}> " -pgreen "$0" -r
[ "$1" != '-r' ] && exec rlwrap -a -s 0 -r -b "(){}[],+=^#;|&%" -S "${c:-$s}> " -pgreen "$0" -r

blk="$(tput setaf 6)" # cyan \003[36m
grn="$(tput setaf 2)" # green \003[31m
Expand All @@ -25,20 +25,20 @@ rst="$(tput sgr0)" # reset \003[0m -- reset

bar="------------------------------------------------------------" # trackbar

[ -p "$i/$n/$c/in" ] || exit 1
[ -e "$i/$n/$c/out" ] || { touch "$i/$n/$c/out" || exit 1; }
[ -p "$i/$s/$c/in" ] || exit 1
[ -e "$i/$s/$c/out" ] || { touch "$i/$s/$c/out" || exit 1; }

mark() {
tail -n1 "$i/$n/$c/out" | {
tail -n1 "$i/$s/$c/out" | {
read -r date time nick mesg
[ "$mesg" != "$bar" ] && printf '%s -!- %.*s\n' "$(date +"%F %R")" "$f" "${bar}${bar}${bar}" >>"$i/$n/$c/out"
[ "$mesg" != "$bar" ] && printf '%s -!- %.*s\n' "$(date +"%F %R")" "$f" "${bar}${bar}${bar}" >>"$i/$s/$c/out"
}
}

trap "stty '$(stty -g)'; kill -TERM 0" EXIT
stty -echonl -echo

tail -f -n "$h" "$i/$n/$c/out" | while IFS= read -r mesg
tail -f -n "$h" "$i/$s/$c/out" | while IFS= read -r mesg
do
date="${mesg%% *}" mesg="${mesg#* }"
time="${mesg%% *}" mesg="${mesg#* }"
Expand Down Expand Up @@ -141,5 +141,5 @@ while IFS= read -r line; do
;;
esac
printf '%s\n' "$line"
done >"$i/$n/$c/in"
done >"$i/$s/$c/in"

20 changes: 10 additions & 10 deletions notifiii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ inotifywait -m --exclude "/in$" --format "%w %f" -e modify -r "$i" | \
nickname="$(awk '{ n=$3 } END { print n }' "$p$f")"
[ "$nickname" = '<-!->' -o "$nickname" = '-!-' ] && continue

# break path down # p=/ircdir/network/channel/
p="${p#$i}" # p=/network/channel/
p="${p%/*}" # p=/network/channel
# break path down # p=/ircdir/server/channel/
p="${p#$i}" # p=/server/channel/
p="${p%/*}" # p=/server/channel
c="${p##*/}" # c=channel
p="${p%/*}" # p=/network
n="${p##*/}" # n=network
# if network is empty then action is on the network view
[ -z "$n" ] && n="$c" c=""
p="${p%/*}" # p=/server
s="${p##*/}" # s=server
# if server is empty then action is on the server view
[ -z "$s" ] && s="$c" c=""

opts="h=50 i="$i" n="$n" c="$c""
opts="h=50 i="$i" s="$s" c="$c""

## spawn a new tmux window named <channel> in a tmux session named IRC
env $opts tmiii.sh

# ## spawn a new urxvt terminal with IRC-<channel> class name
# if ! xwininfo -root -children | sed -n 's,^ \+\(0x[^ ]\+\).*("\([^"]*\)" "\([^"]*\)").*\+,"\1 \2 \3",p' | grep "${c:-$n} URxvt"
# then env $opts urxvtc -name "IRC-${c:-$n}" -e iii.sh
# if ! xwininfo -root -children | sed -n 's,^ \+\(0x[^ ]\+\).*("\([^"]*\)" "\([^"]*\)").*\+,"\1 \2 \3",p' | grep "${c:-$s} URxvt"
# then env $opts urxvtc -name "IRC-${c:-$s}" -e iii.sh
# fi
done

8 changes: 4 additions & 4 deletions tmiii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
# accepts all env vars iii.sh accepts plus 't' which sets the terminal

## collect options from env - all opts to iii.sh should be set here
opts="TERM="${t:-rxvt-unicode}" m="$m" h="$h" p=$p u="$u" l="$l" i="$i" n="$n" c="$c""
opts="TERM="${t:-rxvt-unicode}" m="$m" h="$h" p=$p u="$u" l="$l" i="$i" s="$s" c="$c""

## spawn a new tmux window named <channel> in a tmux session named IRC
if ! tmux list-sessions | awk -v r=1 '$1 == "IRC:" { exit r=0 } END { exit r }'
then urxvtc -name "IRC-tmux" -e tmux new-session -s IRC -n "${c:-$n}" "$opts iii.sh"
elif ! tmux list-windows -t IRC | awk -v r=1 -v m="${c:-$n}" '$2 ~ "^"m"[*!-]*$" { print $2; exit r=0 } END { exit r }'
then tmux new-window -t IRC -n "${c:-$n}" -d "$opts iii.sh"
then urxvtc -name "IRC-tmux" -e tmux new-session -s IRC -n "${c:-$s}" "$opts iii.sh"
elif ! tmux list-windows -t IRC | awk -v r=1 -v m="${c:-$s}" '$2 ~ "^"m"[*!-]*$" { print $2; exit r=0 } END { exit r }'
then tmux new-window -t IRC -n "${c:-$s}" -d "$opts iii.sh"
fi

0 comments on commit 4c53a70

Please sign in to comment.