diff options
Diffstat (limited to '.config/wmii-hg/config.sh')
-rw-r--r-- | .config/wmii-hg/config.sh | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/.config/wmii-hg/config.sh b/.config/wmii-hg/config.sh index 3ddc8d5..be75d65 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 @@ -36,22 +36,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,7 +61,7 @@ Event() { echo " -> Unmounting WMII_DIR=$WMII_DIR..." 9umount "$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' @@ -99,14 +95,14 @@ 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) @@ -117,8 +113,9 @@ Event() { 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 +135,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 +154,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 +218,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; exec $command ) & ;; $MODKEY-Return) ## Launch a terminal - PATH=$_PATH setsid x-terminal-emulator & ;; + ( PATH=$_PATH; unset _PATH; 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 +} |