Personal tools

Xmonad/Config archive/Josh Rickmar's dzenscript

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m
(Rewrote script in sh instead of zsh for better portability.)
Line 1: Line 1:
-
This zsh script handles the right side of my statusbar. It shows my system using uname, my currently playing song from XMMS2, and the date and time.
+
This script handles the right side of my statusbar. It shows my system using uname, my currently playing song from XMMS2, and the date and time.
-
<pre>#!/usr/bin/env zsh
+
<pre>#!/bin/sh
UPDATE=1
UPDATE=1
Line 8: Line 8:
while :; do
while :; do
DATE=`date +"%a %B %d, %I:%M %p"`
DATE=`date +"%a %B %d, %I:%M %p"`
 +
BATTERY=`sysctl -n hw.acpi.battery.life`
# if xmms2d is running
# if xmms2d is running
-
if [[ -n `pgrep xmms2d` ]]; then
+
if pgrep xmms2d > /dev/null ; then
# another if statement, stopped or not
# another if statement, stopped or not
-
if [[ `nyxmms2 status` =~ '^Stopped: ' ]]; then
+
if [ `nyxmms2 status -f "\\${playback_status}"` = "Stopped" ]; then
XMMS2=" ^fg(green)XMMS2 is stopped^fg() |"
XMMS2=" ^fg(green)XMMS2 is stopped^fg() |"
else
else
Line 19: Line 20:
XMMS2=""
XMMS2=""
fi
fi
-
echo "^fg(red)$SYSTEM^fg() |$XMMS2 ^fg(orange)$DATE^fg()"
+
echo "^fg(red)$SYSTEM^fg() |$XMMS2 ^fg(#00FFFF)$BATTERY%^fg() | ^fg(orange)$DATE^fg() "
sleep $UPDATE
sleep $UPDATE
-
done | dzen2 -fn '-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*' -bg '#222222' -fg '#aaaaaa' -w 1370 -ta r -x 950
+
done | dzen2 -fn '-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*' -bg '#222222' -fg '#aaaaaa' -w 840 -ta r -x 840
</pre>
</pre>

Revision as of 20:11, 15 August 2009

This script handles the right side of my statusbar. It shows my system using uname, my currently playing song from XMMS2, and the date and time.

#!/bin/sh

UPDATE=1
SYSTEM=`uname -sr`

while :; do
    DATE=`date +"%a %B %d, %I:%M %p"`
    BATTERY=`sysctl -n hw.acpi.battery.life`
    # if xmms2d is running
    if pgrep xmms2d > /dev/null ; then
        # another if statement, stopped or not
        if [ `nyxmms2 status -f "\\${playback_status}"` = "Stopped" ]; then
            XMMS2=" ^fg(green)XMMS2 is stopped^fg() |"
        else
            XMMS2=" ^fg(green)`nyxmms2 status | grep -Eo '^[^:]+:[^:]+'`^fg() |"
        fi
    else
        XMMS2=""
    fi
    echo "^fg(red)$SYSTEM^fg() |$XMMS2 ^fg(#00FFFF)$BATTERY%^fg() | ^fg(orange)$DATE^fg() "
    sleep $UPDATE
done | dzen2 -fn '-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*' -bg '#222222' -fg '#aaaaaa' -w 840 -ta r -x 840