aboutsummaryrefslogtreecommitdiff
path: root/herbstluftwm/bar/functions
diff options
context:
space:
mode:
Diffstat (limited to 'herbstluftwm/bar/functions')
-rwxr-xr-xherbstluftwm/bar/functions/sysinfo48
-rwxr-xr-xherbstluftwm/bar/functions/volume_info3
-rwxr-xr-xherbstluftwm/bar/functions/weather21
3 files changed, 72 insertions, 0 deletions
diff --git a/herbstluftwm/bar/functions/sysinfo b/herbstluftwm/bar/functions/sysinfo
new file mode 100755
index 00000000..a377c600
--- /dev/null
+++ b/herbstluftwm/bar/functions/sysinfo
@@ -0,0 +1,48 @@
+#!/bin/zsh
+
+date_time() {
+ datetime=$(date +"%d %b(%A) %H:%M")
+ echo $datetime
+}
+
+cpu_load() {
+ read cpu a b c previdle rest < /proc/stat
+ prevtotal=$((a+b+c+previdle))
+ sleep 0.5
+ read cpu a b c idle rest < /proc/stat
+ total=$((a+b+c+idle))
+ cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
+ echo -e "CPU: $cpu%"
+}
+
+cpu_temp() {
+ CEL=$'\xc2\xb0C'
+ temp=$( cat /sys/devices/virtual/thermal/thermal_zone0/temp )
+ temp=`expr $temp / 1000`
+ echo "TEMP: " $temp$CEL
+}
+
+root_usage() {
+ root=$(df -h / | awk 'NR==2 {print $4 "/" $2}')
+ echo "ROOT: "$root
+}
+
+home_usage() {
+ home=$(df -h /home | awk 'NR==2 {print $4 "/" $2}')
+ echo "HOME: "$home
+}
+
+mem_usage() {
+ mem=$(free -m | grep Mem: | awk '{print$3 / $2 * 100}')
+ printf "MEM: %.0f %%" $mem
+}
+
+while :; do
+ echo $(date_time) > /home/zt/.cache/lemon/clock
+ echo $(cpu_load) > /home/zt/.cache/lemon/cpu_load
+ echo $(cpu_temp) > /home/zt/.cache/lemon/cpu_temp
+ echo $(root_usage) > /home/zt/.cache/lemon/disk_root
+ echo $(home_usage) > /home/zt/.cache/lemon/disk_home
+ echo $(mem_usage) > /home/zt/.cache/lemon/mem
+ sleep 3
+done
diff --git a/herbstluftwm/bar/functions/volume_info b/herbstluftwm/bar/functions/volume_info
new file mode 100755
index 00000000..e5d06f8d
--- /dev/null
+++ b/herbstluftwm/bar/functions/volume_info
@@ -0,0 +1,3 @@
+#!/bin/zsh
+
+echo $(pamixer --get-volume-human) > /home/zt/.cache/lemon/volume
diff --git a/herbstluftwm/bar/functions/weather b/herbstluftwm/bar/functions/weather
new file mode 100755
index 00000000..df6cf24b
--- /dev/null
+++ b/herbstluftwm/bar/functions/weather
@@ -0,0 +1,21 @@
+#!/bin/zsh
+
+get_current_temp() {
+ if [ $stat = "Smoke" ] || [ $stat = "Sunny" ]; then
+ temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $4 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g")
+ else
+ temp=$(curl wttr.in | grep °C | awk 'NR==1 {print $9 "°C"}' | sed -r "s/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g")
+ fi
+
+ echo $temp
+}
+
+get_current_weather() {
+ stat=$(curl wttr.in | awk 'NR==3 {print $1}')
+ echo $(get_current_temp)"("$stat")"
+}
+
+while :; do
+ echo $(get_current_weather) > /home/zt/.cache/lemon/weather
+ sleep 3600
+done