Commits

Jhonny5  committed 5483920

Added dzen botton bar: first code.

  • Participants
  • Parent commits 25188f8

Comments (0)

Files changed (15)

File dzen2/notify

+#!/bin/sh
+
+MSG=$1
+LINE_COUNT=`echo "$MSG" | wc -l`
+
+FONT="-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*"
+BG="#ffffff"
+FG="#224488"
+DELAY=10
+X=1600
+Y=20
+WIDTH=300
+
+echo $1 | dzen2 -l `expr $LINE_COUNT - 1` -x $X -y $Y -w $WIDTH -fn $FONT -bg $BG -fg $FG -ta l -sa l -e 'onstart=uncollapse;button1=exit' -p $DELAY

File dzen2/startdzen

+#!/bin/sh
+
+SLEEP=2
+ICON_PATH='$HOME/.dwm/dzen2/xbm'
+ICON_COLOR='#224488'
+BG='#101010'
+FG='#ffffff'
+NORMAL_COLOR='^fg()'
+GRAY_COLOR='^fg(#555555)'
+CLEAR_COLOR='^fg()'
+X=0
+Y=1060
+HEIGHT=13
+WIDTH=1920
+FONT='-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*'
+
+#WIDTH=1000
+#FONT='-*-monaco-medium-r-*-*-16-*-*-*-*-*-*-*'
+
+
+MIXER="Master"
+
+STAT_BEFORE=`cat /proc/stat | head -n 5`
+
+# min
+#WEATHER_UPDATE_INTERVAL=10
+#let "TEMP_MAX=${WEATHER_UPDATE_INTERVAL}*60*60"
+#TEMP_COUNT=${TEMP_MAX}
+#temp file
+#WEATHER_TEMP=$(/bin/mktemp)
+
+icon() {
+    echo -n "   ^fg($ICON_COLOR)^i($ICON_PATH/$1.xbm)^fg() "
+}
+
+text() {
+    echo -n $GRAY_COLOR$1$CLEAR_COLOR
+}
+
+sleep 0.01
+getCoreLoadPercent() {
+    CORE=$1
+
+    BEFORE=`echo "$STAT_BEFORE" | grep "^cpu$CORE "`
+    AFTER=`echo "$STAT_AFTER" | grep "^cpu$CORE "`
+
+    # парсим колонки
+    USER0=`echo "$BEFORE" | awk '{ print $2 }'`
+    USER1=`echo "$AFTER" | awk '{ print $2 }'`
+    NICE0=`echo "$BEFORE" | awk '{ print $3 }'`
+    NICE1=`echo "$AFTER" | awk '{ print $3 }'`
+    SYST0=`echo "$BEFORE" | awk '{ print $4 }'`
+    SYST1=`echo "$AFTER" | awk '{ print $4 }'`
+    IDLE0=`echo "$BEFORE" | awk '{ print $5 }'`
+    IDLE1=`echo "$AFTER" | awk '{ print $5 }'`
+
+    # разность
+    USER=`expr $USER1 - $USER0`
+    NICE=`expr $NICE1 - $NICE0`
+    SYST=`expr $SYST1 - $SYST0`
+    IDLE=`expr $IDLE1 - $IDLE0`
+
+    # сумма разностей
+    TOTAL=`expr $USER + $NICE + $SYST + $IDLE`
+    USED=`expr $USER + $NICE + $SYST`
+
+    # средняя загрузка за интервал времени в процентах
+    echo "$USED * 100 / $TOTAL" | bc
+}
+
+getCpuload() {
+    STAT_AFTER=`cat /proc/stat | head -n 5`
+    CORE0=`getCoreLoadPercent 0`
+    CORE1=`getCoreLoadPercent 1`
+    CORE2=`getCoreLoadPercent 2`
+    CORE3=`getCoreLoadPercent 3`
+
+    STAT_BEFORE=$STAT_AFTER
+
+    icon 'cpu'
+    echo -n $CORE0%
+    text ' / '
+    echo -n $CORE1%
+    text ' / '
+    echo -n $CORE2%
+    text ' / '
+    echo -n $CORE3%
+}
+
+getTemp() {
+    icon 'temp'
+    CPU1_TEMP=`sensors | tail -n 7|head -n 1|awk '{print $3}'`
+    CPU2_TEMP=`sensors | tail -n 6|head -n 1|awk '{print $3}'`
+    MB_TEMP=`sensors | tail -n 6 | sed -ne 's/MB Temperature: \+[-+]\([0-9]\+\).*/\1/p'`
+    
+    text 'Core 1: '
+    echo -n "$CPU1_TEMP°"
+    text ' Core 2: '
+    echo -n "$CPU2_TEMP°"
+
+
+    
+    #CPU_TEMP=`sensors | tail -n 6 | sed -ne 's/CPU Temperature: \+[-+]\([0-9]\+\).*/\1/p'`
+    #MB_TEMP=`sensors | tail -n 6 | sed -ne 's/MB Temperature: \+[-+]\([0-9]\+\).*/\1/p'`
+    #text 'CPU: '
+    #echo -n "$CPU_TEMP°C"
+    #text ', MB: '
+    #echo -n "$MB_TEMP°C"
+}
+
+getMem() {
+    icon 'mem'
+    # %
+    MEM_USAGE_PERCENT=`free -om | awk '/Mem:/ {print int(($3 - $7 - $6) / $2  * 100)}'`
+    # Mb
+    MEM_USAGE_MB=`free -om | awk '/Mem:/ {print int($3 - $7 - $6)}'`
+    echo -n "$MEM_USAGE_PERCENT% $(text '(')$MEM_USAGE_MB MB$(text ')')"
+}
+
+getFs() {
+    echo -n '^ca(1,~/sft/dwm/dzen/fs-popup.sh)'
+    icon 'tall'
+    echo -n '^ca()'
+
+    text 'home: '
+    echo -n `df -h | grep sda5 | awk '{ print $5 }'`
+
+    text ', root: '
+    echo -n `df -h | grep sda6 | awk '{ print $5 }'`
+
+}
+
+INTERFACE=wlan0
+# Here we remember the previous rx/tx counts
+RXB=`cat /sys/class/net/$INTERFACE/statistics/rx_bytes`
+TXB=`cat /sys/class/net/$INTERFACE/statistics/tx_bytes`
+
+getNet() {
+    # get new rx/tx counts
+    RXBN=`cat /sys/class/net/$INTERFACE/statistics/rx_bytes`
+    TXBN=`cat /sys/class/net/$INTERFACE/statistics/tx_bytes`
+
+    # calculate the rates
+    # format the values to 4 digit fields
+    RXR=`echo "($RXBN - $RXB) / 1024 / $SLEEP" | bc -l | xargs printf "%.2f"`
+    TXR=`echo "($TXBN - $TXB) / 1024 / $SLEEP" | bc -l | xargs printf "%.2f"`
+
+    icon 'wired'
+    echo -n "^fg(#67b15f)^i($ICON_PATH/net_down.xbm)^fg() $RXR kB/s ^fg(#785038)^i($ICON_PATH/net_up.xbm)^fg() $TXR kB/s"
+
+    # reset old rates
+    RXB=$RXBN; TXB=$TXBN
+}
+
+#getWeather() {
+#    icon 'load'
+#
+#    ((TEMP_COUNT++))
+#    if [ ${TEMP_COUNT} -gt ${TEMP_MAX} ]; then
+#        TEMP_COUNT=0
+#        # city code http://informer.gismeteo.ru/getcode/xml.php
+#        # moscow
+#        TEMP_MSL=`curl -s "http://informer.gismeteo.ru/rss/27612.xml" | egrep "description" | head -n 2 | tail -n 1 | awk -F 'температура ' '{ print $2 }' | awk '{ print $1 }'`
+#        # irkutsk id = 30710
+#    fi
+#
+#    text 't°C: '
+#    echo -n $TEMP_MSK
+#}
+
+MAILDIR='/home/qbbr/Mail/GMail/INBOX/new/'
+
+getMail() {
+    icon 'mail'
+    COUNT=`ls -1 ${MAILDIR} | wc -l`
+    if [ "$COUNT" = 0 ]; then
+        text $COUNT
+    else
+        echo -n $COUNT
+    fi
+}
+
+getVolume() {
+    VOLUME=`amixer sget $MIXER  | grep Mono\: | sed -e s/"  Mono: Playback [0-9]* \["// -e s/"\%.*"//`
+    VOLUME_ON=`amixer sget $MIXER | sed -ne 's/.*\ \[\([^]]*\).*/\1/p'`
+
+    echo -n '^ca(1,~/scrpts/volumechanger.sh -t)'
+    if [ "$VOLUME_ON" = "on" ]; then
+        icon 'volume'
+    else
+        icon 'volume-mute'
+    fi
+    echo -n '^ca()'
+
+    echo -n "$VOLUME%"
+}
+
+getMpd() {
+    icon 'mpd'
+    if [ "`mpc | head -c 6`" = "volume" ]; then
+        text '[stoped]'
+    else
+        echo -n `mpc | head -n 1`
+    fi
+}
+
+while :; do
+    getCpuload
+    getTemp
+    getMem
+    getFs
+    getNet
+    #getWeather
+    #getMail
+    #getVolume
+    #getMpd
+
+    echo ''
+
+    sleep $SLEEP
+done | dzen2 -x $X -y $Y -w $WIDTH -h $HEIGHT -bg $BG -fg $FG -ta c -fn $FONT -p

File dzen2/xbm/cpu.xbm

+#define load_cpu_width 16
+#define load_cpu_height 16
+static unsigned char load_cpu_bits[] = {
+   0x00, 0x00, 0x48, 0x12, 0x48, 0x12, 0xfc, 0x3f, 0xfc, 0x3f, 0xfe, 0x7f,
+   0x1c, 0x38, 0x1c, 0x38, 0x1e, 0x78, 0x1c, 0x38, 0xfc, 0x3f, 0xfe, 0x7f,
+   0xfc, 0x3f, 0x48, 0x12, 0x48, 0x12, 0x00, 0x00 };

File dzen2/xbm/load.xbm

+#define load_width 16
+#define load_height 16
+static unsigned char load_bits[] = {
+   0x00, 0x00, 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40,
+   0x02, 0x44, 0x02, 0x4a, 0x02, 0x71, 0x8e, 0x40, 0x52, 0x40, 0x22, 0x40,
+   0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0x00, 0x00 };

File dzen2/xbm/mail.xbm

+#define mail_width 15
+#define mail_height 15
+static unsigned char mail_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x06, 0x30, 0x0e, 0x38, 0x1a, 0x2c,
+   0x32, 0x26, 0xc2, 0x21, 0x82, 0x20, 0x02, 0x20, 0x02, 0x20, 0xfe, 0x3f,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

File dzen2/xbm/mem.xbm

+#define load_mem_width 16
+#define load_mem_height 16
+static unsigned char load_mem_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x12, 0x48, 0x12, 0xfc, 0x3f,
+   0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0x48, 0x12,
+   0x48, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

File dzen2/xbm/mpd.xbm

+#define mpd_width 16
+#define mpd_height 16
+static unsigned char mpd_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x40, 0x10,
+   0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x70, 0x1c, 0x78, 0x1e,
+   0x30, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

File dzen2/xbm/net_down.xbm

+#define arr_down_width 12
+#define arr_down_height 12
+static unsigned char arr_down_bits[] = {
+   0x00, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0xe0, 0x00,
+   0xe0, 0x00, 0xf8, 0x03, 0xf0, 0x01, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00};

File dzen2/xbm/net_up.xbm

+#define arr_up_width 12
+#define arr_up_height 12
+static unsigned char arr_up_bits[] = {
+   0x00, 0x00, 0x40, 0x00, 0xe0, 0x00, 0xf0, 0x01, 0xf8, 0x03, 0xe0, 0x00,
+   0xe0, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0xe0, 0x00, 0x00, 0x00};

File dzen2/xbm/tall.xbm

+#define tall_width 12
+#define tall_height 12
+static unsigned char tall_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x7e, 0x07, 0x7e, 0x07, 0x7e, 0x00, 0x7e, 0x07,
+   0x7e, 0x07, 0x7e, 0x00, 0x7e, 0x07, 0x7e, 0x07, 0x00, 0x00, 0x00, 0x00};

File dzen2/xbm/temp.xbm

+#define temp_width 16
+#define temp_height 16
+static unsigned char temp_bits[] = {
+   0x00, 0x00, 0x80, 0x01, 0xc0, 0x0b, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x0b,
+   0x40, 0x02, 0x40, 0x02, 0x40, 0x0a, 0x40, 0x02, 0x40, 0x02, 0x60, 0x06,
+   0x20, 0x04, 0x60, 0x06, 0xc0, 0x03, 0x00, 0x00 };

File dzen2/xbm/volume-mute.xbm

+#define vol_mute2_width 16
+#define vol_mute2_height 16
+static unsigned char vol_mute2_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0xc0, 0x01, 0xfc, 0x01,
+   0xfc, 0x01, 0xfc, 0x29, 0xfc, 0x11, 0xfc, 0x29, 0xfc, 0x01, 0xc0, 0x01,
+   0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 };

File dzen2/xbm/volume.xbm

+#define vol_hi2_width 16
+#define vol_hi2_height 16
+static unsigned char vol_hi2_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x80, 0x21, 0xc0, 0x49, 0xfc, 0x51,
+   0xfc, 0x55, 0xfc, 0x55, 0xfc, 0x55, 0xfc, 0x55, 0xfc, 0x51, 0xc0, 0x49,
+   0x80, 0x21, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00 };

File dzen2/xbm/wired.xbm

+#define network_eth2_width 16
+#define network_eth2_height 16
+static unsigned char network_eth2_bits[] = {
+   0x00, 0x00, 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0xc2, 0x43, 0xc2, 0x43,
+   0xc2, 0x43, 0xf2, 0x4f, 0xf2, 0x4f, 0xf2, 0x4f, 0xf2, 0x4f, 0xf2, 0x4f,
+   0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0x00, 0x00 };

File startx/deploy.sh

-#!/bin/sh
-
-sudo cp dwm-start /usr/local/bin/