diff options
Diffstat (limited to '.config/wmii-hg')
-rw-r--r--[-rwxr-xr-x] | .config/wmii-hg/config.sh | 203 | ||||
-rw-r--r-- | .config/wmii-hg/ctl-init | 5 | ||||
-rw-r--r-- | .config/wmii-hg/fixes.sh | 24 | ||||
-rwxr-xr-x | .config/wmii-hg/help-events | 3 | ||||
-rwxr-xr-x | .config/wmii-hg/help-keys | 3 | ||||
-rw-r--r-- | .config/wmii-hg/rules | 8 | ||||
-rw-r--r-- | .config/wmii-hg/theme-solarized-dark | 2 | ||||
-rw-r--r-- | .config/wmii-hg/theme-tango | 10 | ||||
-rw-r--r-- | .config/wmii-hg/theme-tango-dark | 11 | ||||
-rw-r--r-- | .config/wmii-hg/util.sh | 129 | ||||
-rwxr-xr-x | .config/wmii-hg/wmiirc | 15 |
11 files changed, 300 insertions, 113 deletions
diff --git a/.config/wmii-hg/config.sh b/.config/wmii-hg/config.sh index 92adb8b..3ddc8d5 100755..100644 --- a/.config/wmii-hg/config.sh +++ b/.config/wmii-hg/config.sh @@ -1,30 +1,16 @@ #!/bin/bash -# Let any running instances of wmiirc know that we're starting -wmiir xwrite /event Start -. "$HOME/.wmii/include.sh" - -echo ' ==> Starting wmiirc' -mount9p=/opt/plan9/bin/9pfuse -mkdir -p $WMII_NAMESPACE/mnt -$mount9p $WMII_NAMESPACE/{wmii,mnt} - -MODKEY=Mod4 # super +MODKEY=Mod4 # "super" UP=p DOWN=n LEFT=b RIGHT=f -# Colors tuples: "<text> <background> <border>" -. `conffile theme-solarized-dark` - -# Menu history -hist="`conffile history`" +HIST="$XDG_CACHE_HOME/wmii/history" +mkdir -p "${HIST%/*}" -# Tagging Rules -echo '/Emacs|Navigator/ -> +sel' >> $WMII_DIR/tagrules -echo '/Eclipse/ -> +sel' >> $WMII_DIR/tagrules -echo '/panel/ -> /.*/' >> $WMII_DIR/tagrules +# Colors tuples: "<text> <background> <border>" +. theme-tango-dark Event() { event=$1; shift; @@ -40,15 +26,52 @@ Event() { ## 2 = middle ## 3 = right - ## WMII-meta events - Quit) ## No args + ## 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 + hsetroot -solid "$WMII_BACKGROUND" + + # Clear the LBar and RBar + find $WMII_DIR/{l,r}bar -type f -delete + # Populate the LBar by emulating [Create|Focus]Tag events + seltag=`sed 1q $WMII_DIR/tag/sel/ctl` + lstags | while read tag; do + Event CreateTag "$tag" + if [ "$tag" = "$seltag" ]; then + Event FocusTag "$tag" + fi + done + + # Run the autostart action + Action autostart 2>/dev/null & + ;; + WmiircQuit) ## No args echo ' ==> Stopping wmiirc' - echo " -> unmounting WMII_DIR=$WMII_DIR..." - # might complain about /etc/mtab if the x server has already stopped - fusermount -u "$WMII_DIR" 2>>/dev/null - echo " -> rmdir'ing WMII_DIR=$WMII_DIR..." - rmdir "$WMII_DIR" 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 @@ -85,9 +108,9 @@ Event() { { case `wmii9menu Delete Fullscreen` in Delete) - echo kill |a $WMII_DIR/client/$client/ctl;; + echo kill >> $WMII_DIR/client/$client/ctl;; Fullscreen) - echo Fullscreen on |a $WMII_DIR/client/$1/ctl;; + echo Fullscreen on >> $WMII_DIR/client/$1/ctl;; esac }& ;; esac;; @@ -102,7 +125,7 @@ Event() { resp=$(wihack -transient $client \ xmessage -nearmouse -buttons Kill,Wait -print "$msg") if [ "$resp" = Kill ]; then - echo slay |a $WMII_DIR/client/$client/ctl + echo slay >> $WMII_DIR/client/$client/ctl fi }& ;; Fullscreen) ## $1=client $2=[on|off] @@ -111,24 +134,24 @@ Event() { ## Tag events CreateTag) ## $1=tag - echo "$WMII_NORMCOLORS" $@ |a $WMII_DIR/lbar/$1;; + echo label "$*" >> $WMII_DIR/lbar/$1;; DestroyTag) ## $1=tag rm $WMII_DIR/lbar/$1;; FocusTag) ## $1=tag - echo "$WMII_FOCUSCOLORS" $1 |a $WMII_DIR/lbar/$1;; + echo colors "$WMII_FOCUSCOLORS" >> $WMII_DIR/lbar/$1;; UnfocusTag) ## $1=tag - echo "$WMII_NORMCOLORS" $1 |a $WMII_DIR/lbar/$1;; + echo colors "$WMII_NORMCOLORS" >> $WMII_DIR/lbar/$1;; UrgentTag) ## $1=tag $2=[Manager|Client] - echo "$WMII_URGENTCOLORS" $1 |a $WMII_DIR/lbar/$1;; + echo "$WMII_URGENTCOLORS" >> $WMII_DIR/lbar/$1;; NotUrgentTag) ## $1=tag $2=[Manager|Client] - echo "$WMII_NORMCOLORS" $1 |a $WMII_DIR/lbar/$1;; + echo "$WMII_NORMCOLORS" >> $WMII_DIR/lbar/$1;; ## LeftBar events (usually tag buttons) LeftBarMouseDown) ## $1=button $2=bar_item ;; LeftBarClick) ## $1=button $2=bar_item shift # ignore the button - echo view "$@" |a $WMII_DIR/ctl;; + echo view "$@" >> $WMII_DIR/ctl;; LeftMouseDND) ## $1=button $2=bar_item Event LeftBarClick "$@";; @@ -139,10 +162,6 @@ Event() { ;; RightMouseDND) ## $1=button $2=bar_item Event RightBarClick "$@";; - - ## Custom (non-WMII-generated) events - Start) ## No args - Event Quit;; # get out of the way for a new event loop esac } ## End Event @@ -153,119 +172,79 @@ Key() { ## Moving around $MODKEY-$LEFT) ## Select the client to the left - echo select left |a $WMII_DIR/tag/sel/ctl;; + echo select left >> $WMII_DIR/tag/sel/ctl;; $MODKEY-$RIGHT) ## Select the client to the right - echo select right |a $WMII_DIR/tag/sel/ctl;; + echo select right >> $WMII_DIR/tag/sel/ctl;; $MODKEY-$UP) ## Select the client above - echo select up |a $WMII_DIR/tag/sel/ctl;; + echo select up >> $WMII_DIR/tag/sel/ctl;; $MODKEY-$DOWN) ## Select the client below - echo select down |a $WMII_DIR/tag/sel/ctl;; + echo select down >> $WMII_DIR/tag/sel/ctl;; $MODKEY-space) ## Toggle between floating and managed layers - echo select toggle |a $WMII_DIR/tag/sel/ctl;; + echo select toggle >> $WMII_DIR/tag/sel/ctl;; ## Moving clients around $MODKEY-Shift-$LEFT) ## Move selected client to the left - wmiir xwrite /tag/sel/ctl send sel left;; + echo send sel left >> $WMII_DIR/tag/sel/ctl;; $MODKEY-Shift-$RIGHT) ## Move selected client to the right - wmiir xwrite /tag/sel/ctl send sel right;; + echo send sel right >> $WMII_DIR/tag/sel/ctl;; $MODKEY-Shift-$UP) ## Move selected client up - wmiir xwrite /tag/sel/ctl send sel up;; + echo send sel up >> $WMII_DIR/tag/sel/ctl;; $MODKEY-Shift-$DOWN) ## Move selected client down - wmiir xwrite /tag/sel/ctl send sel down;; - + echo send sel down >> $WMII_DIR/tag/sel/ctl;; $MODKEY-Shift-space) ## Toggle selected client between floating and managed layers - wmiir xwrite /tag/sel/ctl send sel toggle;; + echo send sel toggle >> $WMII_DIR/tag/sel/ctl;; ## Moving through stacks $MODKEY-Control-$UP) ## Select the stack above - wmiir xwrite /tag/sel/ctl select up stack;; - $MODKEY-Control-$DOWN) # Select the stack below - wmiir xwrite /tag/sel/ctl select down stack;; + 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 - wmiir xwrite /client/sel/ctl Fullscreen toggle;; + echo Fullscreen toggle >> $WMII_DIR/client/sel/ctl;; $MODKEY-shift-0) ## Close client - wmiir xwrite /client/sel/ctl kill;; + echo kill >> $WMII_DIR/client/sel/ctl;; ## Changing column modes $MODKEY-d) ## Set column to default mode - wmiir xwrite /tag/sel/ctl colmode sel default-max;; + echo colmode sel default-max >> $WMII_DIR/tag/sel/ctl;; $MODKEY-s) ## Set column to stack mode - wmiir xwrite /tag/sel/ctl colmode sel stack-max;; + echo colmode sel stack-max >> $WMII_DIR/tag/sel/ctl;; $MODKEY-m) ## Set column to max mode - wmiir xwrite /tag/sel/ctl colmode sel stack+max;; + 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) & ;; + Action $(path_ls $WMII_CONFPATH | wimenu -h "${HIST}.actions" -n 5000) & ;; $MODKEY-x) ## Open program menu - setsid $(wimenu -h "${hist}.progs" -n 5000 <$progsfile) & ;; + PATH=$_PATH setsid $(path_ls $PATH | wimenu -h "${HIST}.progs" -n 5000) & ;; $MODKEY-Return) ## Launch a terminal - setsid x-terminal-emulator & ;; - - ## Other - $MODKEY-Control-t) ## Toggle all other key bindings - case $(wmiir read /keys | wc -l | tr -d ' \t\n') in - 0|1) - echo -n "$Keys" | wmiir write /keys - wmiir xwrite /ctl grabmod $MODKEY;; - *) - wmiir xwrite /keys $MODKEY-Control-t - wmiir xwrite /ctl grabmod Mod3;; - esac;; + PATH=$_PATH setsid x-terminal-emulator & ;; ## Tag actions $MODKEY-t) ## Change to another tag { - tag=$(lstags | wimenu -h "${hist}.tags" -n 50) || return - wmiir xwrite /ctl view $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 - wmiir xwrite /client/$sel/tags "$tag" + tag=$(lstags | wimenu -h "${HIST}.tags" -n 50) || return + echo "$tag" >> $WMII_DIR/client/$sel/tags }& ;; esac } ## End Key -# WM Configuration -echo font xft:Monospace-8 |a $WMII_DIR/ctl -echo focuscolors $WMII_FOCUSCOLORS |a $WMII_DIR/ctl -echo normcolors $WMII_NORMCOLORS |a $WMII_DIR/ctl -echo grabmod $MODKEY |a $WMII_DIR/ctl -echo border 1 |a $WMII_DIR/ctl -xsetroot -solid "$WMII_BACKGROUND" & - -progsfile=$WMII_NAMESPACE/.proglist -path_ls $PATH > $progsfile & - -eval arg `scansection Key|cut -sf2` |a $WMII_DIR/keys - -# Clear the LBar -find $WMII_DIR/lbar -type f -delete - -# Emulate [Create|Focus]Tag events -seltag=`sed 1q $WMII_DIR/tag/sel/ctl` -lstags | while read tag; do - Event CreateTag "$tag" - if [ "$tag" = "$seltag" ]; then - Event FocusTag "$tag" +Action() { + prog=`path_which "$WMII_CONFPATH" $1`; shift + if [ -n "$prog" ]; then + "$prog" "$@" + return $? + else + return 1 fi -done - -Action autostart 2>/dev/null & - -if [ -f "`conffile wmiirc_local`" ]; then - . "`conffile wmiirc_local`" -fi - -trap "Event Quit" EXIT - -# use wmiir so it doesn't look like an open file -wmiir read /event 2>/dev/null | while read event; do - Event $event -done +} ## End Action diff --git a/.config/wmii-hg/ctl-init b/.config/wmii-hg/ctl-init new file mode 100644 index 0000000..026c0d5 --- /dev/null +++ b/.config/wmii-hg/ctl-init @@ -0,0 +1,5 @@ +font xft:Monospace-8 +focuscolors $WMII_FOCUSCOLORS +normcolors $WMII_NORMCOLORS +grabmod $MODKEY +border 1 diff --git a/.config/wmii-hg/fixes.sh b/.config/wmii-hg/fixes.sh new file mode 100644 index 0000000..5858859 --- /dev/null +++ b/.config/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() { + local 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/.config/wmii-hg/help-events b/.config/wmii-hg/help-events new file mode 100755 index 0000000..08abd18 --- /dev/null +++ b/.config/wmii-hg/help-events @@ -0,0 +1,3 @@ +#!/bin/bash +. include.sh +scansection Event | xmessage -file - diff --git a/.config/wmii-hg/help-keys b/.config/wmii-hg/help-keys new file mode 100755 index 0000000..6f4bd1c --- /dev/null +++ b/.config/wmii-hg/help-keys @@ -0,0 +1,3 @@ +#!/bin/bash +. include.sh +scansection Key | xmessage -file - diff --git a/.config/wmii-hg/rules b/.config/wmii-hg/rules new file mode 100644 index 0000000..cf735c9 --- /dev/null +++ b/.config/wmii-hg/rules @@ -0,0 +1,8 @@ +/wimenu/ floating=always +/panel/ tags=/.*/ floating=always +/xfce4-notifyd/ tags=/.*/ floating=always + +/nm-applet/ floating=off + +/Emacs|Navigator/ force-tags=+sel floating=never +/.*/ floating=off diff --git a/.config/wmii-hg/theme-solarized-dark b/.config/wmii-hg/theme-solarized-dark index 83285ba..fde361b 100644 --- a/.config/wmii-hg/theme-solarized-dark +++ b/.config/wmii-hg/theme-solarized-dark @@ -1,7 +1,7 @@ #!/bin/sh # Solarized-dark -. $HOME/.wmii/theme-solarized +. theme-solarized WMII_BACKGROUND="$SOL_BASE02" diff --git a/.config/wmii-hg/theme-tango b/.config/wmii-hg/theme-tango new file mode 100644 index 0000000..e0e35d4 --- /dev/null +++ b/.config/wmii-hg/theme-tango @@ -0,0 +1,10 @@ +TANGO_butter=("#fce94f" "#edd400" "#c4a000") +TANGO_orange=("#fcaf3e" "#f57900" "#ce5c00") +TANGO_choc=( "#e9b96e" "#c17d11" "#8f5902") +TANGO_cham=( "#8ae234" "#73d216" "#4e9a06") +TANGO_blue=( "#729fcf" "#3465a4" "#204a87") +TANGO_plum=( "#ad7fa8" "#75507b" "#5c3566") +TANGO_red=( "#ef2929" "#cc0000" "#a40000") +TANGO_alum=( "#eeeeec" "#d3d7cf" "#babdb6" + "#888a85" "#555753" "#2e3436") + diff --git a/.config/wmii-hg/theme-tango-dark b/.config/wmii-hg/theme-tango-dark new file mode 100644 index 0000000..04a9fa6 --- /dev/null +++ b/.config/wmii-hg/theme-tango-dark @@ -0,0 +1,11 @@ +#!/bin/bash +# Tango-tark + +. theme-tango + +WMII_BACKGROUND="${TANGO_alum[5]}" + +# ="<text> <background> <border>" +WMII_NORMCOLORS="${TANGO_alum[0]} ${TANGO_alum[4]} ${TANGO_alum[3]}" +WMII_FOCUSCOLORS="${TANGO_alum[5]} ${TANGO_alum[1]} ${TANGO_alum[0]}" +WMII_URGENTCOLORS="${TANGO_orange[0]} ${TANGO_alum[4]} ${TANGO_orange[4]}" diff --git a/.config/wmii-hg/util.sh b/.config/wmii-hg/util.sh new file mode 100644 index 0000000..71dbc41 --- /dev/null +++ b/.config/wmii-hg/util.sh @@ -0,0 +1,129 @@ +#!/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() { + local 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() { + local dir="$(readlink -m $1)" + local mntpnt="$(cut -d' ' -f2 /proc/mounts|grep -Fx -- "$dir")" + [[ $dir = "$mntpnt" ]] + return $? +} + +################################################################################ +# PATH manipulation # +################################################################################ + +## +# Usage: path_ls PATH +# List executables in PATH (PATH is delimited by `:') +## +path_ls() { + local dirs + IFS=: dirs=($@) + 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() { + local mypath=$1 + local prog=$2 + local 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() { + local file=$(conffile config.sh) + local sec=$1 + local tmp=$(mktemp --tmpdir wmii-scansecion.XXXXXXXXXX) + # 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/$1" +} diff --git a/.config/wmii-hg/wmiirc b/.config/wmii-hg/wmiirc new file mode 100755 index 0000000..a6bc4b4 --- /dev/null +++ b/.config/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 |