From b79166e3c79ddefaed2caab1262fa8b649c91fbf Mon Sep 17 00:00:00 2001 From: gutmet Date: Sun, 14 Mar 2021 15:41:00 +0100 Subject: [PATCH] add shell scripts --- autostart.sh | 21 +++++++++++++++++++++ cleanup_autostart.sh | 5 +++++ dumpweather.sh | 6 ++++++ dwmstatus.sh | 19 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100755 autostart.sh create mode 100755 cleanup_autostart.sh create mode 100755 dumpweather.sh create mode 100755 dwmstatus.sh diff --git a/autostart.sh b/autostart.sh new file mode 100755 index 0000000..448cf2a --- /dev/null +++ b/autostart.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +clearpids() { + echo -n "" > autostart.pids +} + +start() { + eval "$1 &" + pid="$!" + if ps -p "$pid" > /dev/null; then + echo "$pid" >> autostart.pids + fi +} + +clearpids +start "nm-applet" +start "redshift-gtk" +start "./dumpweather.sh" +start "./dwmstatus.sh" + +feh --bg-scale background.jpg diff --git a/cleanup_autostart.sh b/cleanup_autostart.sh new file mode 100755 index 0000000..851b812 --- /dev/null +++ b/cleanup_autostart.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +while read pid; do + kill "$pid" +done weatherdump 2>/dev/null + sleep 600 +done diff --git a/dwmstatus.sh b/dwmstatus.sh new file mode 100755 index 0000000..dcb74ec --- /dev/null +++ b/dwmstatus.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +while true; do + time=`date +"🕑 %d.%m. %H:%M"` + + weatherdata=`cat weatherdump` + current=`echo "$weatherdata" | jq -r '.current_condition | .[0]'` + temp=`echo "$current" | jq -r '.temp_C'` + weatherDesc=`echo "$current" | jq -r '.weatherDesc | .[0].value'` + wind=`echo "$current" | jq -r '.windspeedKmph'` + astronomy=`echo "$weatherdata" | jq -r '.weather | .[0] .astronomy | .[0]'` + moonphase=`echo "$astronomy" | jq -r '.moon_phase'` + sunrise=`echo "$astronomy" | jq -r '.sunrise'` + sunset=`echo "$astronomy" | jq -r '.sunset'` + weather="🌡 $temp°C $weatherDesc $wind""km/h Daylight $sunrise-$sunset, Moon $moonphase" + + xsetroot -name "$weather $time " + sleep 10 +done