Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 648126dc57b7d6130d455bb2881c1b2e2aa84dfa 0 parents
@w0ng authored
Showing with 162 additions and 0 deletions.
  1. +34 −0 colours
  2. +96 −0 dwm-statusbar
  3. +9 −0 mailrun
  4. +23 −0 startdwm
34 colours
@@ -0,0 +1,34 @@
+#!/bin/bash
+# Script to display terminal colours
+# Original: http://frexx.de/xterm-256-notes/
+# http://frexx.de/xterm-256-notes/data/colortable16.sh
+# Modified by Aaron Griffin
+# and further by Kazuo Teramoto
+FGNAMES=(' black ' ' red ' ' green ' ' yellow' ' blue ' 'magenta' ' cyan ' ' white ')
+BGNAMES=('DFT' 'BLK' 'RED' 'GRN' 'YEL' 'BLU' 'MAG' 'CYN' 'WHT')
+
+echo " ┌──────────────────────────────────────────────────────────────────────────┐"
+for b in {0..8}; do
+ ((b>0)) && bg=$((b+39))
+
+ echo -en "\033[0m ${BGNAMES[b]}"
+
+ for f in {0..7}; do
+ echo -en "\033[${bg}m\033[$((f+30))m ${FGNAMES[f]} "
+ done
+
+ echo -en "\033[0m │"
+ echo -en "\033[0m\n\033[0m │ "
+
+ for f in {0..7}; do
+ echo -en "\033[${bg}m\033[1;$((f+30))m ${FGNAMES[f]} "
+ done
+
+ echo -en "\033[0m │"
+ echo -e "\033[0m"
+
+ ((b<8)) &&
+ echo " ├──────────────────────────────────────────────────────────────────────────┤"
+done
+echo " └──────────────────────────────────────────────────────────────────────────┘"
+
96 dwm-statusbar
@@ -0,0 +1,96 @@
+#!/bin/bash
+# Status bar for dwm (see http://jasonwryan.com/)
+# colors: \x01 grey; \x02 white; \x04 red; \x05 green; \x06 yellow;
+# \x07 blue; \x08 magenta; \x09 cyan
+
+print_last_msg() {
+ last_msg="$(cat ~/.irssi_pipe)"
+ echo -e "\x06Ò ${last_msg}\x01"
+}
+
+print_gmail_unread() {
+ gmail_unread="$(find ~/.maildir/gmail/inbox/new -type f | wc -l)"
+ echo -e "\x06Ó ${gmail_unread}\x01 GM"
+}
+
+print_mq_unread() {
+ mq_unread="$(find ~/.maildir/mq/inbox/new -type f | wc -l)"
+ echo -e "\x06Ó ${mq_unread}\x01 MQ"
+}
+
+print_dropbox_status() {
+ echo -e "\x07Ù $(dropbox status)\x01"
+}
+
+print_mem_used() {
+ mem_used="$(free -m | awk '/buffers\/cache/ {print $3}')"
+ echo -e "${mem_used}M"
+}
+
+print_song_info() {
+ song_info="$(ncmpcpp --now-playing '{{{{%a - }%t}}|{%f}}' | head -c 60)"
+ if [[ ! $song_info ]]; then
+ song_info="Not playing"
+ fi
+echo -e "\x08Î ${song_info}\x01"
+}
+
+print_volume() {
+ volume="$(amixer get Master | tail -n1 | sed -r 's/.*\[(.*)%\].*/\1/')"
+ echo -e "\x09Ô ${volume}%\x01"
+}
+
+print_datetime() {
+ datetime="$(date "+%a %d %b, %I:%M %p")"
+ echo -e "\x02Õ ${datetime}\x01"
+}
+
+
+
+# network (see: http://dzen.geekmode.org/dwiki/doku.php?id=dzen:network-meter)
+# cpu (see:https://bbs.archlinux.org/viewtopic.php?pid=661641#p661641)
+rx_old=$(cat /sys/class/net/eth0/statistics/rx_bytes)
+tx_old=$(cat /sys/class/net/eth0/statistics/tx_bytes)
+
+while true; do
+ # get new cpu idle and total usage
+ eval $(awk '/^cpu /{print "cpu_idle_now=" $5 \
+"; cpu_total_now=" $2+$3+$4+$5 }' /proc/stat)
+ cpu_interval=$((cpu_total_now-${cpu_total_old:-0}))
+ # calculate cpu usage (%)
+ let cpu_used="100 * ($cpu_interval - ($cpu_idle_now-${cpu_idle_old:-0})) \
+/ $cpu_interval"
+
+ # get new rx/tx counts
+ rx_now=$(cat /sys/class/net/eth0/statistics/rx_bytes)
+ tx_now=$(cat /sys/class/net/eth0/statistics/tx_bytes)
+ # calculate the rate (K) and total (M)
+ let rx_rate=($rx_now-$rx_old)/1024
+ let tx_rate=($tx_now-$tx_old)/1024
+ let rx_total=$rx_now/1048576
+ let tx_total=$tx_now/1048576
+
+ # output vars
+ print_cpu_used() { echo -e "\x07Ï ${cpu_used}%\x01"; }
+ print_rx_rate() { echo -e "\x05Ð ${rx_rate}K\x01"; }
+ print_rx_total() { echo -e "${rx_total}M"; }
+ print_tx_rate() { echo -e "\x04Ñ ${tx_rate}K\x01"; }
+ print_tx_total() { echo -e "${tx_total}M"; }
+
+ # Pipe to status bar, not indented due to printing extra spaces/tabs
+ xsetroot -name "Ö $(print_last_msg) Ö \
+$(print_gmail_unread) $(print_mq_unread) Ö \
+$(print_rx_rate) $(print_rx_total) $(print_tx_rate) $(print_tx_total) Ö \
+$(print_cpu_used) $(print_mem_used) Ö \
+$(print_song_info) Ö \
+$(print_volume) Ö \
+$(print_datetime) "
+
+ # reset old rates
+ rx_old=$rx_now
+ tx_old=$tx_now
+ cpu_idle_old=$cpu_idle_now
+ cpu_total_old=$cpu_total_now
+ # loop stats every 1 second
+ sleep 1
+done
9 mailrun
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+PID=$(pgrep offlineimap)
+
+[[ -n "$PID" ]] && kill "$PID"
+
+offlineimap -o -u quiet &>/dev/null &
+
+exit
23 startdwm
@@ -0,0 +1,23 @@
+#!/bin/bash
+# called by xinitrc, restarts dwm without leaving X
+
+xrdb -merge ~/.Xresources &
+
+xset +fp /usr/share/fonts/local
+xset +fp ~/.fonts
+xset fp rehash
+xset s off
+xset dpms 3600 3600 3600
+wmname LG3D
+mpd &
+numlockx &
+tmux &
+dropboxd &
+~/bin/dwm-statusbar &
+
+while true; do
+ # Log stderror to a file
+ dwm 2> ~/.dwm.log
+ # No error logging
+ #dwm >/dev/null 2>&1
+done
Please sign in to comment.
Something went wrong with that request. Please try again.