os/arch panel: move icons to panel-config; refactor lemons
This commit is contained in:
parent
15a659a961
commit
7e3d550994
|
@ -3,35 +3,20 @@
|
|||
. $(dirname $0)/../panel-config
|
||||
|
||||
# No guarantee that it will be called BAT0, but it suits my purposes.
|
||||
if ! command -v acpi >/dev/null
|
||||
then
|
||||
if ! command -v acpi >/dev/null; then
|
||||
>&2 echo "acpi is not installed, battery segment disabled"
|
||||
exit
|
||||
fi
|
||||
if [ ! -d "/sys/class/power_supply/BAT0" ]
|
||||
then
|
||||
if [ ! -d /sys/class/power_supply/BAT0 ]; then
|
||||
>&2 echo "No battery! This must be a PC"
|
||||
exit
|
||||
fi
|
||||
|
||||
ICON_BAT0=""
|
||||
ICON_BAT1=""
|
||||
ICON_BAT2=""
|
||||
ICON_BAT3=""
|
||||
ICON_BAT4=""
|
||||
ICON_BAT5=""
|
||||
ICON_BAT6=""
|
||||
ICON_BAT7=""
|
||||
ICON_BAT8=""
|
||||
ICON_BAT9=""
|
||||
ICON_BATAC=""
|
||||
while :; do
|
||||
data=$(acpi --battery)
|
||||
perc=${${${data#*,}%,*}:1:-1}
|
||||
|
||||
while :
|
||||
do
|
||||
BAT=$(acpi --battery)
|
||||
PERC=$(echo $BAT | cut -d, -f2)
|
||||
|
||||
case "${PERC#??}" in
|
||||
case $perc in
|
||||
100|9[0-9]) icon="${ICON_BAT9}" ;;
|
||||
8[0-9]) icon="${ICON_BAT8}" ;;
|
||||
7[0-9]) icon="${ICON_BAT7}" ;;
|
||||
|
@ -43,12 +28,10 @@ do
|
|||
1[0-9]) icon="%{F$COLOR_1}${ICON_BAT1}%{F-}" ;;
|
||||
*) icon="%{F$COLOR_1}${ICON_BAT0}%{F-}" ;;
|
||||
esac
|
||||
if echo "$BAT" | grep charging >/dev/null
|
||||
then
|
||||
echo "${icon}${ICON_BATAC}"
|
||||
else
|
||||
echo "${icon} "
|
||||
fi
|
||||
echo -n "${icon}"
|
||||
[ "${data/ charging/}" == "$data" ] && echo "${ICON_BATAC}"
|
||||
|
||||
sleep 15
|
||||
done
|
||||
|
||||
# vim:set ft=sh:
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
[ -f ~/.secrets/accounts.sh ] && . ~/.secrets/accounts.sh || exit
|
||||
. $(dirname $0)/../panel-config
|
||||
set -e
|
||||
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=""
|
||||
|
||||
get-mail() {
|
||||
get_mail() {
|
||||
local feed=$(curl -u "$1:$2" --silent https://mail.google.com/mail/feed/atom)
|
||||
if [ "$(echo $feed | grep -c "<fullcount>")" -eq 1 ]
|
||||
then
|
||||
echo $feed | grep -o "<entry>" | wc -l
|
||||
if [[ "${feed//\<fullcount\>/}" != "$feed" ]]; then
|
||||
echo "$feed" | grep -o "<entry>" | wc -l
|
||||
else
|
||||
>&2 echo "mail.sh: error with $1"
|
||||
ERROR=!
|
||||
|
@ -17,14 +23,14 @@ get-mail() {
|
|||
fi
|
||||
}
|
||||
|
||||
a=$(get-mail "${MAIL1[USER]}" "${MAIL1[PASS]}")
|
||||
b=$(get-mail "${MAIL2[USER]}" "${MAIL2[PASS]}")
|
||||
c=$(get-mail "${MAIL3[USER]}" "${MAIL3[PASS]}")
|
||||
a=$(get_mail "${MAIL1_USER}" "${MAIL1_PASS}")
|
||||
b=$(get_mail "${MAIL2_USER}" "${MAIL2_PASS}")
|
||||
c=$(get_mail "${MAIL3_USER}" "${MAIL3_PASS}")
|
||||
|
||||
num=$(( $a + $b + $c ))
|
||||
icon="${ICON_MAIL}"
|
||||
color=${COLOR_FG}
|
||||
case "$num" in
|
||||
color="${COLOR_FG}"
|
||||
case $num in
|
||||
[1-9]*)
|
||||
icon="$icon$num"
|
||||
;;
|
||||
|
@ -32,6 +38,8 @@ case "$num" in
|
|||
;;
|
||||
esac
|
||||
|
||||
[ -n "$ERROR" ] && color=${COLOR_1}
|
||||
[[ $ERROR ]] && color=${COLOR_1}
|
||||
|
||||
echo "M%{F$color}$icon%{F-}"
|
||||
|
||||
# vim:set ft=sh:
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
. $(dirname $0)/../panel-config
|
||||
|
||||
ICON_PLAY=""
|
||||
ICON_PAUSE=""
|
||||
# ICON_STOP=""
|
||||
|
||||
progress_bar() {
|
||||
BAR_SIZE=${2:-26}
|
||||
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
|
||||
}
|
||||
|
||||
while :
|
||||
do
|
||||
while :; do
|
||||
output=$(mpc --format ";%title%;%artist%;%album%")
|
||||
if echo $output | grep "^;" 2>&1 >/dev/null
|
||||
then
|
||||
if echo $output | grep "^;" 2>&1 >/dev/null; then
|
||||
# title=$(echo "$output" | head -1 | cut -d';' -f2)
|
||||
# artist=$(echo "$output" | head -1 | cut -d';' -f3)
|
||||
# album=$(echo "$output" | head -1 | cut -d';' -f4)
|
||||
|
@ -44,3 +38,5 @@ do
|
|||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# vim:set ft=sh:
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
#!/usr/bin/env dash
|
||||
|
||||
# wireless icons
|
||||
ICON_WIFI0=""
|
||||
ICON_WIFI1=""
|
||||
ICON_WIFI2=""
|
||||
ICON_WIFI3=""
|
||||
. $(dirname $0)/../panel-config
|
||||
|
||||
# No wifi interface? Abort!
|
||||
ints=$(find /sys/class/net/*/wireless -type d)
|
||||
[ -z "$ints" ] && echo "I${ICON_WIFI0}" && exit
|
||||
|
||||
# Start watching
|
||||
while :
|
||||
do
|
||||
while :; do
|
||||
# SSID=$(iwgetid --raw)
|
||||
signal=$(awk 'NR==3 {print $3}' /proc/net/wireless)
|
||||
case "${signal%?}" in
|
||||
case ${signal%?} in
|
||||
100|[6-9][0-9]) icon="${ICON_WIFI3}" ;;
|
||||
[2-5][0-9]) icon="${ICON_WIFI2}" ;;
|
||||
*) icon="${ICON_WIFI1}" ;;
|
||||
|
@ -23,3 +18,5 @@ do
|
|||
echo "I$icon"
|
||||
sleep 10
|
||||
done
|
||||
|
||||
# vim:set ft=sh:
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
. $(dirname $0)/../panel-config
|
||||
|
||||
ICON_UPD=""
|
||||
|
||||
pkgs="$(checkupdates | wc -l)"
|
||||
if [ "$pkgs" -gt 0 ]
|
||||
num=$({ checkupdates; cower -u; } | wc -l)
|
||||
if [ "$num" -gt 0 ]
|
||||
then
|
||||
echo "U%{F${COLOR_2}}$ICON_UPD$pkgs%{F-}"
|
||||
echo "U%{F${COLOR_2}}$ICON_UPD$num%{F-}"
|
||||
else
|
||||
echo "U%{F${COLOR_DIM}}$ICON_UPD%{F-}"
|
||||
fi
|
||||
|
||||
# vim:set ft=sh:
|
||||
|
|
|
@ -6,14 +6,11 @@
|
|||
|
||||
. $(dirname $0)/../panel-config
|
||||
|
||||
# media player icons
|
||||
ICON_MUTED=""
|
||||
ICON_SPEAKER=""
|
||||
|
||||
if echo "$data" | grep '\[on\]' >/dev/null
|
||||
then
|
||||
data=$(amixer get Master)
|
||||
vol=0
|
||||
if echo "$data" | grep '\[on\]' >/dev/null; then
|
||||
vol=$(echo "$data" | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
|
||||
case "$vol" in
|
||||
case $vol in
|
||||
0) echo "V${ICON_MUTED}"
|
||||
;;
|
||||
*) echo "V${ICON_SPEAKER}"
|
||||
|
@ -22,3 +19,5 @@ then
|
|||
else
|
||||
echo "V%{F${COLOR_DIM}}${ICON_MUTED}%{F-}"
|
||||
fi
|
||||
|
||||
# vim:set ft=sh:
|
||||
|
|
|
@ -51,7 +51,40 @@ ICON_FILE=""
|
|||
ICON_MUSIC=""
|
||||
ICON_MEDIA=""
|
||||
ICON_GAMES="" # ghost
|
||||
ICON_MISC=""
|
||||
|
||||
# clock icons
|
||||
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=""
|
||||
|
||||
|
|
Loading…
Reference in a new issue