hlfw.ca

hwwm

Download patch

ref: 1b6c728d36011c3684b4a959925f91f133722c46
parent: 8c7dea63aa89194d96bf4f3986b00a3c6a9212ec
author: Halfwit <michaelmisch1985@gmail.com>
date: Wed Aug 29 14:14:03 PDT 2018

Changes to gitbar to use more sanity

Signed-off-by: Halfwit <michaelmisch1985@gmail.com>

--- a/autotag
+++ b/autotag
@@ -3,11 +3,13 @@
 WIN=$XDG_CONFIG_HOME/x11/tags
 
 name="`xprop -id "$1" | awk '/WM_CLASS/{print $NF}' | tr -d '"' `"
-test -z $name && exit 0
+test -z "$name" && exit 0
 awk -v r="$name" '$0 ~ r {print $2, $3}' "$WIN" | while read -r flag tag; do
 	if test "$flag" = true; then
-		wtf "$flag"
-		chwso "$1"
+		wtf "$1"
+		chwso -r "$1"
+	else
+		wtf `lsw | tail -n1`
 	fi
 	if test "$tag" != ""; then
 		grp "$tag" "$1"
--- a/gitbar
+++ b/gitbar
@@ -2,48 +2,15 @@
 
 GITBAR="$XDG_RUNTIME_DIR/statusbar/git"
 
-comm=0
-push=0
-pull=0
+append() {
+	case "$1" in
+		0) 							   ;;
+		[0-9]*) printf '%s\n' "[$1$2]" ;;
+	esac
+}
 
-while IFS="⇄↑↓" read -r input; do
-	case "$input" in
-		*↑*) push=`echo "$input" | tr -cd [:digit:]` ;;
-		*↓*) pull=`echo "$input" | tr -cd [:digit:]` ;;
-		*⇄*) comm=`echo "$input" | tr -cd [:digit:]` ;;
-	esac		
-done < $GITBAR
-
-case "$1" in
-	commit) comm=`commit wc` ;;
-	pull)   pull=`pull wc`   ;;
-	push)   push=`push wc`   ;;
-esac
-
-check=0
-if [ $comm -gt 0 ]; then
-	comm="⇄$comm"
-	check=1
-else
-	comm=""
-fi
-
-if [ $push -gt 0 ]; then
-	push="↑$push"
-	check=1
-else
-	push=""
-fi
-
-if [ $pull -gt 0 ]; then
-	pull="↓$pull"
-	check=1
-else
-	pull=""
-fi
-
-if [ $check -eq 1 ]; then
-	printf '%s\n' " [$push$pull$comm]" > "$GITBAR"
-else
-	> "$GITBAR"
-fi
+printf '%s%s%s\n' \
+	"$(append "$(wc -l < "$XDG_DATA_DIR/pushes")" "↑")" \
+	"$(append "$(wc -l < "$XDG_DATA_DIR/pulls")" "↓")" \
+	"$(append "$(wc -l < "$XDG_DATA_DIR/commits")" "⇄")" \
+> "$XDG_RUNTIME_DIR/statusbar/git"
--- a/groupsbar
+++ b/groupsbar
@@ -4,10 +4,16 @@
 panels=6
 declare -a item
 
+# This is where webkit browsers currently break on the bar
+# lsgrp 2 | tail -n1 gets something called `WebKitProcess` which is unmapped
 for (( i = 1; i <= $panels; i++ )); do
-  groups=$(lsgrp "$i")
+  groups=$(lsgrp "$i" | tail -n1)
+  if test "$groups" = "WebKitProcess"; then
+    xprop -id "$groups" -remove _WM_GROUP
+    groups="$(lsgrp 2 | tail -n1)"
+  fi
   if [[ $groups != "" ]]; then
-    if wattr m "$(lsgrp "$i" | tail -n 1)"; then
+    if wattr m "$groups"; then
       item[$i]="◉"
     else
       item[$i]="◍"
--- a/stack
+++ b/stack
@@ -1,18 +1,30 @@
 #!/bin/sh
-# Sadly, we currently have to run lsgrp twice here - look into fixing this
-# We want to get "$1" to match wname if we are toggling an unmapped window on
 
-w_name() {
+get_name() {
 	xprop -id "$1" | sed -n -e 's/_NET_WM_NAME(UTF8_STRING) = //p' | tr -d '"'
 }
 
-WIN="$(lsgrp 2 | tail -n 1)"
-wattr m "$WIN" || set -- "$(w_name "$WIN")"
+# Clean up group 2 which could have errant WebKitProcess or blank strings
+clean_group() {
+	lsgrp 2 | while read -r id; do
+	case "_$(get_name "$id")" in
+		_WebKitWebProcess*) xprop -id "$id" -remove _WM_GROUP ;;
+		_)                  killw "$id" ;;
+	esac
+	done
+}
 
+get_win() {
+	clean_group
+	lsgrp 2 | tail -n1
+}
+
+# Make sure we have something useful passed in
+test -z "$1" && set -- "$(get_name `get_win`)"
+
 lsgrp 2 | while read -r id; do
-	# Test if we're sent in name, map if match
-	if test "$1" = "$(w_name "$id")"; then
-		mapw -m "$id"
+	if test "$@" = "$(get_name "$id")"; then
+		mapw -t "$id"
 	else
 		mapw -u "$id"
 	fi