Commits

Anonymous committed e31d01d

add first attempt at pcw_notify.sh
make extras/ directory for all these scripts

Comments (0)

Files changed (4)

  * all three steps in a script, have fun! (and you can add the color too if you
  * want)
  * char *cmd[] = { "urxvt", "-embed", getenv("pcw_window_id"), "-title", path, "-e", "srw", "-p", prompt, "cw", out, in, NULL };
+ *
+ * Try this command to write notifications to dzen. Clickin on a specific
+ * notification in dzen will then spawn a terminal for you on that channel.
+ * NOTE: alpha quality
+ * char *cmd[] = { "pcw_notify.sh", path, nick, NULL };
  */
 
 /* vim: set ts=4 sw=4 noexpandtab: */

cw_color.sh

-#!/bin/sh
-# Make sure to change NICK to your correct nick and feel free to change the formatting to your liking
-#
-
-NICK="$USER"
-
-reset="$(tput sgr0)"
-
-bold="$(tput bold)"
-dim="$(tput dim)"
-under="$(tput smul)"
-ununder="$(tput rmul)"
-blink="$(tput blink)"
-rev="$(tput rev)"
-invis="$(tput invis)"
-
-black="$(tput setaf 0)"
-red="$(tput setaf 1)"
-green="$(tput setaf 2)"
-yellow="$(tput setaf 3)"
-blue="$(tput setaf 4)"
-magenta="$(tput setaf 5)"
-cyan="$(tput setaf 6)"
-white="$(tput setaf 7)"
-
-bg_black="$(tput setab 0)"
-bg_red="$(tput setab 1)"
-bg_green="$(tput setab 2)"
-bg_yellow="$(tput setab 3)"
-bg_blue="$(tput setab 4)"
-bg_magenta="$(tput setab 5)"
-bg_cyan="$(tput setab 6)"
-bg_white="$(tput setab 7)"
-
-if [ $# -eq 3 -a -n "$3" ]; then
-    NICK="$3"
-fi
-
-cw "$1" "$2" | sed -e "s/^\([-0-9]\{10,10\}\) \([:0-9]\{5,5\}\) <\([^>]*\)>/${yellow}\1 ${green}\2${reset} <${cyan}\3${reset}>/" \
-                   -e "s/^\([-0-9]\{10,10\}\) \([:0-9]\{5,5\}\) \(-!-\)/${yellow}\1 ${green}\2${reset} ${magenta}\3${reset}/" \
-                   -e "s/^\([-0-9]\{10,10\}\) \([:0-9]\{5,5\}\)/${yellow}\1 ${green}\2${reset}/" \
-                   -e "s/$NICK/\a${red}&${reset}/g" 

extras/cw_color.sh

+#!/bin/sh
+# Make sure to change NICK to your correct nick and feel free to change the formatting to your liking
+#
+
+NICK="$USER"
+
+reset="$(tput sgr0)"
+
+bold="$(tput bold)"
+dim="$(tput dim)"
+under="$(tput smul)"
+ununder="$(tput rmul)"
+blink="$(tput blink)"
+rev="$(tput rev)"
+invis="$(tput invis)"
+
+black="$(tput setaf 0)"
+red="$(tput setaf 1)"
+green="$(tput setaf 2)"
+yellow="$(tput setaf 3)"
+blue="$(tput setaf 4)"
+magenta="$(tput setaf 5)"
+cyan="$(tput setaf 6)"
+white="$(tput setaf 7)"
+
+bg_black="$(tput setab 0)"
+bg_red="$(tput setab 1)"
+bg_green="$(tput setab 2)"
+bg_yellow="$(tput setab 3)"
+bg_blue="$(tput setab 4)"
+bg_magenta="$(tput setab 5)"
+bg_cyan="$(tput setab 6)"
+bg_white="$(tput setab 7)"
+
+if [ $# -eq 3 -a -n "$3" ]; then
+    NICK="$3"
+fi
+
+cw "$1" "$2" | sed -e "s/^\([-0-9]\{10,10\}\) \([:0-9]\{5,5\}\) <\([^>]*\)>/${yellow}\1 ${green}\2${reset} <${cyan}\3${reset}>/" \
+                   -e "s/^\([-0-9]\{10,10\}\) \([:0-9]\{5,5\}\) \(-!-\)/${yellow}\1 ${green}\2${reset} ${magenta}\3${reset}/" \
+                   -e "s/^\([-0-9]\{10,10\}\) \([:0-9]\{5,5\}\)/${yellow}\1 ${green}\2${reset}/" \
+                   -e "s/$NICK/\a${red}&${reset}/g" 

extras/pcw_notify.sh

+#!/bin/bash
+FILE="$HOME/.pcw_notify"
+CHAN="$1"
+NICK="$2"
+
+[ -f "$FILE" ] || printf "\n\n\n\n\n\n\n\n\n\n\n" > "$FILE" || exit 2
+
+if ! pgrep -lf pcw_notify_dzen > /dev/null 2>&1; then
+	while true; do
+		{ tail "$FILE"; tail -n 1 "$FILE"; } | tac
+		sleep 1
+	done | dzen2 -m -e 'entertitle=uncollapse,grabkeys;enterslave=grabkeys;leaveslave=collapse,ungrabkeys;button1=menuprint;button2=togglestick;button3=exit:13;button4=scrollup;button5=scrolldown;key_Escape=ungrabkeys,exit' -x 1000 -w 920 -l 10 -u -h 14 -title-name "pcw_notify_dzen" -fg '#b20033' -bg black -fn "monospace-10" | while read line; do
+		path="$(echo "$line" | cut -d '|' -f 1 | sed "s/ *$//")"
+		channel="$(basename "$path")"
+		urxvt -title "$path" -e srw -p "$channel> " cw_color.sh "$path/out" "$path/in" "$NICK" &
+	done > /dev/null 2>&1 &
+fi
+
+line="$(printf "%-30s" "$CHAN") | $(tail -n 1 "$CHAN/out")"
+echo "$line" >> "$FILE"