hlfw.ca

hwwm

Download patch

ref: a7e98f81daba727890aeb739375d9e1cd04df0c5
parent: be34cb4ce29e7bbe9a205a44cdb25ad38039399d
author: halfwit <michaelmisch1985@gmail.com>
date: Wed Jan 16 12:25:14 PST 2019

Add focus helper

--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@
 OTHER = \
 	autotag \
 	fullscreen \
+	focus \
 	gitbar \
 	groups \
 	groupsbar \
--- /dev/null
+++ b/focus
@@ -1,0 +1,39 @@
+#!/bin/sh
+
+# Read in current focused window
+current=`pfw`
+cx=`wattr x $current`
+cy=`wattr y $current`
+cw=`wattr w $current`
+ch=`wattr h $current`
+mx=$((cx + $((cw / 2))))
+my=$((cy + $((ch / 2))))
+distance=99999
+focus=0
+
+euclidistance() {
+	echo "sqrt(($mx - $1)^2+($my - $2)^2)" | bc
+	
+}
+
+focus=$current
+lsw | xargs wattr xywhi | while read -r x y w h id; do 
+	test $id = $current && continue
+	no=0
+	case $1 in
+	left)	test $x -gt $((cx - 1)) && no=1 ;;
+	down)	test $((y + h)) -lt $((my + 1)) && no=1 ;;
+	# If right side current is further than left edge of window  
+	right)	test $((mx + mw + 1)) -gt $x && no=1 ;;
+	up)	test $((y + h)) -gt $((my - 1)) && no=1 ;;
+	*)      echo Please use up, down, left, right
+		break ;;
+	esac
+	test $no = 1 && continue
+	here=`euclidistance $((x + $((w / 2)))) $((y + $((h / 2))))`
+	test $here -gt $distance && continue
+	focus=$id
+	distance=$here
+	echo "$id"
+done | tail -n 1 | xargs wtf
+
--- a/hwwm
+++ b/hwwm
@@ -27,10 +27,6 @@
 	xprop -id $wid | grep -q -e TRANSIENT -e TYPE_MENU -e TYPE_DOCK -e drawterm && continue
 	fullscreen="$(watom `lsw -r` FS 2>/dev/null)"
 	case "$ev" in
-	# Focus in
-	9*)	chwb -s 2 -c "$highlight" "$wid" ;;
-	# Focus out
-	10*)	chwb -s 2 -c "$normal" "$wid" ;;
 	# Unmap
 	18*)	if test -z $fullscreen; then 
 			$DIR/wshuf | xargs -n 5 wtp
--- a/inotifybar
+++ b/inotifybar
@@ -1,5 +1,6 @@
 #!/bin/sh
 #TODO: This isn't part of hwwm at all, this should be in a seperate repository
+#TODO: -g +1920 moves things on to my middle monitor.
 # Full credit to @Earnestly.
 statusdir="$XDG_RUNTIME_DIR/statusbar"
 mkdir -pm0700 "$statusdir"
@@ -22,9 +23,6 @@
 	test -f "$statusdir/batt" && read -r batt < "$statusdir/batt"
 
 
-	# This will fail unless you have something set for *desktop in your Xresources!
-	background="$(xrdb -query | awk '/desktop/{print $NF}')"
-	foreground="$(xrdb -query | awk '/foreground/{print $NF}')"
 	inotifywait -qme close_write --format %f "$statusdir" | while read -r file; do
 		if read -r -- "$file" < "$statusdir/$file"; then
 			printf -- ' %s %s %%{c} %s %%{r} %s%s%s \n' "$time" "$batt" "$groups" "$rss" "$git" "$media"
@@ -31,7 +29,7 @@
 			# We explicitely need to force a redraw here, since we ignore
 			/usr/local/share/hwwm/wshuf | xargs -n 5 wtp
 		fi
-	done | lemonbar -F "$foreground" -B "$background" -d -b -f "DejaVu Book:size=10.5" -f "Symbola:size=9.5" -f "FreeSans:size=9.5"
+	done | lemonbar -F '#000000' -d -b -f "DejaVu Book:size=10.5" -f "Symbola:size=9.5" -f "FreeSans:size=9.5" -g +1920
 }
 
 barrun