47 lines
1.2 KiB
Bash
Executable file
47 lines
1.2 KiB
Bash
Executable file
#! /usr/bin/sh
|
|
|
|
today=$(date +'%Y-%m-%d')
|
|
now=$(date +'%H:%M:%S')
|
|
|
|
audio_state=$(amixer get Master | tail -n 1)
|
|
audio_volume=$(echo "$audio_state" | grep -o '[0-9]*%' | tr -d %)
|
|
audio_mute=$(echo "$audio_state" | grep -o '\[o.*\]' | tr -d \[\])
|
|
audio_symbol="❔"
|
|
if [ "${audio_mute}" = "off" ]; then
|
|
audio_symbol="🔇"
|
|
elif [ "${audio_mute}" = "on" ]; then
|
|
if [ "${audio_volume}" = "0" ]; then
|
|
audio_symbol="🔈"
|
|
elif [ "${audio_volume}" -lt 50 ]; then
|
|
audio_symbol="🔉"
|
|
else
|
|
audio_symbol="🔊"
|
|
fi
|
|
fi
|
|
|
|
battery=$(cat /sys/class/power_supply/BAT0/capacity)
|
|
battery_state=$(cat /sys/class/power_supply/BAT0/status)
|
|
case "${battery_state}" in
|
|
"Charging"|"Full"|"Not charging")
|
|
battery_symbol="🔌"
|
|
;;
|
|
"Discharging")
|
|
if [ "${battery}" -lt 20 ]; then
|
|
battery_symbol="🪫"
|
|
else
|
|
battery_symbol="🔋"
|
|
fi
|
|
;;
|
|
*)
|
|
battery_symbol="❔"
|
|
;;
|
|
esac
|
|
|
|
weather_file="/tmp/weather-report.txt"
|
|
if [ -f ${weather_file} ]; then
|
|
weather=$(cat ${weather_file})
|
|
else
|
|
weather=""
|
|
fi
|
|
|
|
echo ${weather} 📆${today} ⏲${now} ${audio_symbol}${audio_volume}% ${battery_symbol}${battery}%
|