diff --git a/dwm/bin/wttrd b/dwm/bin/wttrd new file mode 100755 index 0000000..388b18e --- /dev/null +++ b/dwm/bin/wttrd @@ -0,0 +1,6 @@ +#!/bin/sh + +while true; do + ~/dotfiles/dwm/slstatus/components/wttr.sh + sleep 1800 +done diff --git a/dwm/dwmbar/config b/dwm/dwmbar/config index 5b3fd4f..b89c22e 100644 --- a/dwm/dwmbar/config +++ b/dwm/dwmbar/config @@ -1,7 +1,7 @@ #!/bin/bash # 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 ONLINE_MODULES="weather internet" diff --git a/dwm/dwmbar/modules/weather b/dwm/dwmbar/modules/weather index 9bd9f52..17d7eec 100755 --- a/dwm/dwmbar/modules/weather +++ b/dwm/dwmbar/modules/weather @@ -6,7 +6,7 @@ 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//' } diff --git a/dwm/slstatus/Makefile b/dwm/slstatus/Makefile index 7a18274..c27f7fb 100644 --- a/dwm/slstatus/Makefile +++ b/dwm/slstatus/Makefile @@ -27,7 +27,8 @@ COM =\ components/uptime\ components/user\ components/volume\ - components/wifi + components/wifi\ + components/weather all: slstatus diff --git a/dwm/slstatus/components/battery.o b/dwm/slstatus/components/battery.o index f98fb2b..a8f0f2a 100644 Binary files a/dwm/slstatus/components/battery.o and b/dwm/slstatus/components/battery.o differ diff --git a/dwm/slstatus/components/cat.o b/dwm/slstatus/components/cat.o index 3ca0447..e2a7b9d 100644 Binary files a/dwm/slstatus/components/cat.o and b/dwm/slstatus/components/cat.o differ diff --git a/dwm/slstatus/components/cpu.o b/dwm/slstatus/components/cpu.o index 626fa68..fc67b42 100644 Binary files a/dwm/slstatus/components/cpu.o and b/dwm/slstatus/components/cpu.o differ diff --git a/dwm/slstatus/components/datetime.o b/dwm/slstatus/components/datetime.o index be8618c..7c947df 100644 Binary files a/dwm/slstatus/components/datetime.o and b/dwm/slstatus/components/datetime.o differ diff --git a/dwm/slstatus/components/disk.o b/dwm/slstatus/components/disk.o index 15a48fd..085a3e1 100644 Binary files a/dwm/slstatus/components/disk.o and b/dwm/slstatus/components/disk.o differ diff --git a/dwm/slstatus/components/entropy.o b/dwm/slstatus/components/entropy.o index fbc73ae..00f93e8 100644 Binary files a/dwm/slstatus/components/entropy.o and b/dwm/slstatus/components/entropy.o differ diff --git a/dwm/slstatus/components/hostname.o b/dwm/slstatus/components/hostname.o index d3f15e7..e9b2f48 100644 Binary files a/dwm/slstatus/components/hostname.o and b/dwm/slstatus/components/hostname.o differ diff --git a/dwm/slstatus/components/ip.o b/dwm/slstatus/components/ip.o index 5b9db67..b1d3a85 100644 Binary files a/dwm/slstatus/components/ip.o and b/dwm/slstatus/components/ip.o differ diff --git a/dwm/slstatus/components/kernel_release.o b/dwm/slstatus/components/kernel_release.o index eef4c7c..25fdc18 100644 Binary files a/dwm/slstatus/components/kernel_release.o and b/dwm/slstatus/components/kernel_release.o differ diff --git a/dwm/slstatus/components/keyboard_indicators.o b/dwm/slstatus/components/keyboard_indicators.o index 88dcdf0..30f568d 100644 Binary files a/dwm/slstatus/components/keyboard_indicators.o and b/dwm/slstatus/components/keyboard_indicators.o differ diff --git a/dwm/slstatus/components/keymap.o b/dwm/slstatus/components/keymap.o index 166aa6c..4b00798 100644 Binary files a/dwm/slstatus/components/keymap.o and b/dwm/slstatus/components/keymap.o differ diff --git a/dwm/slstatus/components/load_avg.o b/dwm/slstatus/components/load_avg.o index 2e5d9a0..1eac4dc 100644 Binary files a/dwm/slstatus/components/load_avg.o and b/dwm/slstatus/components/load_avg.o differ diff --git a/dwm/slstatus/components/netspeeds.o b/dwm/slstatus/components/netspeeds.o index a85a3b6..4805501 100644 Binary files a/dwm/slstatus/components/netspeeds.o and b/dwm/slstatus/components/netspeeds.o differ diff --git a/dwm/slstatus/components/num_files.o b/dwm/slstatus/components/num_files.o index 567431c..a45d794 100644 Binary files a/dwm/slstatus/components/num_files.o and b/dwm/slstatus/components/num_files.o differ diff --git a/dwm/slstatus/components/ram.o b/dwm/slstatus/components/ram.o index 848d15b..53d97de 100644 Binary files a/dwm/slstatus/components/ram.o and b/dwm/slstatus/components/ram.o differ diff --git a/dwm/slstatus/components/run_command.o b/dwm/slstatus/components/run_command.o index dcc1845..51567b5 100644 Binary files a/dwm/slstatus/components/run_command.o and b/dwm/slstatus/components/run_command.o differ diff --git a/dwm/slstatus/components/swap.o b/dwm/slstatus/components/swap.o index d20814e..a97d37d 100644 Binary files a/dwm/slstatus/components/swap.o and b/dwm/slstatus/components/swap.o differ diff --git a/dwm/slstatus/components/temperature.o b/dwm/slstatus/components/temperature.o index 31e02ae..89d7e40 100644 Binary files a/dwm/slstatus/components/temperature.o and b/dwm/slstatus/components/temperature.o differ diff --git a/dwm/slstatus/components/uptime.o b/dwm/slstatus/components/uptime.o index e6394bf..c0b18b9 100644 Binary files a/dwm/slstatus/components/uptime.o and b/dwm/slstatus/components/uptime.o differ diff --git a/dwm/slstatus/components/user.o b/dwm/slstatus/components/user.o index c344433..8c23073 100644 Binary files a/dwm/slstatus/components/user.o and b/dwm/slstatus/components/user.o differ diff --git a/dwm/slstatus/components/volume.o b/dwm/slstatus/components/volume.o index b7ab3c4..76ea912 100644 Binary files a/dwm/slstatus/components/volume.o and b/dwm/slstatus/components/volume.o differ diff --git a/dwm/slstatus/components/weather.c b/dwm/slstatus/components/weather.c new file mode 100644 index 0000000..a19662b --- /dev/null +++ b/dwm/slstatus/components/weather.c @@ -0,0 +1,21 @@ +#include +#include + +#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); +} diff --git a/dwm/slstatus/components/weather.o b/dwm/slstatus/components/weather.o new file mode 100644 index 0000000..6c4d4fd Binary files /dev/null and b/dwm/slstatus/components/weather.o differ diff --git a/dwm/slstatus/components/wifi.o b/dwm/slstatus/components/wifi.o index dd05aef..ded0a46 100644 Binary files a/dwm/slstatus/components/wifi.o and b/dwm/slstatus/components/wifi.o differ diff --git a/dwm/slstatus/components/wttr.sh b/dwm/slstatus/components/wttr.sh new file mode 100755 index 0000000..c3175be --- /dev/null +++ b/dwm/slstatus/components/wttr.sh @@ -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 \ No newline at end of file diff --git a/dwm/slstatus/config.h b/dwm/slstatus/config.h index d5d1055..e81d7a1 100644 --- a/dwm/slstatus/config.h +++ b/dwm/slstatus/config.h @@ -65,7 +65,8 @@ static const char unknown_str[] = "n/a"; */ static const struct arg args[] = { /* function format argument */ - { datetime, "| %s | ", "%F %T" }, + { weather, "| %s | ", NULL }, + { datetime, "%s | ", "%F %T" }, { cpu_perc, " %s% | ", NULL }, { ram_used, "󰘚 %s/", NULL }, { ram_total, "%s | ", NULL }, diff --git a/dwm/slstatus/slstatus b/dwm/slstatus/slstatus index 01cb374..0c898ad 100755 Binary files a/dwm/slstatus/slstatus and b/dwm/slstatus/slstatus differ diff --git a/dwm/slstatus/slstatus.h b/dwm/slstatus/slstatus.h index 8ef5874..5dbc979 100644 --- a/dwm/slstatus/slstatus.h +++ b/dwm/slstatus/slstatus.h @@ -82,3 +82,5 @@ const char *vol_perc(const char *card); /* wifi */ const char *wifi_essid(const char *interface); const char *wifi_perc(const char *interface); + +const char *weather(); diff --git a/dwm/slstatus/slstatus.o b/dwm/slstatus/slstatus.o index 71f5422..523f51c 100644 Binary files a/dwm/slstatus/slstatus.o and b/dwm/slstatus/slstatus.o differ diff --git a/dwm/slstatus/util.o b/dwm/slstatus/util.o index c4fa245..0ffa042 100644 Binary files a/dwm/slstatus/util.o and b/dwm/slstatus/util.o differ diff --git a/dwm/startdwm.sh b/dwm/startdwm.sh index d786585..9338e6e 100755 --- a/dwm/startdwm.sh +++ b/dwm/startdwm.sh @@ -7,6 +7,7 @@ setxkbmap "us,ru" -option 'grp:win_space_toggle' slstatus & dunst & ~/dotfiles/bin/dpmsdisablexorg +~/dotfiles/dwm/slstatus/components/wttr.sh xrdb -merge ~/dotfiles/dwm/Xresources diff --git a/hypr/startup.conf b/hypr/startup.conf index 8da98e1..ea8c1e4 100644 --- a/hypr/startup.conf +++ b/hypr/startup.conf @@ -8,7 +8,9 @@ exec-once = waybar #exec-once = ~/dotfiles/background-swww.sh #--------------------------------------- +#-------- polkit ------ exec-once = lxpolkit +#---------------------- #------------------------------ GTK settings ------------------------------------ exec-once = gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'