os/arch panel: move icons to panel-config; refactor lemons

This commit is contained in:
Henrik Lissner 2016-11-20 20:41:00 -05:00
parent 15a659a961
commit 7e3d550994
7 changed files with 86 additions and 70 deletions

View file

@ -3,35 +3,20 @@
. $(dirname $0)/../panel-config . $(dirname $0)/../panel-config
# No guarantee that it will be called BAT0, but it suits my purposes. # No guarantee that it will be called BAT0, but it suits my purposes.
if ! command -v acpi >/dev/null if ! command -v acpi >/dev/null; then
then
>&2 echo "acpi is not installed, battery segment disabled" >&2 echo "acpi is not installed, battery segment disabled"
exit exit
fi fi
if [ ! -d "/sys/class/power_supply/BAT0" ] if [ ! -d /sys/class/power_supply/BAT0 ]; then
then
>&2 echo "No battery! This must be a PC" >&2 echo "No battery! This must be a PC"
exit exit
fi fi
ICON_BAT0="" while :; do
ICON_BAT1="" data=$(acpi --battery)
ICON_BAT2="" perc=${${${data#*,}%,*}:1:-1}
ICON_BAT3=""
ICON_BAT4=""
ICON_BAT5=""
ICON_BAT6=""
ICON_BAT7=""
ICON_BAT8=""
ICON_BAT9=""
ICON_BATAC=""
while : case $perc in
do
BAT=$(acpi --battery)
PERC=$(echo $BAT | cut -d, -f2)
case "${PERC#??}" in
100|9[0-9]) icon="${ICON_BAT9}" ;; 100|9[0-9]) icon="${ICON_BAT9}" ;;
8[0-9]) icon="${ICON_BAT8}" ;; 8[0-9]) icon="${ICON_BAT8}" ;;
7[0-9]) icon="${ICON_BAT7}" ;; 7[0-9]) icon="${ICON_BAT7}" ;;
@ -43,12 +28,10 @@ do
1[0-9]) icon="%{F$COLOR_1}${ICON_BAT1}%{F-}" ;; 1[0-9]) icon="%{F$COLOR_1}${ICON_BAT1}%{F-}" ;;
*) icon="%{F$COLOR_1}${ICON_BAT0}%{F-}" ;; *) icon="%{F$COLOR_1}${ICON_BAT0}%{F-}" ;;
esac esac
if echo "$BAT" | grep charging >/dev/null echo -n "${icon}"
then [ "${data/ charging/}" == "$data" ] && echo "${ICON_BATAC}"
echo "${icon}${ICON_BATAC}"
else
echo "${icon} "
fi
sleep 15 sleep 15
done done
# vim:set ft=sh:

View file

@ -1,15 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
[ -f ~/.secrets/accounts.sh ] && . ~/.secrets/accounts.sh || exit set -e
. $(dirname $0)/../panel-config CWD=$(dirname $0)
if [[ ! -f ~/.private/config/email ]]; then
>&2 echo "Couldn't load account settings"
exit 1
fi
. ~/.private/config/email
. $CWD/../panel-config
ICON_MAIL="" ICON_MAIL=""
get-mail() { get_mail() {
local feed=$(curl -u "$1:$2" --silent https://mail.google.com/mail/feed/atom) local feed=$(curl -u "$1:$2" --silent https://mail.google.com/mail/feed/atom)
if [ "$(echo $feed | grep -c "<fullcount>")" -eq 1 ] if [[ "${feed//\<fullcount\>/}" != "$feed" ]]; then
then echo "$feed" | grep -o "<entry>" | wc -l
echo $feed | grep -o "<entry>" | wc -l
else else
>&2 echo "mail.sh: error with $1" >&2 echo "mail.sh: error with $1"
ERROR=! ERROR=!
@ -17,14 +23,14 @@ get-mail() {
fi fi
} }
a=$(get-mail "${MAIL1[USER]}" "${MAIL1[PASS]}") a=$(get_mail "${MAIL1_USER}" "${MAIL1_PASS}")
b=$(get-mail "${MAIL2[USER]}" "${MAIL2[PASS]}") b=$(get_mail "${MAIL2_USER}" "${MAIL2_PASS}")
c=$(get-mail "${MAIL3[USER]}" "${MAIL3[PASS]}") c=$(get_mail "${MAIL3_USER}" "${MAIL3_PASS}")
num=$(( $a + $b + $c )) num=$(( $a + $b + $c ))
icon="${ICON_MAIL}" icon="${ICON_MAIL}"
color=${COLOR_FG} color="${COLOR_FG}"
case "$num" in case $num in
[1-9]*) [1-9]*)
icon="$icon$num" icon="$icon$num"
;; ;;
@ -32,6 +38,8 @@ case "$num" in
;; ;;
esac esac
[ -n "$ERROR" ] && color=${COLOR_1} [[ $ERROR ]] && color=${COLOR_1}
echo "M%{F$color}$icon%{F-}" echo "M%{F$color}$icon%{F-}"
# vim:set ft=sh:

View file

@ -2,10 +2,6 @@
. $(dirname $0)/../panel-config . $(dirname $0)/../panel-config
ICON_PLAY=""
ICON_PAUSE=""
# ICON_STOP=""
progress_bar() { progress_bar() {
BAR_SIZE=${2:-26} BAR_SIZE=${2:-26}
C1="%{F${COLOR_6}}-%{F-}" C1="%{F${COLOR_6}}-%{F-}"
@ -15,11 +11,9 @@ progress_bar() {
echo "$1" | SIZE=$BAR_SIZE CHAR1="$C1" CHAR2="$C2" SEP='' START="$DELIM" END="$DELIM" mkb echo "$1" | SIZE=$BAR_SIZE CHAR1="$C1" CHAR2="$C2" SEP='' START="$DELIM" END="$DELIM" mkb
} }
while : while :; do
do
output=$(mpc --format ";%title%;%artist%;%album%") output=$(mpc --format ";%title%;%artist%;%album%")
if echo $output | grep "^;" 2>&1 >/dev/null if echo $output | grep "^;" 2>&1 >/dev/null; then
then
# title=$(echo "$output" | head -1 | cut -d';' -f2) # title=$(echo "$output" | head -1 | cut -d';' -f2)
# artist=$(echo "$output" | head -1 | cut -d';' -f3) # artist=$(echo "$output" | head -1 | cut -d';' -f3)
# album=$(echo "$output" | head -1 | cut -d';' -f4) # album=$(echo "$output" | head -1 | cut -d';' -f4)
@ -44,3 +38,5 @@ do
fi fi
sleep 1 sleep 1
done done
# vim:set ft=sh:

View file

@ -1,21 +1,16 @@
#!/usr/bin/env dash #!/usr/bin/env dash
# wireless icons . $(dirname $0)/../panel-config
ICON_WIFI0=""
ICON_WIFI1=""
ICON_WIFI2=""
ICON_WIFI3=""
# No wifi interface? Abort! # No wifi interface? Abort!
ints=$(find /sys/class/net/*/wireless -type d) ints=$(find /sys/class/net/*/wireless -type d)
[ -z "$ints" ] && echo "I${ICON_WIFI0}" && exit [ -z "$ints" ] && echo "I${ICON_WIFI0}" && exit
# Start watching # Start watching
while : while :; do
do
# SSID=$(iwgetid --raw) # SSID=$(iwgetid --raw)
signal=$(awk 'NR==3 {print $3}' /proc/net/wireless) signal=$(awk 'NR==3 {print $3}' /proc/net/wireless)
case "${signal%?}" in case ${signal%?} in
100|[6-9][0-9]) icon="${ICON_WIFI3}" ;; 100|[6-9][0-9]) icon="${ICON_WIFI3}" ;;
[2-5][0-9]) icon="${ICON_WIFI2}" ;; [2-5][0-9]) icon="${ICON_WIFI2}" ;;
*) icon="${ICON_WIFI1}" ;; *) icon="${ICON_WIFI1}" ;;
@ -23,3 +18,5 @@ do
echo "I$icon" echo "I$icon"
sleep 10 sleep 10
done done
# vim:set ft=sh:

View file

@ -2,12 +2,12 @@
. $(dirname $0)/../panel-config . $(dirname $0)/../panel-config
ICON_UPD="" num=$({ checkupdates; cower -u; } | wc -l)
if [ "$num" -gt 0 ]
pkgs="$(checkupdates | wc -l)"
if [ "$pkgs" -gt 0 ]
then then
echo "U%{F${COLOR_2}}$ICON_UPD$pkgs%{F-}" echo "U%{F${COLOR_2}}$ICON_UPD$num%{F-}"
else else
echo "U%{F${COLOR_DIM}}$ICON_UPD%{F-}" echo "U%{F${COLOR_DIM}}$ICON_UPD%{F-}"
fi fi
# vim:set ft=sh:

View file

@ -6,14 +6,11 @@
. $(dirname $0)/../panel-config . $(dirname $0)/../panel-config
# media player icons data=$(amixer get Master)
ICON_MUTED="" vol=0
ICON_SPEAKER="" if echo "$data" | grep '\[on\]' >/dev/null; then
if echo "$data" | grep '\[on\]' >/dev/null
then
vol=$(echo "$data" | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq) vol=$(echo "$data" | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
case "$vol" in case $vol in
0) echo "V${ICON_MUTED}" 0) echo "V${ICON_MUTED}"
;; ;;
*) echo "V${ICON_SPEAKER}" *) echo "V${ICON_SPEAKER}"
@ -22,3 +19,5 @@ then
else else
echo "V%{F${COLOR_DIM}}${ICON_MUTED}%{F-}" echo "V%{F${COLOR_DIM}}${ICON_MUTED}%{F-}"
fi fi
# vim:set ft=sh:

View file

@ -51,7 +51,40 @@ ICON_FILE=""
ICON_MUSIC="" ICON_MUSIC=""
ICON_MEDIA="" ICON_MEDIA=""
ICON_GAMES="" # ghost ICON_GAMES="" # ghost
ICON_MISC=""
# clock icons # clock icons
ICON_DATE="" ICON_DATE=""
ICON_TIME="" ICON_TIME=""
# battery icons
ICON_BAT0=""
ICON_BAT1=""
ICON_BAT2=""
ICON_BAT3=""
ICON_BAT4=""
ICON_BAT5=""
ICON_BAT6=""
ICON_BAT7=""
ICON_BAT8=""
ICON_BAT9=""
ICON_BATAC=""
ICON_SYNC=""
# media icons
ICON_PLAY=""
ICON_PAUSE=""
# ICON_STOP=""
ICON_MUTED=""
ICON_SPEAKER=""
# wireless icons
ICON_WIFI0=""
ICON_WIFI1=""
ICON_WIFI2=""
ICON_WIFI3=""
# updates
ICON_UPD=""