Signed-off-by: Marcin Wozniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-05-18 17:04:01 +02:00 committed by Marcin Wozniak
parent 6f58c0bf5c
commit 4b9322bacd
2 changed files with 25 additions and 29 deletions

View File

@ -2,35 +2,34 @@
print_weather() { print_weather() {
[ "$(stat -c %y "/home/yorune/.config/weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && curl -s "wttr.in/$location" > "/home/yorune/.config/weatherreport" [ "$(stat -c %y "/home/yorune/.config/weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && curl -s "wttr.in/$location" > "/home/yorune/.config/weatherreport"
printf "%s " "$(sed '16q;d' "/home/yorune/.config/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/ /g" | tr -d '\n')" && sed '13q;d' "/home/yorune/.config/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ",$1 "°","",$2 "°"}' printf "%s " "$(sed '16q;d' "/home/yorune/.config/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/ /g" | tr -d '\n')" && sed '13q;d' "/home/yorune/.config/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄",$1 "°","☀",$2 "°"}'
} }
print_volume() { print_volume() {
[ "$(pulsemixer --get-mute)" = "1" ] && printf "" && exit [ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇" && exit
vol=$(pulsemixer --get-volume | awk '{print $1}') vol=$(pulsemixer --get-volume | awk '{print $1}')
printf "%s%%\\n" " $vol" printf "%s%%\\n" "🔊 $vol"
} }
print_wifi(){ print_wifi(){
[ "$(stat -c %y "/home/yorune/.config/vpn" 3>/dev/null | egrep -o '[0-9]+\-[0-9]+\-[0-9]+ [0-9]+')" != "$(date '+%Y-%m-%d %H')" ] && sudo /root/.local/bin/protonvpn status | grep -i Status | awk {'print $2'} > "/home/yorune/.config/vpn" [ "$(stat -c %y "/home/yorune/.config/vpn" 3>/dev/null | egrep -o '[0-9]+\-[0-9]+\-[0-9]+ [0-9]+')" != "$(date '+%Y-%m-%d %H')" ] && sudo /root/.local/bin/protonvpn status | grep -i Status | awk {'print $2'} > "/home/yorune/.config/vpn"
echo -e "$(cat /sys/class/net/w*/operstate | sed "s/down//;s/up//") $(cat /sys/class/net/e*/operstate | sed "s/down//;s/up//") $(cat /home/yorune/.config/vpn | sed 's/Connected//g;s/Disconnected//g')" echo -e "$(cat /sys/class/net/w*/operstate | sed "s/down/❌/;s/up/📶/") $(cat /sys/class/net/e*/operstate | sed "s/down/❌/;s/up/🌐/") $(cat /home/yorune/.config/vpn | sed 's/Connected/🌐/g;s/Disconnected/❌/g')"
} }
print_temp(){ print_temp(){
echo -e " $(sensors | awk '/Core 0/ {print $3}') +$(sudo nvidia-smi -q -d temperature | grep --color=no -i "GPU Current" |egrep --color=no -o '[0-9]*').0°C" echo -e "🔥 $(sensors | awk '/Core 0/ {print $3}') +$(sudo nvidia-smi -q -d temperature | grep --color=no -i "GPU Current" |egrep --color=no -o '[0-9]*').0°C"
} }
print_date(){ print_date(){
echo -e " $(date +"%d/%m %H:%M:%S")" echo -e "🕛 $(date +"%d/%m %H:%M")"
} }
print_mem(){ print_mem(){
memfree=$(($(grep -m1 'MemAvailable:' /proc/meminfo | awk '{print $2}') / 1024)) free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠 %2.2fGiB/%2.2fGiB", ( $3 / 1024), ($2 / 1024))}'
echo -e " $memfree"
} }
batLevel() { batLevel() {
@ -42,37 +41,34 @@ batLevel() {
# Determine battery glyph by percentage range # Determine battery glyph by percentage range
if [[ -z $onl && ${charge} -gt 80 ]]; then if [[ -z $onl && ${charge} -gt 80 ]]; then
echo -e " ${charge}% ${time}" echo -e "🔋 ${charge}% ${time}"
elif [[ -z $onl && ${charge} -le 80 && ${charge} -gt 60 ]]; then elif [[ -z $onl && ${charge} -le 80 && ${charge} -gt 60 ]]; then
echo -e " ${charge}% ${time}" echo -e "🔋 ${charge}% ${time}"
elif [[ -z $onl && ${charge} -le 60 && ${charge} -gt 40 ]]; then elif [[ -z $onl && ${charge} -le 60 && ${charge} -gt 40 ]]; then
echo -e " ${charge}% ${time}" echo -e "🔋 ${charge}% ${time}"
elif [[ -z $onl && ${charge} -le 40 && ${charge} -gt 20 ]]; then elif [[ -z $onl && ${charge} -le 40 && ${charge} -gt 20 ]]; then
echo -e " ${charge}% ${time}" echo -e "🔋 ${charge}% ${time}"
elif [[ -z $onl && ${charge} -le 20 ]]; then elif [[ -z $onl && ${charge} -le 20 ]]; then
echo -e " ${charge}% ${time}" echo -e "❗🔋 ${charge}% ${time}"
# If charging, use animated glyph # If charging, use animated glyph
else else
echo -e "" echo -e "🔌"
fi fi
} }
usageData() { print_mail(){
read cpu a b c pi rest < /proc/stat unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)"
pt=$((a+b+c+pi)) icon="$(cat "/tmp/imapsyncicon_$USER" 2>/dev/null)"
sleep 0.1 [ "$unread" = "0" ] && [ "$icon" = "" ] || echo "📬 $unread$icon"
read cpu a b c i rest < /proc/stat }
t=$((a+b+c+i))
cpuUse=$((100*( (t-pt) - (i-pi) ) / (t-pt) ))
ramUseA=$(free -m -h | grep Mem | awk '{print $3"/"$2}') print_cpu() {
ramPer=$(free -m | grep Mem | awk '{print 100*($3/$2)}') cpuUse=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
ramUseB="${ramPer%.*}" echo -e "💻 $cpuUse"
echo -e " $cpuUse%  $ramUseB%"
} }
while true while true
do do
xsetroot -name "$(print_temp) | $(print_weather) | $(print_wifi) | $(batLevel) | $(print_volume) | $(print_date)" xsetroot -name "$(print_temp) | $(print_mail) | $(print_cpu) | $(print_mem) | $(print_weather) | $(print_wifi) | $(batLevel) | $(print_volume) | $(print_date)"
sleep 5
done done

View File

@ -9,13 +9,13 @@ compton&
feh --bg-fill $HOME/.wall.jpg & feh --bg-fill $HOME/.wall.jpg &
redshift -l 53.2327:18.3036 -t 6500:3200& redshift -l 53.2327:18.3036 -t 6500:3200&
nm-applet --sm-disable& nm-applet --sm-disable&
/usr/local/bin/st -e /bin/sh -c "tmux new-session -s BASE -n HOME '/bin/zsh'\; split-window 'htop'\; new-window -n MAIL 'neomutt'\; new-window -n DISCORD '/home/yorune/git/cordless/cordless'\; new-window -n IRC 'irssi'\; new-window -n NEWSBOAT 'newsboat'\; new-window -n MUSIC 'cmus'"&
sudo /root/.local/bin/protonvpn c -f& sudo /root/.local/bin/protonvpn c -f&
DISPLAY=:0 gkrellm& DISPLAY=:0 gkrellm&
dunst -config&
browser-x& browser-x&
password-manager& password-manager&
dunst -config&
transmission-daemon& transmission-daemon&
/usr/local/bin/st -e /bin/sh -c "tmux new-session -s BASE -n HOME '/bin/zsh'\; split-window 'htop'\; new-window -n MAIL 'neomutt'\; new-window -n DISCORD '/home/yorune/git/cordless/cordless'\; new-window -n IRC 'irssi'\; new-window -n NEWSBOAT 'newsboat'\; new-window -n MUSIC 'cmus'"&
(sleep 30 && getforecast)& (sleep 30 && getforecast)&
sudo /usr/bin/rdate -s -l ntp.task.gda.pl && sudo /sbin/hwclock --systohc sudo /usr/bin/rdate -s -l ntp.task.gda.pl && sudo /sbin/hwclock --systohc
/opt/MEGAcmd/mega-cmd-server --debug-full > /var/log/megacmd/megacmd.log& /opt/MEGAcmd/mega-cmd-server --debug-full > /var/log/megacmd/megacmd.log&