summaryrefslogtreecommitdiff
path: root/.wmii-hg
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-10-12 14:48:21 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-10-12 14:48:21 -0400
commit9d689e7d224b5c1ea3ab3018998135979f19c5a9 (patch)
tree3778e974ec6826c253e73642f64d8cb030f135df /.wmii-hg
parent0e2d2d798ff057e6efa9b1a7a918c06aa18a1345 (diff)
add .wmii-hg
Diffstat (limited to '.wmii-hg')
-rwxr-xr-x.wmii-hg/autostart21
-rw-r--r--.wmii-hg/config.sh237
-rw-r--r--.wmii-hg/ctl-init6
-rw-r--r--.wmii-hg/fixes.sh24
-rwxr-xr-x.wmii-hg/help-events3
-rwxr-xr-x.wmii-hg/help-keys3
-rw-r--r--.wmii-hg/include.sh11
-rwxr-xr-x.wmii-hg/quit3
-rwxr-xr-x.wmii-hg/rbar_battery9
-rwxr-xr-x.wmii-hg/rbar_clock9
-rwxr-xr-x.wmii-hg/rbar_cpu12
-rwxr-xr-x.wmii-hg/rbar_wifi9
-rw-r--r--.wmii-hg/rules3
-rw-r--r--.wmii-hg/theme-solarized16
-rw-r--r--.wmii-hg/theme-solarized-dark12
-rw-r--r--.wmii-hg/util.sh128
-rwxr-xr-x.wmii-hg/wmiirc15
17 files changed, 521 insertions, 0 deletions
diff --git a/.wmii-hg/autostart b/.wmii-hg/autostart
new file mode 100755
index 0000000..3f94eff
--- /dev/null
+++ b/.wmii-hg/autostart
@@ -0,0 +1,21 @@
+#!/bin/bash
+. include.sh
+
+# return the number of windows in the current tag
+w() {
+ sed '/^#/d' "${WMII_DIR}/tag/sel/index"|wc -l
+}
+
+# start linphone
+tfe linphone &> /dev/null &
+# wait until linphone starts
+while [[ $(w) < 1 ]]; do
+ sleep 1
+done
+# THEN switch back to the home tag
+echo view 1 >> "${WMII_DIR}/ctl"
+
+# start other services
+daemon unclutter &> /dev/null
+daemon fbpanel &> /dev/null
+daemon notifyd &> /dev/null
diff --git a/.wmii-hg/config.sh b/.wmii-hg/config.sh
new file mode 100644
index 0000000..2eb5f22
--- /dev/null
+++ b/.wmii-hg/config.sh
@@ -0,0 +1,237 @@
+#!/bin/bash
+
+MODKEY=Mod4 # "super"
+UP=p
+DOWN=n
+LEFT=b
+RIGHT=f
+
+HIST="`conffile history`"
+
+# Colors tuples: "<text> <background> <border>"
+. `conffile theme-solarized-dark`
+
+Event() {
+ event=$1; shift;
+ case "$event" in
+ ## Mouse event meanings:
+ ## MouseDown = mouse down
+ ## Click = mouse up
+ ## DND = hover, while dragging something (Drag 'n' Drop)
+ ## The associated mouse button is always "1"
+ ##
+ ## Mouse-button IDs:
+ ## 1 = left
+ ## 2 = middle
+ ## 3 = right
+
+ ## Custom (non-WMII-generated) events
+ WmiircStart) ## No args
+ echo ' ==> Starting wmiirc'
+ is_mounted $WMII_DIR && Event WmiircUnmount
+ Event WmiircMount
+
+ # Configure wmii
+ < "`conffile rules`" expand_variables >> $WMII_DIR/rules
+ < "`conffile ctl-init`" expand_variables >> $WMII_DIR/ctl
+ scansection Key | cut -sf2 >> $WMII_DIR/keys
+ # Configure X11
+ xsetroot -solid "$WMII_BACKGROUND"
+
+ # Run the autostart action
+ Action autostart 2>/dev/null &
+ ;;
+ WmiircQuit) ## No args
+ echo ' ==> Stopping wmiirc'
+ exit;;
+ WmiircMount) ## No args
+ echo " -> Creating mountpoint WMII_DIR=$WMII_DIR..."
+ mkdir -p "$WMII_DIR"
+ echo " -> Mounting WMII_DIR=$WMII_DIR..."
+ 9mount -i "unix!$WMII_NAMESPACE/wmii" "$WMII_DIR";;
+ WmiircUnmount) ## No args
+ echo " -> Unmounting WMII_DIR=$WMII_DIR..."
+ 9umount "$WMII_DIR"
+ echo " -> Removing mountpoint WMII_DIR=$WMII_DIR..."
+ rmdir "$WMII_DIR";;
+ ## WMII-meta events
+ Quit) ## No args
+ echo ' ==> wmii quit: unmounting'
+ trap - EXIT
+ Event WmiircUnmount
+ Event WmiircQuit;;
+ Warning) ## $@=string
+ notify-send "wmii warning: $*";;
+ Key) ## $1=keystroke
+ Key "$@";;
+
+ ## WMII Window management events
+ FocusFloating) ## No args
+ ;;
+ AreaFocus) ## $1=area
+ ;;
+ DestroyArea) ## $1=area
+ ;;
+ ColumnFocus) ## $1=column
+ ;;
+ CreateColumn) ## $1=column
+ ;;
+
+ ## Client events
+ CreateClient) ## $1=client
+ ;;
+ DestroyClient) ## $1=client
+ ;;
+ Urgent) ## $1=client $2=[Manager|Client]
+ ;;
+ NotUrgent) ## $1=client $2=[Manager|Client]
+ ;;
+ ClientMouseDown) ## $1=client $2=button
+ client=$1
+ button=$2
+ case $button in
+ 1) ;;
+ 2) ;;
+ 3)
+ {
+ case `wmii9menu Delete Fullscreen` in
+ Delete)
+ echo kill >> $WMII_DIR/client/$client/ctl;;
+ Fullscreen)
+ echo Fullscreen on >> $WMII_DIR/client/$1/ctl;;
+ esac
+ }& ;;
+ esac;;
+ ClientClick) ## $1=client $2=button
+ ;;
+ Unresponsive) ## $1=client
+ client=$1
+ client_name=`cat $WMII_DIR/client/$client/label`
+ msg="The client \`${client_name}' is not responding."
+ msg+=" What would you like to do?"
+ {
+ resp=$(wihack -transient $client \
+ xmessage -nearmouse -buttons Kill,Wait -print "$msg")
+ if [ "$resp" = Kill ]; then
+ echo slay >> $WMII_DIR/client/$client/ctl
+ fi
+ }& ;;
+ Fullscreen) ## $1=client $2=[on|off]
+ # TODO: hide any clients with the 'panel' class
+ ;;
+
+ ## Tag events
+ CreateTag) ## $1=tag
+ ;;
+ DestroyTag) ## $1=tag
+ ;;
+ FocusTag) ## $1=tag
+ ;;
+ UnfocusTag) ## $1=tag
+ ;;
+ UrgentTag) ## $1=tag $2=[Manager|Client]
+ ;;
+ NotUrgentTag) ## $1=tag $2=[Manager|Client]
+ ;;
+
+ ## LeftBar events (usually tag buttons)
+ LeftBarMouseDown) ## $1=button $2=bar_item
+ ;;
+ LeftBarClick) ## $1=button $2=bar_item
+ ;;
+ LeftMouseDND) ## $1=button $2=bar_item
+ ;;
+
+ ## RightBar events
+ RightBarMouseDown) ## $1=button $2=bar_item
+ ;;
+ RightBarClick) ## $1=button $2=bar_item
+ ;;
+ RightMouseDND) ## $1=button $2=bar_item
+ ;;
+ esac
+} ## End Event
+
+# Key Bindings
+Key() {
+ key=$1
+ case "$key" in
+ ## Moving around
+
+ $MODKEY-$LEFT) ## Select the client to the left
+ echo select left >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-$RIGHT) ## Select the client to the right
+ echo select right >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-$UP) ## Select the client above
+ echo select up >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-$DOWN) ## Select the client below
+ echo select down >> $WMII_DIR/tag/sel/ctl;;
+
+ $MODKEY-space) ## Toggle between floating and managed layers
+ echo select toggle >> $WMII_DIR/tag/sel/ctl;;
+
+ ## Moving clients around
+
+ $MODKEY-Shift-$LEFT) ## Move selected client to the left
+ echo send sel left >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-Shift-$RIGHT) ## Move selected client to the right
+ echo send sel right >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-Shift-$UP) ## Move selected client up
+ echo send sel up >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-Shift-$DOWN) ## Move selected client down
+ echo send sel down >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-Shift-space) ## Toggle selected client between floating and managed layers
+ echo send sel toggle >> $WMII_DIR/tag/sel/ctl;;
+
+ ## Moving through stacks
+ $MODKEY-Control-$UP) ## Select the stack above
+ echo select up stack >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-Control-$DOWN) ## Select the stack below
+ echo select down stack >> $WMII_DIR/tag/sel/ctl;;
+
+ ## Client actions
+ $MODKEY-shift-1) ## Toggle selected client's fullsceen state
+ echo Fullscreen toggle >> $WMII_DIR/client/sel/ctl;;
+ $MODKEY-shift-0) ## Close client
+ echo kill >> $WMII_DIR/client/sel/ctl;;
+
+ ## Changing column modes
+ $MODKEY-d) ## Set column to default mode
+ echo colmode sel default-max >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-s) ## Set column to stack mode
+ echo colmode sel stack-max >> $WMII_DIR/tag/sel/ctl;;
+ $MODKEY-m) ## Set column to max mode
+ echo colmode sel stack+max >> $WMII_DIR/tag/sel/ctl;;
+
+ ## Running programs
+ $MODKEY-a) ## Open wmii actions menu
+ Action $(path_ls $WMII_CONFPATH | wimenu -h "${HIST}.actions" -n 5000) & ;;
+ $MODKEY-x) ## Open program menu
+ PATH=$_PATH setsid $(path_ls $PATH | wimenu -h "${HIST}.progs" -n 5000) & ;;
+ $MODKEY-Return) ## Launch a terminal
+ PATH=$_PATH setsid x-terminal-emulator & ;;
+
+ ## Tag actions
+ $MODKEY-t) ## Change to another tag
+ {
+ tag=$(lstags | wimenu -h "${HIST}.tags" -n 50) || return
+ echo view $tag >> $WMII_DIR/ctl
+ }& ;;
+ $MODKEY-Shift-t) ## Retag the selected client
+ sel=$(sed 1q $WMII_DIR/client/sel/ctl)
+ {
+ tag=$(lstags | wimenu -h "${HIST}.tags" -n 50) || return
+ echo "$tag" >> $WMII_DIR/client/$sel/tags
+ }& ;;
+ esac
+} ## End Key
+
+Action() {
+ prog=`path_which "$WMII_CONFPATH" $1`; shift
+ if [ -n "$prog" ]; then
+ "$prog" "$@"
+ return $?
+ else
+ return 1
+ fi
+} ## End Action
diff --git a/.wmii-hg/ctl-init b/.wmii-hg/ctl-init
new file mode 100644
index 0000000..ecba5b3
--- /dev/null
+++ b/.wmii-hg/ctl-init
@@ -0,0 +1,6 @@
+bar off
+font xft:Monospace-8
+focuscolors $WMII_FOCUSCOLORS
+normcolors $WMII_NORMCOLORS
+grabmod $MODKEY
+border 1
diff --git a/.wmii-hg/fixes.sh b/.wmii-hg/fixes.sh
new file mode 100644
index 0000000..aa09157
--- /dev/null
+++ b/.wmii-hg/fixes.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Fix various deficiencies in either the shell or the filesystem
+
+##
+# Usage: ls DIRECTORY
+# Linux's 9p kernel module sometimes omits entries in directory listings
+##
+unalias ls &>/dev/null
+ls() {
+ real_ls="`which ls` -1F"
+ [ $# = 0 ] && set -- "`pwd`"
+ f="${1/#${WMII_DIR}/}"
+ if [ "$f" = "$1" ]; then
+ $real_ls "$f"
+ else
+ wmiir ls "$f"
+ fi
+}
+
+##
+# Usage: setsid cmd [arguments...]
+# I like wmiir's setsid better than linux-utils'
+##
+setsid() { wmiir setsid "$@"; }
diff --git a/.wmii-hg/help-events b/.wmii-hg/help-events
new file mode 100755
index 0000000..08abd18
--- /dev/null
+++ b/.wmii-hg/help-events
@@ -0,0 +1,3 @@
+#!/bin/bash
+. include.sh
+scansection Event | xmessage -file -
diff --git a/.wmii-hg/help-keys b/.wmii-hg/help-keys
new file mode 100755
index 0000000..6f4bd1c
--- /dev/null
+++ b/.wmii-hg/help-keys
@@ -0,0 +1,3 @@
+#!/bin/bash
+. include.sh
+scansection Key | xmessage -file -
diff --git a/.wmii-hg/include.sh b/.wmii-hg/include.sh
new file mode 100644
index 0000000..38551aa
--- /dev/null
+++ b/.wmii-hg/include.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+if [[ -z "$WMII_NAMESPACE" ]]; then
+ export WMII_NAMESPACE="`wmiir namespace`"
+fi
+if [[ -z "$WMII_DIR" ]]; then
+ export WMII_DIR="$HOME/n/wmii"
+fi
+
+. util.sh
+. config.sh
diff --git a/.wmii-hg/quit b/.wmii-hg/quit
new file mode 100755
index 0000000..27d9052
--- /dev/null
+++ b/.wmii-hg/quit
@@ -0,0 +1,3 @@
+#!/bin/bash
+. include.sh
+echo quit >> $WMII_DIR/ctl
diff --git a/.wmii-hg/rbar_battery b/.wmii-hg/rbar_battery
new file mode 100755
index 0000000..f632f7e
--- /dev/null
+++ b/.wmii-hg/rbar_battery
@@ -0,0 +1,9 @@
+#!/bin/bash
+. include.sh
+
+priority=$1
+
+while connected_to_x_server; do
+ printf 'label %s\n' "$(acpi -b)" >> "$WMII_DIR/rbar/${priority}_battery"
+ sleep 1
+done
diff --git a/.wmii-hg/rbar_clock b/.wmii-hg/rbar_clock
new file mode 100755
index 0000000..6aecb92
--- /dev/null
+++ b/.wmii-hg/rbar_clock
@@ -0,0 +1,9 @@
+#!/bin/bash
+. include.sh
+
+priority=$1
+
+while connected_to_x_server; do
+ printf 'label %s\n' "$(date)" >> "$WMII_DIR/rbar/${priority}_clock"
+ sleep .5
+done
diff --git a/.wmii-hg/rbar_cpu b/.wmii-hg/rbar_cpu
new file mode 100755
index 0000000..5531e60
--- /dev/null
+++ b/.wmii-hg/rbar_cpu
@@ -0,0 +1,12 @@
+#!/bin/bash
+. include.sh
+
+priority=$1
+
+while connected_to_x_server; do
+ # This doesn't work for me, it shows capacity
+ #echo -n 'Core MHz:' $(cat /proc/cpuinfo | grep 'cpu MHz' | sed 's/.*: //g; s/\..*//g;') >> "$WMII_DIR/rbar/${priority}_cpu"
+ # This actually displays %idle
+ echo 'label CPU: [ '$(tail -n3 ~/tmp/cputime|sed -ur 's/\s\s+/\t/g'|cut -f2,11|sed 's/\t\(.*\)/(\1)/')' ]' >> "$WMII_DIR/rbar/${priority}_cpu"
+ sleep 1
+done
diff --git a/.wmii-hg/rbar_wifi b/.wmii-hg/rbar_wifi
new file mode 100755
index 0000000..18395a3
--- /dev/null
+++ b/.wmii-hg/rbar_wifi
@@ -0,0 +1,9 @@
+#!/bin/bash
+. include.sh
+
+priority=$1
+
+while connected_to_x_server; do
+ echo 'label Wlan0:' $(iwconfig wlan0 | sed 's/ /\n/g' | grep Quality) >> "$WMII_DIR/rbar/${priority}_wifi"
+ sleep 1
+done
diff --git a/.wmii-hg/rules b/.wmii-hg/rules
new file mode 100644
index 0000000..73cdf40
--- /dev/null
+++ b/.wmii-hg/rules
@@ -0,0 +1,3 @@
+/panel|notifyd/ tags=/.*/ floating=always
+/wimenu/ floating=always
+/Emacs/ force-tags=+sel floating=never
diff --git a/.wmii-hg/theme-solarized b/.wmii-hg/theme-solarized
new file mode 100644
index 0000000..5dc830d
--- /dev/null
+++ b/.wmii-hg/theme-solarized
@@ -0,0 +1,16 @@
+SOL_BASE03='#002b36'
+SOL_BASE02='#073642'
+SOL_BASE01='#586e75'
+SOL_BASE00='#657b83'
+SOL_BASE0='#839496'
+SOL_BASE1='#93a1a1'
+SOL_BASE2='#eee8d5'
+SOL_BASE3='#fdf6e3'
+SOL_YELLOW='#b58900'
+SOL_ORANGE='#cb4b16'
+SOL_RED='#dc322f'
+SOL_MAGENTA='#d33682'
+SOL_VIOLET='#6c71c4'
+SOL_BLUE='#268bd2'
+SOL_CYAN='#2aa198'
+SOL_GREEN='#859900'
diff --git a/.wmii-hg/theme-solarized-dark b/.wmii-hg/theme-solarized-dark
new file mode 100644
index 0000000..fde361b
--- /dev/null
+++ b/.wmii-hg/theme-solarized-dark
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Solarized-dark
+
+. theme-solarized
+
+WMII_BACKGROUND="$SOL_BASE02"
+
+# ="<text> <background> <border>"
+WMII_NORMCOLORS="$SOL_BASE0 $SOL_BASE03 $SOL_BASE02"
+WMII_FOCUSCOLORS="$SOL_BASE0 $SOL_BASE02 $SOL_BASE0"
+WMII_URGENTCOLORS="$SOL_RED $SOL_BASE03 $SOL_RED"
+
diff --git a/.wmii-hg/util.sh b/.wmii-hg/util.sh
new file mode 100644
index 0000000..a4c4bb4
--- /dev/null
+++ b/.wmii-hg/util.sh
@@ -0,0 +1,128 @@
+#!/bin/bash
+
+# I moved "fixes" into a separate file because it isn't so much configuration...
+. 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-hg/$@"
+}
diff --git a/.wmii-hg/wmiirc b/.wmii-hg/wmiirc
new file mode 100755
index 0000000..a6bc4b4
--- /dev/null
+++ b/.wmii-hg/wmiirc
@@ -0,0 +1,15 @@
+#!/bin/bash
+export _PATH="$PATH"
+export PATH="$WMII_CONFPATH:$PATH"
+
+. include.sh
+
+wmiir xwrite /event WmiircQuit # close any existing wmiirc's
+
+Event WmiircStart
+
+trap "Event Quit" EXIT
+
+wmiir read /event 2>/dev/null | while read event; do
+ Event $event
+done