Scripts: Fix cpuusage, currency, cxev

master
Pierre Neidhardt 2015-10-07 16:33:45 +02:00
parent ec18117b17
commit 9706c8c819
4 changed files with 28 additions and 18 deletions

View File

@ -35,22 +35,22 @@ fi
##
## Only the first 4 values are interesting here.
cpuarray="$(grep 'cpu ' /proc/stat)"
f1=$(echo $cpuarray | cut -f3 -d' ')
f2=$(echo $cpuarray | cut -f4 -d' ')
f3=$(echo $cpuarray | cut -f5 -d' ')
f4=$(echo $cpuarray | cut -f6 -d' ')
cpuarray="$(grep '^cpu ' /proc/stat)"
## We start at field #3 since there are 2 spaces after 'cpu'.
f1=$(echo "$cpuarray" | cut -f3 -d' ')
f2=$(echo "$cpuarray" | cut -f4 -d' ')
f3=$(echo "$cpuarray" | cut -f5 -d' ')
f4=$(echo "$cpuarray" | cut -f6 -d' ')
totalA=$(($f1+$f2+$f3+$f4))
idleA=$f4
sleep 1
cpuarray="$(grep 'cpu ' /proc/stat)"
f1=$(echo $cpuarray | cut -f3 -d' ')
f2=$(echo $cpuarray | cut -f4 -d' ')
f3=$(echo $cpuarray | cut -f5 -d' ')
f4=$(echo $cpuarray | cut -f6 -d' ')
cpuarray="$(grep '^cpu ' /proc/stat)"
f1=$(echo "$cpuarray" | cut -f3 -d' ')
f2=$(echo "$cpuarray" | cut -f4 -d' ')
f3=$(echo "$cpuarray" | cut -f5 -d' ')
f4=$(echo "$cpuarray" | cut -f6 -d' ')
totalB=$(($f1+$f2+$f3+$f4))
idleB=$f4

View File

@ -12,4 +12,4 @@ EOF
fi
curl -sA "Mozilla/5.0" "http://www.google.com/finance?q=$2$3" | \
awk -v value=$1 -F '<|>' '/^1 / {print value * substr($3, 1, index($3," "))}'
awk -v value="$1" -F '<|>' '/^1 / {print value * substr($3, 1, index($3," "))}'

View File

@ -1,6 +1,11 @@
#!/bin/sh
xev | awk '/KeyPress|KeyRelease/ {
compat=""
if [ $(awk --version | grep -c GNU) -gt 0 ]; then
# This is for hex-to-decimal conversion.
compat="--non-decimal"
fi
xev "$@" | awk $compat '/KeyPress|KeyRelease/ {
if ($1 == "KeyPress")
event="pressed";
else
@ -11,8 +16,15 @@ xev | awk '/KeyPress|KeyRelease/ {
keycode = $4;
keysym = substr($7, 1, length($7)-2);
getline;
string=$6;
printf "%-16s code=%-3s state=%s event=%-8s", keysym, keycode, state, event
printf "%-10s: code=%-3s state=%s event=%-8s string=%s\n", keysym, keycode, state, event, string
getline;
gsub(/\(|\)/, "", $5)
code=int(sprintf("%d", "0x" $5))
if (code > 32 && code != 127) {
/* Ignore non-printable characters" */
gsub(/"/, "", $NF)
printf " string=%s", $NF
}
print ""
}'

View File

@ -1,2 +0,0 @@
#!/bin/sh
zenity --info --text "IP: $(curl -s 192.168.1.1 | awk -F'>: |<' '/Adresse IP/{getline;print $3;exit}')"