From 44885fa01e6348f211eac0cfed47d3e237410286 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Jan 2013 17:42:06 -0500 Subject: mv .wmii .config/wmii; ln -s .config/wmii .wmii --- .wmii/util.sh | 128 ---------------------------------------------------------- 1 file changed, 128 deletions(-) delete mode 100644 .wmii/util.sh (limited to '.wmii/util.sh') diff --git a/.wmii/util.sh b/.wmii/util.sh deleted file mode 100644 index 43d7d4a..0000000 --- a/.wmii/util.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash - -# I moved "fixes" into a separate file because it isn't so much configuration... -. "$HOME/.wmii/fixes.sh" - -################################################################################ -# Added shell features # -################################################################################ - -## -# Usage: dquote STRING -# Safely double-quotes a string. -# It escapes ways to execute code, but not variables. -## -dquote() { - str=$1 - str="${str//\\/\\\\}" # backslash - str="${str//\"/\\\"}" # dquote - str="${str//\$(/\\\$(}" # $(...) - str="${str//\`/\\\`}" # backtick - printf '"%s"\n' "$str" -} - -## -# Usage: expand_variables -# Expands variables read from /dev/stdin -## -expand_variables() { - while read; do - eval printf "'%s\n'" "$(dquote "$REPLY")" - done -} - -is_mounted() { - dir="$(readlink -m $1)" - mntpnt="$(cut -d' ' -f2 /proc/mounts|grep -- "$dir")" - [[ $dir = "$mntpnt" ]] - return $? -} - -################################################################################ -# PATH manipulation # -################################################################################ - -## -# Usage: path_ls PATH -# List executables in PATH (PATH is delimited by `:') -## -path_ls() { - dirs="`echo "$@"|sed 'y/:/ /'`" - find -L $dirs -maxdepth 1 -type f -executable -printf '%f\n' 2>/dev/null | sort -u -} - -## -# Usage: path_which PATH PROGRAM -# Find the full path of PROGRAM by searching PATH -## -path_which() { - mypath=$1 - prog=$2 - which=`which which` - PATH="$mypath" "$which" -- "$prog" 2>/dev/null -} - -################################################################################ -# wmii convenience functions # -################################################################################ - -## -# Usage: lstags -# Lists wmii tags -## -lstags() { - ls $WMII_DIR/tag | sed -e 's@/@@' -e '/^sel$/d' -} - -################################################################################ -# X11 functions # -################################################################################ - -## -# Usage: connected_to_x_server -# Return status indicates whether there is an X server at $DISPLAY -## -connected_to_x_server() { - xdpyinfo &>/dev/null - return $? -} - -################################################################################ -# My wmii configuration # -################################################################################ - -## -# Usage: scansection [SECTION] -# Reads the doc comments from a section of wmiirc. -# If SECTION is not given, it reads all doc comments. -## -scansection() { - file=`conffile config.sh` - sec=$1 - tmp=`mktemp` - # Isolate the sections we want. - if [ -n "$sec" ]; then - # Find the section - < "$file" sed -n "/^\s*$sec\s*()/,/##\s*End $sec/p" | sed '1d;$d'> $tmp - else - # Remove extra lines that mark the end of a section - < "$file" sed "/\s*}\s*##\s*End\s/d" > $tmp - fi - < $tmp sed -n '/##/p' | while read; do - var="$(echo "$REPLY" | sed -nr 's/^\s*(.*)\)\s*##.*/\1/p')" - comment="$(echo "$REPLY" | sed -r 's/.*## ?//')" - if [ -z "$var" ]; then - printf '%s\n' "$comment" - else - printf '\t%s\t%s\n' "$(echo "$var"|expand_variables)" "$comment" - fi - done - rm $tmp -} - -## -# Usage: conffile FILE -## -conffile() { - echo "$HOME/.wmii/$@" -} -- cgit v1.2.3-2-g168b