aboutsummaryrefslogtreecommitdiff
path: root/wmutils/bin/group
diff options
context:
space:
mode:
authorxero <x@xero.nu>2017-01-22 23:22:55 -0500
committerxero <x@xero.nu>2017-01-22 23:22:55 -0500
commit5a4d4a06a287985fbf5b458056881d3d0a0c71aa (patch)
tree0daa8de87d60c396ca3dbadccbdfe735fc5f72d8 /wmutils/bin/group
parent4d6c6b497c3e4d5d6bd4e7728f42303f23120f27 (diff)
downloaddotfiles_ascii-5a4d4a06a287985fbf5b458056881d3d0a0c71aa.tar.xz
dotfiles_ascii-5a4d4a06a287985fbf5b458056881d3d0a0c71aa.zip
add wmutils setup
Diffstat (limited to 'wmutils/bin/group')
-rwxr-xr-xwmutils/bin/group105
1 files changed, 105 insertions, 0 deletions
diff --git a/wmutils/bin/group b/wmutils/bin/group
new file mode 100755
index 0000000..0d105dc
--- /dev/null
+++ b/wmutils/bin/group
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# wmg by:
+#
+# ▓█████▄ ▄████▄ ▄▄▄ ▄▄▄█████▓
+# ▒██▀ ██▌▒██▀ ▀█ ▒████▄ ▓ ██▒ ▓▒
+# ░██ █▌▒▓█ ▄ ▒██ ▀█▄ ▒ ▓██░ ▒░
+# ░▓█▄ ▌▒▓▓▄ ▄██▒░██▄▄▄▄██░ ▓██▓ ░
+# ░▒████▓ ▒ ▓███▀ ░ ▓█ ▓██▒ ▒██▒ ░
+# ▒▒▓ ▒ ░ ░▒ ▒ ░ ▒▒ ▓▒█░ ▒ ░░
+# ░ ▒ ▒ ░ ▒ ▒ ▒▒ ░ ░
+# ░ ░ ░ ░ ░ ▒ ░
+# ░ ░ ░ ░ ░
+# ░ ░
+
+GRP_DIR="/tmp/wmutils/groups"
+USE_FIFO=yes
+
+setup() {
+ [ -d "$GRP_DIR" ] || mkdir -p $GRP_DIR
+ if [ -n "$USE_FIFO" ]
+ then
+ [ -p "$GRP_DIR/.fifo" ] || mkfifo $GRP_DIR/.fifo
+ fi
+}
+
+sed_apply() {
+ TMP=`mktemp /tmp/grp.XXXXXX`
+ sed $1 < $2 > $TMP && mv $TMP $2 || rm $TMP
+ [ -n "$DEBUG" ] && echo "sed $1 < $2 > $TMP && mv $TMP $2 || rm $TMP"
+}
+
+pop() {
+ sed_apply "/$1/d" $2
+}
+
+push() {
+ echo $1 >> $GRP_DIR/$2
+}
+
+view() {
+ while read WID
+ do mapw -m $WID
+ done < $GRP_DIR/$1
+}
+
+hide() {
+ while read WID
+ do mapw -u $WID
+ done < $GRP_DIR/$1
+}
+
+pop_from_all() {
+ for GRP in $GRP_DIR/*
+ do
+ pop $1 $GRP
+ done
+}
+
+case $1 in
+view)
+ setup
+ if [ -f "$GRP_DIR/$2" ]
+ then
+ for GRP in $GRP_DIR/*
+ do hide `basename $GRP`
+ done
+ view $2
+ else
+ echo "group does not exist"
+ exit 1
+ fi
+
+ # customize your fifo printing here
+ if [ -n "$USE_FIFO" ]
+ then
+ for GRP in $GRP_DIR/*
+ do
+ GRP_BASE="`basename $GRP`"
+ GRP_NUM=`wc -l < $GRP | tr -cd '[:digit:]'`
+ [ $GRP_NUM -ne 0 ] && printf '^fg(#888)' || printf '^fg(#555)'
+ [ $GRP_BASE -eq $2 ] && printf '^fg(orange)<'
+ printf "$GRP_BASE^fg()"
+ [ $GRP_BASE -eq $2 ] && printf '>^fg()'
+ done > $GRP_DIR/.fifo
+ echo >> $GRP_DIR/.fifo
+ fi
+
+ ;;
+hide)
+ setup
+ hide $2
+ ;;
+add)
+ setup
+ pop_from_all $2
+ push $2 $3
+ hide $3
+ view $3
+ ;;
+remove)
+ setup
+ pop_from_all $2
+ ;;
+esac