Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

monsterwm output to dzen2 or some_sorta_bar

View monsterwm2bar
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
ff="/tmp/monsterwm.fifo"
[[ -p $ff ]] || mkfifo -m 600 "$ff"
 
# desktop names
ds=("web" "dev" "foo" "null")
 
# layout names
ms=("T" "M" "B" "G" "F")
 
while read -t 60 -r wmout || true; do
if [[ $wmout =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]]; then
read -ra desktops <<< "$wmout" && unset r
for desktop in "${desktops[@]}"; do
IFS=':' read -r d w m c u <<< "$desktop"
((c)) && fg="\\f4" i="${ms[$m]}" || fg="\\f3"
((u)) && w+='\f5!'
r+="$fg${ds[$d]} ${w/#0/\\f8-} \\f3:: "
done
r="${r%::*}"
fi
printf "\\\l%s\\\r%s\n" "$r\\f5[\\f3$i\\f5]" "$(date +"%F %R")"
done < "$ff" | bar &
 
# pass output to fifo
monsterwm > "$ff"
View monsterwm2bar
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/usr/bin/env bash
 
# create a fifo to send output
ff="/tmp/monsterwm.fifo"
[[ -p $ff ]] || mkfifo -m 600 "$ff"
 
while read -r; do
# filter output to only what we want to match and parse
[[ $REPLY =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]] && read -ra desktops <<< "$REPLY" || continue
for desktop in "${desktops[@]}"; do
# set values for
# d - the desktop id
# w - number of windows in that desktop
# m - tiling layout/mode for that desktop
# c - whether that desktop is the current (1) or not (0)
# u - whether a window in that desktop has an urgent hint set (1) or not (0)
IFS=':' read -r d w m c u <<< "$desktop"
# name each desktop
case $d in
0) d="web" s="" ;;
1) d="dev" s="::" ;;
2) d="foo" s="::" ;;
esac
# the current desktop color should be #d11783
# we will also display the current desktop's tiling layout/mode
((c)) && f="#d11783" && case $m in
# name each layout/mode with a symbol
0) i="[T]" ;;
1) i="[M]" ;;
2) i="[B]" ;;
3) i="[G]" ;;
esac || f="#5e7175"
 
# if the desktop has an urgent hint its color should be #ff0000
((u)) && f="#ff0000"
 
# if the desktop has windows print that number next to the desktop name
# else just print the desktop name
((w)) && r+="$s ^fg($f)$d $w^fg() " || r+="$s ^fg($f)$d^fg() "
done
 
# read from fifo and output to dzen2
printf "%s%s\n" "$r" "$i" && unset r
done < "$ff" | dzen2 -h 18 -w 400 -ta l -e -p -fn "-misc-terminusmod.icons-medium-r-normal--12-120-72-72-c-60-*-*" &
 
# pass output to fifo
monsterwm > "$ff"
View monsterwm2bar
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#!/usr/bin/env bash
 
: "${wm:=$HOME/Projects/monsterwm/monsterwm}"
: "${ff:="/tmp/$RANDOM.monsterwm.fifo"}"
 
tags=('1' '2' '3' '4')
 
layouts=('[]=' '[ ]' 'TTT' '[#]')
 
conky | dzen2 -h 18 -x 320 -ta r -e -p -fn &
 
# Check if it's a pipe, otherwise create it
[[ -p $ff ]] || mkfifo -m 600 "$ff"
 
while read -t 60 -r wmout || true; do
desktops=( $(cut -d"|" -f1 <<< "$wmout") )
title="$(cut -d"|" -f2- <<< "$wmout")"
 
if [[ "${desktops[@]}" =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]]; then
unset tmp
for desktop in "${desktops[@]}"; do
IFS=':' read -r d w m c u <<< "$desktop"
# Tags labels
label="${tags[$d]}"
# Is this the current desktop ? save the layout
((c)) && fg="#fefefe" bg="#204a87" && layout="${layouts[$m]}" \
|| fg="#b3b3b3" bg=""
 
# Has windows ?
((w)) && fg="#fce94f"
 
# Urgent windows ?
((u)) && fg="#ef2929"
 
tmp+="^fg($fg)^bg($bg) $label ^bg()^fg()"
done
fi
 
# Merge the clients indications, the tile and the info
echo "$tmp $layout $title"
done < "$ff" | dzen2 -w 320 -h 18 -ta l -e -p &
 
while :; do "$wm" || break; done | tee -a "$ff"
#$wm > "$ff"
View monsterwm2bar
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#!/usr/bin/env bash
 
# create a fifo to send output
ff="/tmp/monsterwm.fifo"
[[ -p $ff ]] || mkfifo -m 600 "$ff"
 
# desktop names
ds=("web" "dev" "foo" "null")
 
# layout names
ls=("T" "M" "B" "G" "F")
 
while read -t 60 -r wmout || true; do
if [[ $wmout =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]]; then
read -ra desktops <<< "$wmout" && unset r
for desktop in "${desktops[@]}"; do
# set values for
# d - the desktop id
# w - number of windows in that desktop
# m - tiling layout/mode for that desktop
# c - whether that desktop is the current (1) or not (0)
# u - whether a window in that desktop has an urgent hint set (1) or not (0)
IFS=':' read -r d w m c u <<< "$desktop"
# if this is the current desktop, color should be '&4'
# if this is the current desktop, also set the layout name
# else the color should be '&3'
((c)) && fg="&4" i="${ls[$m]}" || fg="&3"
 
# if the desktop has an urgent hint, add an
# exclamation mark '!' with '&5' color
((u)) && w+='&5!'
r+="$fg${ds[$d]} $w &3:: "
done
r="${r%::*}"
fi
 
# read from fifo and output to some_sorta_bar
printf "&L%s&R%s\n" "$r&5[&3$i&5]" "$(date +"%F %R")"
done < "$ff" | some_sorta_bar &
 
# pass output to fifo
monsterwm > "$ff"
Owner

monsterwm :cactus: is a tiny but monsterous dynamic tiling wm by @c00kiemon5ter written in less than 650lines of C

bar :fire: is a @LemonBoy creation, a simple bar written in C/XCB.

some_sorta_bar :zap: is a @moetunes creation, some sort of a bar, written in C/Xlib.

Owner

I use tee to get the output to stdout on the tty/console too.
If you don't want that, then just redirect the output from mosterwm directly to the pipe.

monsterwm > "$ff"

update: this is now the default.

Owner

some_sorta_bar now reads input from stdin instead of xsetroot -name, so it works just like dzen does. Replacing dzen (and its options) with some_sorta_bar (and vice versa) will work the same.

Owner

added friendlier script by @LemonBoy, edited to also include the window titles.

Owner

@livinglifeback I had forgotten a & at the end of the dzen2 call.
the only thing you need to run the script is to make it executable and add

exec /path/to/monsterwm2dzen

in your ~/.xinitrc

Owner

added script to output to bar by @LemonBoy

Also check mstatusbar
Use it as indicated in monsterbar.sh replacing the above scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.