Merge remote-tracking branch 'gitorious/master' into phoenix

This commit is contained in:
Tom Willemsen 2012-02-06 23:47:14 +01:00
commit 6e999ca93d
8 changed files with 156 additions and 79 deletions

View file

@ -10,7 +10,7 @@ fi
# geometry has the format: WxH+X+Y
x=${geometry[0]}
width=${geometry[2]}
height=1
height=12
y=$(expr ${geometry[3]} - $height)
tag_width=40
font="-misc-tamsyn-medium-r-normal-*-14-*-*-*-*-*-iso8859-*"
@ -25,6 +25,96 @@ function uniq_linebuffered() {
awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
}
function print_tags() {
# draw tags
echo -n "$separator"
for i in "${TAGS[@]}" ; do
if [[ "${TAGS2[@]}" == *"#${i:1}"* ]]; then
echo -n "^bg($selcolor)^fg(#000000) ${i:1} ^fg()^bg()"
# echo -n "^fg($selcolor)^ro(${tag_width}x$height)^fg()"
elif [[ "${TAGS2[@]}" == *"+${i:1}"* ]]; then
echo -n "^bg($locolor)^fg(#000000) ${i:1} ^fg()^bg()"
# echo -n "^fg($locolor)^ro(${tag_width}x$height)^fg()"
else
case ${i:0:1} in
'#')
echo -n "^bg($selcolor)^fg(#000000) ${i:1} ^fg()^bg()"
# echo -n "^fg($selcolor)^ro(${tag_width}x$height)^fg()"
;;
'+')
echo -n "^bg($locolor)^fg(#000000) ${i:1} ^fg()^bg()"
# echo -n "^fg($locolor)^ro(${tag_width}x$height)^fg()"
;;
':')
echo -n "^bg($hicolor)^fg(#000000) ${i:1} ^fg()^bg()"
# echo -n "^fg($hicolor)^ro(${tag_width}x$height)^fg()"
;;
'!')
echo -n "^bg($urcolor)^fg(#000000) ${i:1} ^fg()^bg()"
# echo -n "^fg($urcolor)^ro(${tag_width}x$height)^fg()"
;;
*)
echo -n "^bg($bgcolor)^fg(#ffffff) ${i:1} ^fg()^bg()"
# echo -n "^bg()^fg($bgcolor)^ro(${tag_width}x$height)^fg()"
;;
esac
fi
echo -n "$separator"
done
}
function print_mailboxes() {
mailboxes=(ninthfloor gmail arch aethon ryuslash.org)
mailtxt=""
for j in "${mailboxes[@]}"; do
mailfile="$HOME/documents/mail/$j/INBOX/new/"
mailcnt=$(ls $mailfile | wc -l)
if [ $mailcnt -gt 0 ]; then
mailsha1=$(echo $j | sha1sum)
mailcolor="#${mailsha1:0:6}"
else
mailcolor=$bgcolor
fi
mailtxt="$mailtxt${separator}^bg($mailcolor)^fg(#ffffff) $j ^fg()^bg()"
# echo -n "^fg($mailcolor)^ro(${tag_width}x$height)^fg()$separator"
done
mailtxt_only=$(echo -n "$mailtxt" | sed 's.\^[^(]*([^)]*)..g')
let mailtxt_width=$(textwidth "$font" "$mailtxt_only")+20
echo -n "^p(_RIGHT)^p(-$mailtxt_width)$mailtxt"
}
function print_services() {
services=(emacs httpd mysqld dunst xbindkeys mpdscribble sshd mpd)
servicetxt=""
for j in "${services[@]}"; do
servicetxt="$servicetxt$separator$(status $j)"
done
servicetxt_only=$(echo -n "$servicetxt" | sed 's.\^[^(]*([^)]*)..g')
let servicetxt_width=$(textwidth "$font" "$servicetxt_only")/2
echo -n "^p(_CENTER)^p(-$servicetxt_width)$servicetxt"
}
function status()
{
running=$(${1}_running 2>/dev/null || pidof $1)
if [ -n "$running" ]; then
color="darkgreen"
else
color="darkred"
fi
echo -n "^bg($color)^fg(#ffffff) $1 ^fg()^bg()"
}
function emacs_running()
{
ps ax | awk '{ print $5 " " $6 }' | grep -E "^emacs --daemon"
}
herbstclient pad $monitor -5 -5 $(expr -5 + $height) -5
herbstclient pad $monitor2 -5 -5 -5 -5
{
@ -36,50 +126,10 @@ herbstclient pad $monitor2 -5 -5 -5 -5
TAGS2=( $(herbstclient tag_status $monitor2) )
while true ; do
separator="^fg($bgcolor)^ro(1x$height)^fg()"
# draw tags
echo -n "$separator"
for i in "${TAGS[@]}" ; do
if [[ "${TAGS2[@]}" == *"#${i:1}"* ]]; then
echo -n "^fg($selcolor)^ro(${tag_width}x$height)^fg()"
elif [[ "${TAGS2[@]}" == *"+${i:1}"* ]]; then
echo -n "^fg($locolor)^ro(${tag_width}x$height)^fg()"
else
case ${i:0:1} in
'#')
echo -n "^fg($selcolor)^ro(${tag_width}x$height)^fg()"
;;
'+')
echo -n "^fg($locolor)^ro(${tag_width}x$height)^fg()"
;;
':')
echo -n "^fg($hicolor)^ro(${tag_width}x$height)^fg()"
;;
'!')
echo -n "^fg($urcolor)^ro(${tag_width}x$height)^fg()"
;;
*)
echo -n "^bg()^fg($bgcolor)^ro(${tag_width}x$height)^fg()"
;;
esac
fi
echo -n "$separator"
done
print_tags
print_services
print_mailboxes
mailboxes=(ninthfloor gmail arch aethon ryuslash.org)
echo -n "^p(_RIGHT)^p(-$(expr $tag_width \* ${#mailboxes[@]} + 5))"
for j in "${mailboxes[@]}"; do
mailfile="$HOME/documents/mail/$j/INBOX/new/"
mailcnt=$(ls $mailfile | wc -l)
if [ $mailcnt -gt 0 ]; then
mailsha1=$(echo $j | sha1sum)
mailcolor="#${mailsha1:0:6}"
else
mailcolor=$bgcolor
fi
echo -n "^fg($mailcolor)^ro(${tag_width}x$height)^fg()$separator"
done
echo
# wait for next event
read line || break

View file

@ -1,10 +1,11 @@
# -*- eval: (git-auto-commit-mode 1) -*-
# Playlist
autocenter_mode = "yes"
centered_cursor = "yes"
now_playing_prefix = "$b"
now_playing_suffix = "$/b"
playlist_display_mode = "classic" # (classic/columns)
song_list_format = "{$8%d%n}|{ $8%n}$9 | {$3%a$9 - }{$4%t$9} {$R$5[%b]$9}"
song_list_format = "{$3%a$9 - }{$4%t$9} {$R$5[%b]$9}"
# Bars
display_bitrate = "no"

View file

@ -1,7 +1,7 @@
[general]
# NOTE: cronjob calls the quiet UI with -u
ui = TTYUI
accounts = ryuslash.org,gmail,arch,aethon,iactor,ninthfloor
accounts = ryuslash.org,gmail,arch,aethon,ninthfloor
pythonfile = ~/.offlineimap.py
[Account arch]

View file

@ -1,6 +1,10 @@
;; -*- eval: (git-auto-commit-mode 1) -*-
(use-modules (ice-9 popen)
(ice-9 rdelim))
;;; Modkey
(define modkey 'mod4)
(define dmenu-cmd "dmenu -b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'")
;;; Macros
(define-macro (cmd command)
@ -16,6 +20,56 @@
(main-binding)
(grab-all-keys))
(define (get-tags)
(let* ((file (open-input-pipe
"TAGS=( $(herbstclient tag_status 0 | tr \":\\!.+#\" \" \") ); echo ${TAGS[@]}"))
(tags (string-split (read-line file) #\ )))
(close-port file)
tags))
(define (get-tag tags pipe)
(read-line pipe))
(define (choose-tag prompt tags)
(let* ((file (open-input-pipe
(string-append "echo '" (string-join tags "\n")
"' | " dmenu-cmd " -p '" prompt ":'")))
(tag (read-line file)))
(close-port file)
tag))
(define (switch-tags)
"Switch to another tag"
(let* ((tags (get-tags))
(tag (choose-tag "Switch to tag" tags)))
(if (string? tag)
(begin
(if (not (member tag tags))
(run-command (string-append "herbstclient add " tag)))
(run-command (string-append "herbstclient use " tag))))
(reset-main-binding)))
(define (kill-tag)
"Kill a selected tag"
(let* ((tags (get-tags))
(tag (choose-tag "Kill tag" tags)))
(if (string? tag)
(begin
(if (member tag tags)
(run-command (string-append "herbstclient merge_tag " tag)))))
(reset-main-binding)))
(define (move-to-tag)
"Move selected window to another tag"
(let* ((tags (get-tags))
(tag (choose-tag "Move to tag" tags)))
(if (string? tag)
(begin
(if (not (member tag tags))
(run-command (string-append "herbstclient add " tag)))
(run-command (string-append "herbstclient move " tag))))
(reset-main-binding)))
;;; Maps
(define (main-binding)
"First binding"
@ -41,10 +95,10 @@
"Second binding"
(ungrab-all-keys)
(remove-all-keys)
(xbindkey-function '(b) (cmd "~/bin/switch_tags"))
(xbindkey-function '(b) switch-tags)
(xbindkey-function `(,modkey c) (cmd "herbstclient quit"))
(xbindkey-function `(,modkey r) (cmd "herbstclient reload"))
(xbindkey-function '(k) (cmd "~/bin/kill_tag"))
(xbindkey-function '(k) kill-tag)
(xbindkey-function '("0") (cmd "herbstclient remove"))
(xbindkey-function '("3") (cmd "herbstclient split horizontal 0.5"))
(xbindkey-function '("2") (cmd "herbstclient split vertical 0.5"))
@ -53,7 +107,7 @@
(xbindkey-function '(shift f) (cmd "herbstclient fullscreen toggle"))
(xbindkey-function '(p) (cmd "herbstclient pseudotile toggle"))
(xbindkey-function '(r) resize-map)
(xbindkey-function '(m) (cmd "~/bin/move_to_tag"))
(xbindkey-function '(m) move-to-tag)
(xbindkey-function `(,modkey g) reset-main-binding)
(grab-all-keys))

View file

@ -1,4 +1,5 @@
# -*- mode: shell-script; eval: (git-auto-commit-mode 1) -*-
case
# -*- mode: shell-script; eval: (git-auto-commit-mode 1) -*-
# -----[ Set background ]---------------------------------------------
hsetroot -center ~/pictures/wallpapers/3600x1080/wallpaper-1460625.jpg

View file

@ -1,10 +0,0 @@
#!/bin/zsh
TAGS=( $(herbstclient tag_status 0 | tr ":\!.+#" " ") )
FOO=$(for i in "${TAGS[@]}"; do echo $i; done | dmenu)
if [[ "${TAGS[@]}" == *"$FOO"* ]]; then
herbstclient merge_tag $FOO
else
notify-send "Unknown tag: $FOO"
fi

View file

@ -1,9 +0,0 @@
#!/bin/zsh
. $HOME/bin/hlwm_source
if [[ "${TAGS[@]}" != *" $FOO "* ]]; then
herbstclient add $FOO
fi
herbstclient move $FOO

View file

@ -1,10 +0,0 @@
#!/bin/zsh
TAGS=( $(herbstclient tag_status 0 | tr ":\!.+#" " ") )
FOO=$(for i in "${TAGS[@]}"; do echo $i; done | dmenu)
if [[ "${TAGS[@]}" != *"$FOO"* ]]; then
herbstclient add $FOO
fi
herbstclient use $FOO