commit - c0109344e9d48ed692362837c6e1839a16250817
commit + 405b666060e19233b82d27b95b39d02047a6b0e9
blob - 26f4f8e55d42727ae395a0e8598a3d7e3af9d642
blob + e5bc5e50c77a6ac273d69b906a6e082ce03bb861
--- config/herbstluftwm/autostart.lp
+++ config/herbstluftwm/autostart.lp
add the tags
- hc rename default "0" || true
+ hc rename default "1" || true
addtag() {
hc add $1
if [ ! -z "$2" ]; then
- hc keybind "$Mod-$2" use_index $1
- hc keybind "$Mod-Shift-$2" move_index $1
+ hc keybind "$Mod-$2" use $1
+ hc keybind "$Mod-Shift-$2" move $1
fi
}
- addtag 0 ampersand
- addtag 1 braceleft
- addtag 2 bracketleft
- addtag 3 parenleft
- addtag 4 equal
- addtag 5 plus
- addtag 6 parenright
- addtag 7 bracketright
- addtag 8 braceright
- addtag 9 exclam
+ addtag 1 ampersand
+ addtag 2 braceleft
+ addtag 3 bracketleft
+ addtag 4 parenleft
+ addtag 5 equal
+ addtag 6 plus
+ addtag 7 parenright
+ addtag 8 bracketright
+ addtag 9 braceright
+ addtag 0 exclam
cycle through tags
mouse bindings
hc mouseunbind --all
- hc mousebind $Mod-Button1 move
+ hc mousebind $Mod-Button1 move
hc mousebind $Mod-Button2 zoom
hc mousebind $Mod-Button3 resize
herbstclient set_monitors $((1920-100))x$((1080-100))+50+50
# hc detect_monitors
-Finally launche the panel on each screen
+Finally launche the panel on each screen. I rewrote the original
+script for the monitor in a mix of rc (the plan9 shell) and awk.
- panel=~/.config/herbstluftwm/panel.sh
- [ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh
+ cd ~/.config/herbstluftwm
for monitor in $(hc list_monitors | cut -d: -f1) ; do
- "$panel" "$monitor" &
+ ./panel "$monitor" &
done
blob - /dev/null
blob + 306b7aebd772814ceac89d1859e238b26994cb9a (mode 644)
--- /dev/null
+++ config/herbstluftwm/event-gen.lp
+# event-gen
+
+This script is the event generator for the bar. The ideas is that
+it sits waiting for stuff to happen (window focus, date change,
+music player, ...)
+
+ #!/usr/bin/env rc
+
+ . ./lib
+
+Kill the player monitor and the date subshell upon exit
+
+ fn quit {
+ kill $datepid
+ kill $playerpid
+ }
+
+ fn siguhp { quit }
+ fn sigint { quit }
+
+The idea behind `uniq_linebuffered' is to avoid refreshing the bar
+every tick if the state doesn't change. It doesn't work for some
+reason however...
+
+ # XXX: for some reasons this don't work
+ fn uniq_linebuffered {
+ awk '$0 != l { print ; l=$0 ; fflush(); }'
+ }
+
+Simulate the tag and play event at the start to force the process
+to update the tags and music info.
+
+ echo tag
+ echo play
+
+Date event generator:
+
+ while () {
+ date=`{date +'%H:%M, %Y-%m-%d'}
+ printf 'date\t%s\n' $"date
+ sleep 10 || break
+ } | uniq_linebuffered &
+ datepid=$apid
+
+Music player event generator:
+
+ amused monitor | egrep --line-buffered '(play|next|prev)' &
+ playerpid=$apid
+
+Window manager event generator:
+
+ hc --idle
+
+Kill everything upon exit
+
+ quit
blob - /dev/null
blob + 368b611a84c0d701e8551458537a2c323d4a8e94 (mode 644)
--- /dev/null
+++ config/herbstluftwm/lib.lp
+# lib
+
+This are some common stuff that needs to be shared between panel
+and event-gen.
+
+ fn hc { herbstclient $* }
+
+ if (~ $"monitor '')
+ monitor=0
+
+ geometry=`{hc monitor_rect $"monitor}
+ if (test -z $"geometry) {
+ echo invalid monitor $monitor
+ exit 1
+ }
+
+ x=$geometry(1)
+ y=$geometry(2)
+ panel_width=$geometry(3)
+ panel_height=16
+
+ font='-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*'
+
+ fn omit-alpha {
+ sed 's,^\(\#[0-9a-f]\{6\}\)[0-9a-f]\{2\}$,\1,'
+ }
+
+ # extract colors from hlwm and omit alpha-value
+ bgcolor=`{hc get frame_border_normal_color | omit-alpha}
+ selbg=`{hc get window_border_active_color | omit-alpha}
+ selfg='#101010'
blob - /dev/null
blob + abd2555aef69cc850bd6d421d7699e1a2a55c731 (mode 644)
--- /dev/null
+++ config/herbstluftwm/panel.lp
+# panel
+
+This is the scripts that creates the bar in my herbstluftwm setup.
+It's written in rc (the plan9 shell) because why not.
+
+ #!/usr/bin/env rc
+
+ monitor=$1
+
+ . ./lib
+
+ hc pad $monitor $panel_height
+
+ fn process {
+ awk -f process.awk \
+ -v selbg=$"selbg \
+ -v selfg=$"selfg \
+ -v font=$"font \
+ -v monitor=$"monitor
+ }
+
+ fn render {
+ dzen2 -w $panel_width -x $x -y $y -h $panel_height \
+ -fn $"font -ta l -bg $"bgcolor -fg '#222222'
+ }
+
+ ./event-gen $"monitor | process | render >[2] /dev/null
blob - /dev/null
blob + c72d405f9d005b8c233a453f7acab2194a4ccc71 (mode 644)
--- /dev/null
+++ config/herbstluftwm/process.awk.lp
+# process.awk
+
+This awk script processes the events generated by `event-gen' and
+outputs the text of the bar for dzen2. It needs some variable to
+be defined on the command line, see `panel'.
+
+ BEGIN {
+ visible = true
+ }
+
+ /^tag/ {
+ cmd = sprintf("herbstclient tag_status %s", monitor)
+ cmd | getline
+ for (i = 1; i <= NF; i++) {
+ tags[i] = $i
+ }
+ close(cmd)
+ }
+
+ /^date/ {
+ $1 = ""
+ date = substr($0, 2)
+ }
+
+ /^quit_panel/ {
+ exit 0
+ }
+
+ /^reload/ {
+ exit 0
+ }
+
+ /^focus_changed/ || /^window_title_changed/ {
+ $1 = ""
+ $2 = ""
+ windowtitle = substr($0, 3)
+ }
+
+ /^play/ || /^next/ || /^prev/ {
+ cmd = "amused status"
+ cmd | getline
+ $1 = ""
+ file = substr($0, 2)
+ close(cmd)
+
+ # poor man basename
+ player = gensub(".*/", "", 1, file)
+ # and strip out the extension
+ player = gensub("\.[A-Za-z0-9]+$", "", 1, player)
+ }
+
+ {
+ for (i = 1; i <= length(tags); i++) {
+ t = tags[i]
+ if (t ~ "^#") {
+ printf("^bg(%s)^fg(%s)", selbg, selfg)
+ } else if (t ~ "^\\+") {
+ printf "^bg(#9CA668)^fg(#141414)"
+ } else if (t ~ "^:") {
+ printf "^bg()^fg(#222222)"
+ } else if (t ~ "^!") {
+ printf "^bg(#FF0675)^fg(#141414)"
+ } else {
+ printf "^bg()^fg(#d6d6d6)"
+ }
+
+ printf(" %s ^bg()^fg()", substr(t, 2))
+ }
+
+ printf("| %s ", date);
+
+ if (player != "") {
+ printf("| %s ", player);
+ }
+
+ printf("| %s ", windowtitle)
+
+ printf("\n", right)
+ fflush()
+ next
+ }
blob - b0289dd28a773e281b2a92c63b2f789dccb7b2c1
blob + 009134c7148a334e646334b841942b290d88bff9
--- gen
+++ gen
pair bin/sshot bin/sshot.lp +x
pair .config/herbstluftwm/autostart config/herbstluftwm/autostart.lp
+pair .config/herbstluftwm/panel config/herbstluftwm/panel.lp +x
+pair .config/herbstluftwm/process.awk config/herbstluftwm/process.awk.lp
+pair .config/herbstluftwm/lib config/herbstluftwm/lib.lp
+pair .config/herbstluftwm/event-gen config/herbstluftwm/event-gen.lp
conv index index.lp
for file in $files; do