Add timer to scripts. Updated dwmbar

This commit is contained in:
Linux User 2022-08-19 10:02:28 +00:00
parent 2547920d81
commit 4d34fcf3af
11 changed files with 45 additions and 27 deletions

View File

@ -3,13 +3,35 @@
DELIM=" "
DELIM_START=0
mkdir -p ~/.local/tmp/
run() {
for FILE in $(ls ~/.local/scripts)
do
touch "$HOME/.local/tmp/.tmp_$(echo $FILE | cut -d'_' -f3)_BIT"
{
while true
do
echo "$(sh ~/.local/scripts/$FILE)" > "$HOME/.local/tmp/.tmp_$(echo $FILE | cut -d'_' -f3)_BIT"
sleep=$(echo $FILE | cut -d'_' -f2)
if [ $sleep -eq 0 ]
then
sleep=0.1
fi
sleep $sleep
done
} &
done
}
status() {
strt=0
[ $DELIM_START -eq 1 ] && strt=1
for FILE in $(ls ~/.local/scripts)
do
res=$(sh ~/.local/scripts/$FILE)
res=$(cat "$HOME/.local/tmp/.tmp_$(echo $FILE | cut -d'_' -f3)_BIT")
if [ $strt -eq 0 ]
then
strt=1
@ -20,14 +42,12 @@ status() {
done
}
time=$(date +"%s")
run
while true
while :
do
if [ $(($time - $(date +"%s"))) -lt 0 ]
then
stat=$(status | tr -d '\n')
xprop -root -set WM_NAME "$stat"
time=$(date +"%s")
fi
sleep 0.1
done

View File

@ -16,22 +16,22 @@ done
if [ $good -eq 0 ]
then
echo "Change DEVICE in ~/.local/scripts/9993_network"
echo "Change DEVICE in ~/.local/scripts/0010_1_network"
grep ":" /proc/net/dev | awk -F: '{print $1}' | sed s@\ @@g
exit 1
fi
if [ ! -f $HOME/.local/.tmp_RXNET_BIT ]
if [ ! -f $HOME/.local/tmp/.tmp_RXNET_BIT ]
then
RXNET_BIT=0
TXNET_BIT=0
echo $RXNET_BIT > $HOME/.local/.tmp_RXNET_BIT
echo $TXNET_BIT > $HOME/.local/.tmp_TXNET_BIT
echo $RXNET_BIT > $HOME/.local/tmp/.tmp_RXNET_BIT
echo $TXNET_BIT > $HOME/.local/tmp/.tmp_TXNET_BIT
fi
RXNET_BIT=$(cat $HOME/.local/.tmp_RXNET_BIT)
TXNET_BIT=$(cat $HOME/.local/.tmp_TXNET_BIT)
RXNET_BIT=$(cat $HOME/.local/tmp/.tmp_RXNET_BIT)
TXNET_BIT=$(cat $HOME/.local/tmp/.tmp_TXNET_BIT)
line=`grep $DEVICE /proc/net/dev | sed s/.*://`
rx=`echo $line | awk '{print $1}'`
@ -40,14 +40,12 @@ tx=`echo $line | awk '{print $9}'`
inbound=$(($rx-$RXNET_BIT))
outbound=$(($tx-$TXNET_BIT))
LASTNETTIME_BIT=$(date +%s)
line=`grep $DEVICE /proc/net/dev | sed s/.*://`
RXNET_BIT=`echo $line | awk '{print $1}'`
TXNET_BIT=`echo $line | awk '{print $9}'`
echo $RXNET_BIT > $HOME/.local/.tmp_RXNET_BIT
echo $TXNET_BIT > $HOME/.local/.tmp_TXNET_BIT
echo $RXNET_BIT > $HOME/.local/tmp/.tmp_RXNET_BIT
echo $TXNET_BIT > $HOME/.local/tmp/.tmp_TXNET_BIT
if [ $inbound -gt $((1024*1024)) ]
then

8
.local/scripts/0030_0_cpu Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
COLOR1="#990057"
COLOR2="#FF00B2"
usage=$(cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}' | cut -d'.' -f1)"%"
echo "^c$COLOR1^^b$COLOR2^  ^b$COLOR1^^c$COLOR2^ $usage ^d^"

View File

@ -1,8 +0,0 @@
#!/bin/bash
COLOR1="#990057"
COLOR2="#FF00B2"
usage=$(cat <(grep 'cpu ' /proc/stat) <(sleep 0.3 && grep 'cpu ' /proc/stat) | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}' | cut -d'.' -f1)"%"
echo "^c$COLOR1^^b$COLOR2^  ^b$COLOR1^^c$COLOR2^ $usage ^d^"