weather module added in slstatus
This commit is contained in:
1 parent
7addaf17b8
commit
68997bd9d0
36 files changed
+66
-4
No files matched your search
Executable
+6
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
~/dotfiles/dwm/slstatus/components/wttr.sh
|
||||||
|
sleep 1800
|
||||||
|
done
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# What modules, in what order
|
# What modules, in what order
|
||||||
MODULES="weather battery volume disksize wifi internet cpuload ram cputemp date time"
|
MODULES="weather volume disksize wifi internet cpuload ram cputemp date time"
|
||||||
|
|
||||||
# Modules that require an active internet connection
|
# Modules that require an active internet connection
|
||||||
ONLINE_MODULES="weather internet"
|
ONLINE_MODULES="weather internet"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
get_weather()
|
get_weather()
|
||||||
{
|
{
|
||||||
curl -s v2.wttr.in | grep -e "Weather" | sed -n 2p | sed s/Weather://g | sed 's/,//g' | sed 's/+//g' | sed 's/°C.*/°C/' | sed 's/.*m//'
|
curl -s v2.wttr.in/tomsk | grep -e "Weather" | sed -n 2p | sed s/Weather://g | sed 's/,//g' | sed 's/+//g' | sed 's/°C.*/°C/' | sed 's/.*m//'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ COM =\
|
|||||||
components/uptime\
|
components/uptime\
|
||||||
components/user\
|
components/user\
|
||||||
components/volume\
|
components/volume\
|
||||||
components/wifi
|
components/wifi\
|
||||||
|
components/weather
|
||||||
|
|
||||||
all: slstatus
|
all: slstatus
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,21 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../slstatus.h"
|
||||||
|
#include "../util.h"
|
||||||
|
|
||||||
|
#define WTTR_TEMP "/tmp/wttr"
|
||||||
|
|
||||||
|
const char *weather()
|
||||||
|
{
|
||||||
|
FILE *wttr = fopen(WTTR_TEMP, "r");
|
||||||
|
char temp[10];
|
||||||
|
memset(&temp, '\0', 10);
|
||||||
|
|
||||||
|
fgets(temp, 10, wttr);
|
||||||
|
fclose(wttr);
|
||||||
|
|
||||||
|
temp[strlen(temp)-1] = '\0';
|
||||||
|
|
||||||
|
return bprintf("%s", temp);
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Executable
+28
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This function checks if wttr.in is available before the weather info is fetched
|
||||||
|
ck_curl() {
|
||||||
|
curl -sf ru.wttr.in > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
ck_curl
|
||||||
|
if [ $? -eq 0 ] # $? means "output of the last command"
|
||||||
|
then
|
||||||
|
curl -s v2.wttr.in/tomsk?format="%t\n" > /tmp/wttr
|
||||||
|
wttr_net=1
|
||||||
|
else # Non-zero output would appear both when the site \
|
||||||
|
for (( cntr = 0; cntr < 3; cntr++ )) # is down and when you're physically offline
|
||||||
|
do
|
||||||
|
echo "Probing. " > /tmp/wttr
|
||||||
|
sleep 0.5
|
||||||
|
echo "Probing.. " > /tmp/wttr
|
||||||
|
sleep 0.5
|
||||||
|
echo "Probing..." > /tmp/wttr
|
||||||
|
sleep 0.5 # A wee bit of animation
|
||||||
|
done
|
||||||
|
ck_curl # Online check is rerun only once, if the first check fails.
|
||||||
|
fi # In case you're using wifi, and the cron job runs before \
|
||||||
|
# it authenticates
|
||||||
|
if ! [ $wttr_net ]
|
||||||
|
then echo "Offline fr :'( " > /tmp/wttr
|
||||||
|
fi
|
||||||
@@ -65,7 +65,8 @@ static const char unknown_str[] = "n/a";
|
|||||||
*/
|
*/
|
||||||
static const struct arg args[] = {
|
static const struct arg args[] = {
|
||||||
/* function format argument */
|
/* function format argument */
|
||||||
{ datetime, "| %s | ", "%F %T" },
|
{ weather, "| %s | ", NULL },
|
||||||
|
{ datetime, "%s | ", "%F %T" },
|
||||||
{ cpu_perc, " %s% | ", NULL },
|
{ cpu_perc, " %s% | ", NULL },
|
||||||
{ ram_used, " %s/", NULL },
|
{ ram_used, " %s/", NULL },
|
||||||
{ ram_total, "%s | ", NULL },
|
{ ram_total, "%s | ", NULL },
|
||||||
|
|||||||
Binary file not shown.
@@ -82,3 +82,5 @@ const char *vol_perc(const char *card);
|
|||||||
/* wifi */
|
/* wifi */
|
||||||
const char *wifi_essid(const char *interface);
|
const char *wifi_essid(const char *interface);
|
||||||
const char *wifi_perc(const char *interface);
|
const char *wifi_perc(const char *interface);
|
||||||
|
|
||||||
|
const char *weather();
|
||||||
Binary file not shown.
Binary file not shown.
@@ -7,6 +7,7 @@ setxkbmap "us,ru" -option 'grp:win_space_toggle'
|
|||||||
slstatus &
|
slstatus &
|
||||||
dunst &
|
dunst &
|
||||||
~/dotfiles/bin/dpmsdisablexorg
|
~/dotfiles/bin/dpmsdisablexorg
|
||||||
|
~/dotfiles/dwm/slstatus/components/wttr.sh
|
||||||
|
|
||||||
xrdb -merge ~/dotfiles/dwm/Xresources
|
xrdb -merge ~/dotfiles/dwm/Xresources
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ exec-once = waybar
|
|||||||
#exec-once = ~/dotfiles/background-swww.sh
|
#exec-once = ~/dotfiles/background-swww.sh
|
||||||
#---------------------------------------
|
#---------------------------------------
|
||||||
|
|
||||||
|
#-------- polkit ------
|
||||||
exec-once = lxpolkit
|
exec-once = lxpolkit
|
||||||
|
#----------------------
|
||||||
|
|
||||||
#------------------------------ GTK settings ------------------------------------
|
#------------------------------ GTK settings ------------------------------------
|
||||||
exec-once = gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
|
exec-once = gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
|
||||||
|
|||||||
Reference in new issue
Block a user