summaryrefslogtreecommitdiff
path: root/.config/wmii-hg/config.sh
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2015-02-06 15:17:51 -0500
committerLuke Shumaker <shumakl@purdue.edu>2015-02-06 15:17:51 -0500
commitdab097d5000c4697761b6985cb3512f7bce0147f (patch)
tree7b81b7826a1e23822955560f0f73dc09cda6c8e8 /.config/wmii-hg/config.sh
parentf50b49ef26f5c692bda1f3f13cd38f9f4f395300 (diff)
parenta6f973687fb4a1a4558f74f7da595b6902a5dce0 (diff)
Merge remote-tracking branch 'origin/master' into purdue-cs/master
Conflicts: .config/X11/clientrc .config/bash/rc.d/emacs.sh .config/cron/make-config .config/emacs/custom.el .config/emacs/init.el .config/git/config .config/login.sh .config/selected_editor .local/bin/config-path
Diffstat (limited to '.config/wmii-hg/config.sh')
-rw-r--r--.config/wmii-hg/config.sh95
1 files changed, 51 insertions, 44 deletions
diff --git a/.config/wmii-hg/config.sh b/.config/wmii-hg/config.sh
index 4889aac..7ef8305 100644
--- a/.config/wmii-hg/config.sh
+++ b/.config/wmii-hg/config.sh
@@ -7,13 +7,13 @@ LEFT=b
RIGHT=f
HIST="$XDG_CACHE_HOME/wmii/history"
-mkdir -p "${HIST%/*}"
+mkdir -p -- "${HIST%/*}"
# Colors tuples: "<text> <background> <border>"
. theme-tango-dark
Event() {
- event=$1; shift;
+ local event=$1; shift;
case "$event" in
## Mouse event meanings:
## MouseDown = mouse down
@@ -25,6 +25,8 @@ Event() {
## 1 = left
## 2 = middle
## 3 = right
+ ## 4 = scroll up
+ ## 5 = scroll down
## Custom (non-WMII-generated) events
WmiircStart) ## No args
@@ -36,22 +38,18 @@ Event() {
< "`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"
+ #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
+ local tag seltag="$(sed 1q $WMII_DIR/tag/sel/ctl)"
+ while read -r tag; do
Event CreateTag "$tag"
if [ "$tag" = "$seltag" ]; then
Event FocusTag "$tag"
fi
- done
-
- # Run the autostart action
- Action autostart 2>/dev/null &
+ done < <(lstags)
;;
WmiircQuit) ## No args
echo ' ==> Stopping wmiirc'
@@ -65,11 +63,13 @@ Event() {
echo " -> Unmounting WMII_DIR=$WMII_DIR..."
fusermount -u "$WMII_DIR"
echo " -> Removing mountpoint WMII_DIR=$WMII_DIR..."
- rmdir "$WMII_DIR";;
+ rmdir -p "$WMII_DIR" 2>/dev/null;;
## WMII-meta events
Quit) ## No args
- echo ' ==> wmii quit: unmounting'
trap - EXIT
+ if [ -S "$NOTIFY_SOCKET" ]; then
+ echo STOPPING=1 | socat STDIO UNIX-SENDTO:"$NOTIFY_SOCKET"
+ fi
Event WmiircUnmount
Event WmiircQuit;;
Warning) ## $@=string
@@ -99,26 +99,29 @@ Event() {
NotUrgent) ## $1=client $2=[Manager|Client]
;;
ClientMouseDown) ## $1=client $2=button
- client=$1
- button=$2
+ local client=$1
+ local button=$2
case $button in
1) ;;
2) ;;
3)
{
- case `wmii9menu Delete Fullscreen` in
+ case $(wmii9menu Delete Fullscreen) in
Delete)
echo kill >> $WMII_DIR/client/$client/ctl;;
Fullscreen)
echo Fullscreen on >> $WMII_DIR/client/$1/ctl;;
esac
}& ;;
+ 4) ;;
+ 5) ;;
esac;;
ClientClick) ## $1=client $2=button
;;
Unresponsive) ## $1=client
- client=$1
- client_name=`cat $WMII_DIR/client/$client/label`
+ local client=$1
+ local client_name=$(< $WMII_DIR/client/$client/label)
+ local msg resp
msg="The client \`${client_name}' is not responding."
msg+=" What would you like to do?"
{
@@ -138,13 +141,13 @@ Event() {
DestroyTag) ## $1=tag
rm $WMII_DIR/lbar/$1;;
FocusTag) ## $1=tag
- echo colors "$WMII_FOCUSCOLORS" >> $WMII_DIR/lbar/$1;;
+ echo colors "$WMII_FOCUSCOLORS" >> $WMII_DIR/lbar/$1;;
UnfocusTag) ## $1=tag
- echo colors "$WMII_NORMCOLORS" >> $WMII_DIR/lbar/$1;;
- UrgentTag) ## $1=tag $2=[Manager|Client]
- echo "$WMII_URGENTCOLORS" >> $WMII_DIR/lbar/$1;;
- NotUrgentTag) ## $1=tag $2=[Manager|Client]
- echo "$WMII_NORMCOLORS" >> $WMII_DIR/lbar/$1;;
+ echo colors "$WMII_NORMCOLORS" >> $WMII_DIR/lbar/$1;;
+ UrgentTag) ## $1=[Manager|Client] $2=tag
+ echo colors "$WMII_URGENTCOLORS" >> $WMII_DIR/lbar/$2;;
+ NotUrgentTag) ## $1=[Manager|Client] $2=tag
+ echo colors "$WMII_NORMCOLORS" >> $WMII_DIR/lbar/$2;;
## LeftBar events (usually tag buttons)
LeftBarMouseDown) ## $1=button $2=bar_item
@@ -157,17 +160,20 @@ Event() {
## RightBar events
RightBarMouseDown) ## $1=button $2=bar_item
- ;;
+ local button=$1
+ local item=$2
+ local name=${item#[0-9][0-9]_}
+ name=${name%.*}
+ Action "rbar_$name" "$button" & ;;
RightBarClick) ## $1=button $2=bar_item
;;
RightMouseDND) ## $1=button $2=bar_item
Event RightBarClick "$@";;
esac
-} ## End Event
+}
-# Key Bindings
Key() {
- key=$1
+ local key=$1
case "$key" in
## Moving around
@@ -218,33 +224,34 @@ Key() {
## Running programs
$MODKEY-a) ## Open wmii actions menu
- Action $(path_ls $WMII_CONFPATH | wimenu -h "${HIST}.actions" -n 5000) & ;;
+ local action
+ action="$(path_ls "$WMII_CONFPATH" | wimenu -h "${HIST}.actions" -n 5000)" || return
+ Action "$action" & ;;
$MODKEY-x) ## Open program menu
- PATH=$_PATH setsid $(path_ls $PATH | wimenu -h "${HIST}.progs" -n 5000) & ;;
+ local command
+ command="$(path_ls "$_PATH" | wimenu -h "${HIST}.progs" -n 5000)" || return
+ ( PATH=$_PATH; unset _PATH NOTIFY_SOCKET; exec $command ) & ;;
$MODKEY-Return) ## Launch a terminal
- PATH=$_PATH setsid x-terminal-emulator & ;;
+ ( PATH=$_PATH; unset _PATH NOTIFY_SOCKET; exec 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
- }& ;;
+ local tag
+ tag=$(lstags | wimenu -h "${HIST}.tags" -n 50) || return
+ echo view "$tag" >> $WMII_DIR/ctl;;
$MODKEY-Shift-t) ## Retag the selected client
+ local sel tag
sel=$(sed 1q $WMII_DIR/client/sel/ctl)
- {
- tag=$(lstags | wimenu -h "${HIST}.tags" -n 50) || return
- echo "$tag" >> $WMII_DIR/client/$sel/tags
- }& ;;
+ 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
+ local prog=$(path_which "$WMII_CONFPATH" "$1"); shift
if [ -n "$prog" ]; then
- "$prog" "$@"
- return $?
+ exec "$prog" "$@"
else
- return 1
+ exec false
fi
-} ## End Action
+}