summaryrefslogtreecommitdiff
path: root/.config/wmii-hg/rbar.sh
blob: 287f4274190ad1ed69a9e81c6d7ca8079302e86b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/hint/bash
if [[ -z "$XDG_RUNTIME_DIR" ]]; then
	printf "XDG_RUNTIME_DIR isn't set\n" >&2
	exit 6
fi

setup_trap() {
	trap "rm -f -- \"\${XDG_RUNTIME_DIR}\"/n/wmii*/rbar/${1}" EXIT
}

write() {
	local dirs=("${XDG_RUNTIME_DIR}"/n/wmii*/rbar/)
	sponge|tee -a "${dirs[@]/%/${1}}" > /dev/null
}

set -eE
shopt -s nullglob
case "$1" in
	1) left-click;;
	2) middle-click;;
	3) right-click;;
	4) scroll-up;;
	5) scroll-down;;
	[0-9][0-9]_*) update "$1";;
esac