summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rwxr-xr-xscripts/x-banish41
-rwxr-xr-xscripts/x-root-clean15
3 files changed, 57 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 36a67b4..aeaee54 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
PREFIX = /usr/local
SRC = x-session.c
X11SRC = x-move-resize.c x-alt-tab.c x-focus-manager.c x-placement-manager.c x-undecorate.c x-window-list.c
+SCRIPTS= scripts/x-banish scripts/x-root-clean
CC = gcc
CFLAGS = -O2 -Wall -std=c99 -pedantic
diff --git a/scripts/x-banish b/scripts/x-banish
new file mode 100755
index 0000000..47208d3
--- /dev/null
+++ b/scripts/x-banish
@@ -0,0 +1,41 @@
+#!/bin/bash
+dir="${HOME}/.wm-banished"
+programs_to_stop='(surf|acroread)'
+
+pid() {
+ action=$1
+ wid=$2
+ pid=$( xdotool getwindowpid $wid )
+ ps h -p $pid | grep -qsE "$programs_to_stop" || return 0
+ case $action in
+ stop) kill -STOP $pid;;
+ cont) kill -CONT $pid;;
+ esac
+}
+
+[[ ! -d $dir ]] && mkdir -p $dir
+
+[[ "$1" = "clean" ]] && {
+ for i in $dir/*; do
+ [[ -f "$i" ]] && rm "$i"
+ done
+ exit 0
+}
+
+[[ "$1" = "push" ]] && {
+ w_id=$( xdotool search --maxdepth 1 --onlyvisible . 2>/dev/null | tail -1 )
+ xdotool windowunmap $w_id
+ pid "stop" $w_id
+ echo "banished $(xdotool getwindowname $w_id)" | ~/bin/dmenu.sh
+ touch "${dir}/${w_id}"
+ exit 0
+}
+
+w_id=$( ls -tr $dir | tail -1)
+[[ "$w_id" = "" ]] && {
+ exit 0
+}
+pid "cont" $w_id
+xdotool windowmap $w_id windowraise
+xdotool windowraise $w_id
+rm -f "${dir}/${w_id}"
diff --git a/scripts/x-root-clean b/scripts/x-root-clean
new file mode 100755
index 0000000..25fcbf4
--- /dev/null
+++ b/scripts/x-root-clean
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# chromium will spew windows into root, which breaks x-alt-tab, so clean them up
+#
+pattern="$1"; shift
+
+x-window-list | awk -v parent="" -v pattern="$pattern - " '
+ if ( match($0, pattern)) {
+ wid = $3;
+ if ( parent == "") {
+ parent = wid;
+ } else {
+ system(sprintf("xdotool windowreparent %s %s", wid, parent));
+ }
+ }'