From 66ad0da9c96c6598104460572ae394a0ffdfc0f6 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Fri, 5 Jun 2015 01:04:15 +0200 Subject: [PATCH] =?UTF-8?q?Popups=20mit=20dzen2=20hinzugef=C3=BCgt=20yay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/bar.sh | 56 +++++++++++++++++++++++++++++----------------- scripts/barinfo.sh | 53 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 21 deletions(-) create mode 100755 scripts/barinfo.sh diff --git a/scripts/bar.sh b/scripts/bar.sh index 1a71221..7a45cd3 100755 --- a/scripts/bar.sh +++ b/scripts/bar.sh @@ -1,5 +1,7 @@ #!/bin/bash +cd $(dirname $0) + icon_color="#A0A57E" icon() { echo -n "%{F$icon_color}"; printf '%b' "\ue$1"; echo -n "%{F-}"; } @@ -18,14 +20,16 @@ color_battery_good="white" color_battery_low="#C37561" music() { - info=$(mpc current -f '[%artist%] - [%title%]') + info=$(mpc current -f '[%title%]') icon=$icon_music - if [ -z "$info" ]; then - info="(-)" - elif [ -n "$(mpc status | grep paused)" ]; then - icon=$icon_music_paused + if [ -n "$info" ]; then + if [ -n "$(mpc status | grep paused)" ]; then + icon=$icon_music_paused + fi + echo -n "%{A:I "music 20":}$icon $info%{A}" + else + echo -n "$icon (-)" fi - echo -n "$icon $info" } serviceinfo() { @@ -44,43 +48,53 @@ services() { } diskspace() { - echo -n "$icon_diskspace " - df -h | awk '{if($6 == "/") { print $3 " / " $2 }}' + info=$(df -h / | awk '{if($6 == "/") { print $5 }}') + echo -n "%{A:I "filesystem 30":}$icon_diskspace $info%{A}" } wifi() { - echo -n "$icon_wifi " - info=$(wicd-cli --wireless --status | perl -e 'foreach $line (<>) { if($line =~ /Connected to (.+) at .+IP: ([0-9.]+)/ ) { print $1 . " - " . $2; break; } elsif($line =~ /Connecting to wireless network \"(.+)\"/) { print $1 . " - connecting"; break; } }') + info=$(wicd-cli --wireless --status | perl -e 'foreach $line (<>) { if($line =~ /Connected to (.+) at .+IP: ([0-9.]+)/ ) { print $1; break; } elsif($line =~ /Connecting to wireless network \"(.+)\"/) { print $1 . " - connecting"; break; } }') if [ -z "$info" ]; then info="(-)" fi - echo -n $info + echo -n "%{A:I "network 1061":}$icon_wifi $info%{A}" } battery() { level=$(acpi -b | awk -F, 'BEGIN { s=0 } { s+=$2 } END { print int(s/NR) }') - charging=$(acpi -b | grep Charging) + charging=$(acpi -a | grep on-line) + + icon=$icon_battery if [ -n "$charging" ]; then echo -n "$icon_battery_charging " - else - echo -n "$icon_battery " fi - + info="%{F$color_battery_good}$level%%{F-}" if [ "$level" -lt 20 ]; then echo -n "%{F$color_battery_low}$level%%{F-}" - else - echo -n "%{F$color_battery_good}$level%%{F-}" fi + + echo -n "%{A:I "battery 1061":}$icon $info%{A}" } clock() { - echo -n "$icon_clock " - date +"%a %d.%m (%V) %H:%M" + info=$(date +"%H:%M") + echo -n "%{A:I "clock 1061":}$icon_clock $info%{A}" } +run_handler() { + while read type param; do + case $type in + I) + pkill dzen2 + ./barinfo.sh $param & + ;; + esac + done +} + + while true; do echo "%{l} $(music) $(services) $(diskspace)%{r}$(wifi) $(battery) $(clock) " sleep 1 -done | lemonbar -g 1366x15 -f "Terminus:size=8","Stlarch:size=6:style=regular" -B "#88000000" - +done | lemonbar -g 1366x15 -f "Terminus:size=8","Stlarch:size=6:style=regular" -B "#88000000" | run_handler diff --git a/scripts/barinfo.sh b/scripts/barinfo.sh new file mode 100755 index 0000000..09bdde3 --- /dev/null +++ b/scripts/barinfo.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +HEADER_COLOR="#A0A57E" + +header(){ + echo "^fg($HEADER_COLOR)$1^fg()" +} + +### Filesystem info + +filesystem() { + header "Diskspace" + for d in / /boot; do + df -h $d | tail -n 1 | awk '{printf "%-15s%10s%10s/%s\n",$6, $5, $3, $2}' + done +} + +### Network info +network() { + header "Network" + wicd-cli --status +} + +### Music info +music() { + header "Music" + mpc current -f "$(header Artist:) %artist%\n$(header Album:) %album%\n$(header Title:) %title%" +} + +### Battery info +battery() { + header "Battery" + acpi -abt +} + +### Clock info +clock() { + header "Clock" + date +"%A %d.%m.%Y" + date +"$(header KW:) %V" +} + +### RUN CODE + +if [ $# -lt 2 ]; then + echo "$0 " + exit 1 +fi + +DATA=`$1` +LINES=$[ $(echo "$DATA" | wc -l)-1 ] + +echo "$DATA" | dzen2 -p -e 'onstart=uncollapse;button1=exit' -x "$2" -y 20 -w 300 -l $LINES -ta left