hlfw.ca

hwwm

Download patch

ref: 16c61e723e065f71a4bbb96b8effaf22b60f2a92
parent: 599594b2a014a73c073bfdf0da23d67a05f63b45
author: Halfwit <michaelmisch1985@gmail.com>
date: Fri Mar 3 08:56:27 PST 2017

Initial commit

--- /dev/null
+++ b/autotag
@@ -1,0 +1,28 @@
+#!/bin/sh
+
+getname() {
+  cd "$XDG_CONFIG_HOME"/x11/windows || exit 1
+  for i in *; do
+    watom "$1" WM_NAME | grep -io "$i" 2>/dev/null && break
+    watom "$1" _NET_WM_NAME | grep -io "$i" 2>/dev/null && break
+  done
+}
+
+# See if already exists
+case "`getname $1`" in
+  mpv*)        grp=1 ;;
+  surf*)       wtf "$1" && grp=2 ;;
+  browse*)     wtf "$1" && grp=2 ;;
+  edit*)       wtf "$1" && grp=3 ;;
+  mutt*|news*) wtf "$1" && grp=4 ;;
+  irc*)        wtf "$1" && grp=5 ;;
+  *docs*)      wtf "$1" && grp=6 ;;
+  zathura*)    wtf "$1" && grp=6 ;;
+esac
+
+chwso -r "$1"
+
+if [ $grp ]; then
+  grp "$grp" "$1"
+  "$XDG_DATA_HOME"/x11/groupsbar
+fi
--- /dev/null
+++ b/fullscreen
@@ -1,0 +1,18 @@
+#!/bin/sh
+#
+# z3bra - 2014 (c) wtfpl
+# toggle the fullscreen state of a window
+# depends on: focus.sh
+
+
+if watom `lsw -r` FS | xargs -n 5 wtp; then
+    xprop -root -remove FS
+    "$XDG_DATA_HOME"/x11/wshuf
+else
+    xprop -root -format FS 8s -set FS "$(wattr xywhi $1)"
+    . "$XDG_CONFIG_HOME"/x11/size
+    wtp "$gaps" "$gaps" "$fulw" "$fulh" "$1"
+    chwso -r "$1"
+fi
+
+wtf "$1"
--- /dev/null
+++ b/gitbar
@@ -1,0 +1,34 @@
+#!/bin/sh
+
+GITBAR="$XDG_RUNTIME_DIR/statusbar/git"
+
+commit=`commit wc`
+push=`push wc`
+pull=`pull wc`
+check=0
+if [ $commit -gt 0 ]; then
+	commit="⇄$commit"
+	check=1
+else
+	commit=""
+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' " [$commit$push$pull]" > "$GITBAR"
+else
+	printf '%s\n' "" > "$GITBAR"
+fi
--- /dev/null
+++ b/groups
@@ -1,0 +1,9 @@
+#!/bin/sh
+#
+# Copyright (c) 2015 Greduan <me@greduan.com>, licensed under the WTFPL
+# Adds group-like capabilities, sorta like those you find in CWM and such WMs
+
+case "$1" in
+  0x0*) grp "$2" "$1"           ;;
+  *) lsgrp "$1" | xargs mapw -t ;;
+esac
--- /dev/null
+++ b/groupsbar
@@ -1,0 +1,21 @@
+#!/usr/bin/env bash
+
+# Number of groups
+panels=6
+declare -a item
+
+for (( i = 1; i <= $panels; i++ )); do
+  groups=$(lsgrp "$i")
+  if [[ $groups != "" ]]; then
+    if wattr m "$(lsgrp "$i" | tail -n 1)"; then
+      item[$i]="◉"
+    else
+      item[$i]="◍"
+    fi
+  else
+    item[$i]="◌"
+  fi
+  result+=${item["$i"]} 
+done
+
+printf '%s\n' "—${result[@]}—" > $XDG_RUNTIME_DIR/statusbar/groups
\ No newline at end of file
--- /dev/null
+++ b/inotifybar
@@ -1,0 +1,31 @@
+#!/bin/sh
+# Full credit to @Earnestly.
+statusdir="$XDG_RUNTIME_DIR/statusbar"
+mkdir -pm0700 "$statusdir"
+
+battery() {
+	while :; do
+		read -r level < /sys/class/power_supply/BAT0/capacity
+		if [ $level -lt 80 ]; then
+			printf ' %s%%\n' "$level" > "$statusdir/batt"
+		else
+			printf "" > "$statusdir/batt"
+		fi
+		read -r rss < ~/local/cache/rss/count
+		if [ $rss -gt 0 ]; then
+			printf '  %s \n' "$rss" > "$statusdir/rss"
+		else
+			printf "" > "$statusdir/rss" 
+		fi
+		sleep 60
+
+	done
+}
+
+battery &
+
+inotifywait -qme close_write --format %f "$statusdir" | while read -r file; do
+	if read -r -- "$file" < "$statusdir/$file"; then
+		printf -- ' %s %%{c} %s %%{r} %s%s%s \n' "$batt" "$groups" "$rss" "$git" "$media"
+	fi
+done | lemonbar -F '#282828' -d -b -f "DejaVu Book:size=9.5" -f "Symbola:size=9.5" -f "FreeSans:size=9.5"
\ No newline at end of file
--- /dev/null
+++ b/size
@@ -1,0 +1,5 @@
+width=1363
+height=751
+gaps=6
+fulw=1354
+fulh=743
--- /dev/null
+++ b/stack
@@ -1,0 +1,40 @@
+#!/usr/bin/env bash
+# Handler to push window to top of stack
+
+unset MAPPED
+
+# If we call a tab by name
+if [[ $1 ]]; then
+
+  lsgrp 2 | xargs mapw -u
+  
+  while read -r id; do
+    if watom "$id" WM_NAME | grep -i "$1"; then
+      MAPPED="$id"
+    fi
+  done < <(lsw -a)
+  
+  if [[ $MAPPED ]]; then  
+    chwso -r "$MAPPED"
+    mapw  -m "$MAPPED"
+  fi
+
+# Toggle group visibilty
+else
+  
+  while read -r id; do
+    if wattr m "$id"; then
+      MAPPED="$id"
+    fi
+    mapw -u "$id"
+  done < <(lsgrp 2)
+
+  # Toggle off
+  if [[ $MAPPED ]]; then
+    chwso -r "$MAPPED"
+  else
+    # Toggle on top window in stack
+    mapw -m "$(lsgrp 2 | tail -n 1)"
+  fi
+
+fi
--- /dev/null
+++ b/watcher
@@ -1,0 +1,21 @@
+#!/bin/sh
+DIR=$XDG_DATA_HOME/x11
+
+wew | while read -r ev; do
+	wid=`echo "$ev" | sed 's/.*://'`
+    case "$ev" in
+		18*) $DIR/wshuf | xargs -n 5 wtp
+			wtf `lsw | tail -n1`
+			$DIR/groupsbar           ;;
+		19*) $DIR/wshuf | xargs -n 5 wtp
+			$DIR/autotag "$wid"
+			wtf "$wid"
+			$DIR/groupsbar           ;;
+		17*) wtf `lsw | tail -n1`
+			if watom `lsw -r` FS | grep "$wid"; then
+				xprop -root -remove FS
+				$DIR/wshuf | xargs -n 5 wtp
+			fi
+			$DIR/groupsbar           ;;
+	esac
+done
--- /dev/null
+++ b/wshuf
@@ -1,0 +1,28 @@
+#!/bin/sh
+# Requires https://github.com/wmutils
+
+# directory of files that correlate to window names
+WIN="$XDG_CONFIG_HOME"/x11/windows
+
+getname() {
+	cd $WIN
+	for i in *; do
+		watom "$1" WM_NAME | grep -io "$i" && break
+	done
+}
+
+winsize() {
+	while read -r id; do
+		name=`getname $id`
+		test -f $WIN/$name && . $WIN/$name || . $WIN/default
+	done
+}
+
+## Main ##
+# window dimensions and gap
+if watom `lsw -r` FS 2>/dev/null; then
+	exit 0
+fi
+
+. "$XDG_CONFIG_HOME"/x11/size && [ ! $width ] && [ ! $heigh ] && exit 1
+lsw | winsize | binpack -x "$width" -y "$heigh" -g "$gaps"