guest@dotshare [~/groups/info/dzen2] $ ls minimal-yet-extensive/ | cat

minimal yet extensive (scrot, raw, dl) (+7 likes)

foozer Jan 03, 2013 (info/dzen2)

SCROT

  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
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
#!/bin/bash

# -------------------------------------------- VARIABLES

FG_COLOR="#aaaaaa"
BG_COLOR="#111111"
WIDTH=700
HEIGHT=16
X=700
Y=0
TEXT_ALIGNMENT="right"
FONT="-*-terminus-*-r-*-*-*-*-*-*-*-*-*-*"

ICON_COLOR="#78a4ff"
SEP="^fg(#2a2a2a) | ^fg()"

BAR_STYLE="-w 33 -h 10 -s o -ss 1 -sw 4 -nonl"
BAR_FG_COLOR=$FG_COLOR
BAR_BG_COLOR="#333333"

NOW_PLAYING_ICON="/home/rolf/.icons/dzen/note.xbm"
NOW_PLAYING_FORMAT="%a - %t"

BATTERY_CHARGING_ICON="/home/rolf/.icons/dzen/bat_full_01.xbm"
BATTERY_DISCHARGING_ICON="/home/rolf/.icons/dzen/bat_low_01.xbm"
BATTERY_MISSING_ICON="/home/rolf/.icons/dzen/ac_01.xbm"
BATTERY_CRITICAL_PERCENTAGE=10
BATTERY_CRITICAL_FG_COLOR="#220000"
BATTERY_CRITICAL_BG_COLOR="#660000"

WIRELESS_ICON="/home/rolf/.icons/dzen/wifi_01.xbm"
WIRELESS_CLIENT="wicd-client"

VOLUME_ICON="/home/rolf/.icons/dzen/spkr_01.xbm"

CLOCK_ICON="/home/rolf/.icons/dzen/clock.xbm"
CLOCK_FORMAT="%H:%M"

# -------------------------------------------- FUNCTIONS

icon() {
	echo "^fg($ICON_COLOR)^i($1)^fg()"
}

bar() {
	echo $1 | gdbar $BAR_STYLE -fg $BAR_FG_COLOR -bg $BAR_BG_COLOR
}

now_playing() {
	ncmpcpp --now-playing "$NOW_PLAYING_FORMAT"
}

battery_icon() {
	if [ "$battery_status" == "Charging" ]; then
		icon "$BATTERY_CHARGING_ICON"
	elif [ "$battery_status" == "Discharging" ]; then
		icon "$BATTERY_DISCHARGING_ICON"
	else
		icon "$BATTERY_MISSING_ICON"
	fi
}

battery_percentage() {
	percentage=$(acpi -b | cut -d "," -f 2 | tr -d " %")
	if [ -z "$percentage" ]; then
		echo "AC"
	elif [ $percentage -le $BATTERY_CRITICAL_PERCENTAGE ] && [ $battery_status == "Discharging" ]; then
		echo 100 | gdbar $BAR_STYLE -fg $BATTERY_CRITICAL_FG_COLOR -bg $BATTERY_CRITICAL_BG_COLOR
	else
		bar "$percentage"
	fi
}

battery() {
	battery_status=$(acpi -b | cut -d ' ' -f 3 | tr -d ',')
	echo $(battery_icon) $(battery_percentage)
}

wireless_quality() {
	quality_bar=$(bar "$(cat /proc/net/wireless | grep wlan0 | cut -d ' ' -f 6 | tr -d '.')")
	echo "^ca(3, $WIRELESS_CLIENT)$quality_bar^ca()"
}

volume() {
	volume=$(amixer get Master | egrep -o "[0-9]+%" | tr -d "%")
        echo -n "^ca(1, amixer -q set Master 5%-)^ca(3, amixer -q set Master 5%+)^ca(2, amixer -q set Master toggle)"
        if [ -z "$(amixer get Master | grep "\[on\]")" ]; then
                echo -n "$(echo $volume | gdbar $BAR_STYLE -bg $BAR_BG_COLOR -fg $BAR_BG_COLOR)"
        else
                echo -n "$(bar $volume)"
        fi
        echo "^ca()^ca()^ca()"
}

clock() {
	echo $(date +$CLOCK_FORMAT)
}

# -------------------------------------------- SCRIPT EXECUTION LOOP, PIPED INTO DZEN2

while :; do
	echo -n "$(icon $NOW_PLAYING_ICON) $(now_playing)$SEP"
	echo -n "$(battery)$SEP"
	echo -n "$(icon $WIRELESS_ICON) $(wireless_quality)$SEP"
	echo -n "$(icon $VOLUME_ICON) $(volume)$SEP"
	echo "$(icon $CLOCK_ICON) $(clock) "
	sleep 3
done | dzen2 -fg $FG_COLOR -bg $BG_COLOR -ta $TEXT_ALIGNMENT -w $WIDTH -h $HEIGHT -x $X -y $Y -fn $FONT

CLICK TO VIEW

x

Notes

Some features, with the default variables:

  • The battery bar becomes red when under 10%.
  • The volume bar becomes dark gray when muted.
  • The wireless bar spawns wicd-client when right-clicked.
  • The volume bar decreases when left-clicked, increases when right-clicked and mutes when middle-clicked.

Requirements:

  • dzen2 0.9.5
  • gdbar (for battery, wireless and volume)
  • ALSA (for volume)
  • mpd/ncmpcpp (for now playing)

I can still think of some stuff to add, but I’m satisfied enough for now.
Hope you enjoy!

Comments

dmatlack said about 11 years ago

Where did you get the icons?

foozer said about 11 years ago