You are not logged in.

#76 2015-02-23 17:21:01

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,488
Website

Re: shaman - A small C program to fetch weather

Cameo, I am sorry you are having trouble with shaman. If you have XDG_CONFIG_HOME defined, then shaman will look for files under that directory first. Second, you should definitely not need to download the .json files ahead-of-time; they are downloaded dynamically upon request for data (also, I am not sure what running `updatedb` would accomplish). Additionally, `-r` forces a cache to be refreshed (you cannot simply run it alone)—also, you should probably never use this option. Finally, if you read the man page a little more closely, you'll notice that the two-letter code is not the state, but rather the country, so the correct invocation for you would be `shaman -l'Los Gatos,US'`.

Do you have XDG_CONFIG_HOME defined? If not, did shaman create ~/.shaman, or did you try to manually create it yourself?

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#77 2015-02-23 23:40:15

cameo
Member
Registered: 2012-08-18
Posts: 54

Re: shaman - A small C program to fetch weather

HalosGhost wrote:

Cameo, I am sorry you are having trouble with shaman. If you have XDG_CONFIG_HOME defined, then shaman will look for files under that directory first. Second, you should definitely not need to download the .json files ahead-of-time; they are downloaded dynamically upon request for data

Hi, thanks for your response. Dynamic download, good to know. But yet not for me.

HalosGhost wrote:

(also, I am not sure what running `updatedb` would accomplish).

Well, since shaman is from the AUR, this was my last choice for finding eventually missing new files.

HalosGhost wrote:

Additionally, `-r` forces a cache to be refreshed (you cannot simply run it alone)—also, you should probably never use this option.

Probably not, I just hoped this would create some kind of data base in the end. But it didn't.

HalosGhost wrote:

Finally, if you read the man page a little more closely, you'll notice that the two-letter code is not the state, but rather the country, so the correct invocation for you would be `shaman -l'Los Gatos,US'`.

Be sure, I tried to invoke the program in many ways and with different global locations (like in the manpage in this thread). And I already tried yours also -- same result!   

HalosGhost wrote:

Do you have XDG_CONFIG_HOME defined? If not, did shaman create ~/.shaman, or did you try to manually create it yourself?

In fact I haven't. I just installed xdg-user-dirs, ran xdg-user-dirs-update, but this variable is still empty. Maybe I should also reboot or re-login first. -- Anyway ~/.shaman/ was created by shaman.

Last edited by cameo (2015-02-23 23:42:26)

Offline

#78 2015-02-23 23:48:46

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,488
Website

Re: shaman - A small C program to fetch weather

No, if you don't have it defined, then it should default to ~/.shaman (and it sounds like it did). Try this:

$ shaman -l'Los Gatos,US' -c "$HOME/.shaman/imperial.json"

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#79 2015-02-24 00:04:17

cameo
Member
Registered: 2012-08-18
Posts: 54

Re: shaman - A small C program to fetch weather

... unfortunately remains the same, and ~/.shaman/ is still empty:

$ shaman -l'Los Gatos,US' -c "$HOME/.shaman/imperial.json"
The specified cache path does not exist
$ shaman -l'Los Gatos,US'
The specified cache path does not exist

Last edited by cameo (2015-02-24 00:06:05)

Offline

#80 2015-02-24 00:22:57

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,488
Website

Re: shaman - A small C program to fetch weather

Okay, well I am truly not sure what is happening, but I think I know of a work around. try the following:

$ touch "$HOME/.shaman/{imperial,metric}.json"

Then try again. Let me know if that gets it working.

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#81 2015-02-24 01:48:07

cameo
Member
Registered: 2012-08-18
Posts: 54

Re: shaman - A small C program to fetch weather

$ touch "$HOME/.shaman/{imperial,metric}.json"
~ shaman -l'Los Gatos,US'  # with or without the -c option
The specified cache path does not exist
$ ls ~/.shaman
{imperial,metric}.json
$ rm ~/.shaman/*
$ touch "$HOME/.shaman/metric.json"
$ touch "$HOME/.shaman/imperial.json"
$ shaman -l'Los Gatos,US'
Sky is Clear (61.07°F)
$ shaman -m -l'Los Gatos,US'
Sky is Clear (15.6°C)
$ shaman -m -l'London,GB'
overcast clouds (4.4°C)
$ shaman -m -l "London,GB"
overcast clouds (4.4°C)
$ shaman -m -l London,GB 
overcast clouds (4.4°C)
$ shaman -m -l=London,GB 
overcast clouds (4.4°C)
$ shaman -ml London,GB 
overcast clouds (4.4°C)
$ touch $HOME/.shaman/{foo,bar}  # leaving the "" away
$ ls ~/.shaman/
bar  foo  imperial.json  metric.json

Terrific, there's some progress! big_smile
Cool then, this should work with any location on openweathermap.org, I guess.

Tomorrow I'll look for nice monochrome weather icons, including the moon for displaying weather at night. For this reason, is there a way to show an international location's local time? The -v option seems not to do it.

Offline

#82 2015-02-24 01:51:26

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,488
Website

Re: shaman - A small C program to fetch weather

Ahh yes, that was my fault for quoting the brace expansion. I am glad it's now working correctly. You can get the timestamp of the data with a format specifier. See the man page for more details.

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#83 2015-02-24 02:10:37

cameo
Member
Registered: 2012-08-18
Posts: 54

Re: shaman - A small C program to fetch weather

Ah yes, sure. Looks e.g. like this then:

$ shaman -ml London, GB -f "%I,%j %c at %a" 
London,United Kingdom light rain at 1424742709

Well, the country code is different, and here it's 3 am, and I'm too tired now to calculate the Unix time into human readable. So I'm going to sleep now.   But shaman is cool stuff. Thanks for sharing! <3

Offline

#84 2015-02-24 02:13:10

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,488
Website

Re: shaman - A small C program to fetch weather

You should quote the location string so that the `-l` option actually receives "London, GB" and not just "London,". And, allowing for specific formatting of time variables is a planned feature smile I'm glad you like it!

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#85 2015-02-24 02:27:27

cameo
Member
Registered: 2012-08-18
Posts: 54

Re: shaman - A small C program to fetch weather

$ shaman -ml "London, GB" -f "%I,%j %c at %a" 
London,GB light rain at 1424743309

Agreed!  ^^
Well, I'm sure there are nice time converters around. But the time shown here -- isn't this actually localhost's anyway?

Good night~

Edit: However, there's no format specifier for average temperature, just for low and high temperature.

Last edited by cameo (2015-02-24 11:05:34)

Offline

#86 2015-02-24 02:31:23

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,488
Website

Re: shaman - A small C program to fetch weather

cameo wrote:

isn't this actually localhost's anyway?

it's the GMT in unixtime of the time the data was sent.

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#87 2015-02-24 09:12:49

mkoskar
Member
From: /location.jpg
Registered: 2014-07-16
Posts: 61
Website

Re: shaman - A small C program to fetch weather

Related to recent discussion about cache and time formatting, I thought I share my take on it. While ago I wrote simple wrapper around shaman which would handle multiple locations, simple output coloring and basic time formatting. For time formatting I use PKGBUILD with simple patch here https://github.com/mkoskar/pkgbuilds/tr … shaman-git. To handle multiple runs I do hash of all options for completeness. It's simple, straightforward but most likely overkill and probably better / faster fingerprint could be devised. Anyway, thanks goes to HalosGhost for shaman in first place, long-time user here smile.

$ cat ~/bin/wi
#!/bin/bash

set -e

ti_reset=$'\e[m'
ti_hi0=$'\e[1;37m'
ti_hi1=$'\e[1;32m'
ti_hi2=$'\e[1;31m'
ti_hi3=$'\e[1;33m'

format="%I, %j (%l, %L) at %a
----------------------------------------
Condition:              ${ti_hi0}%c${ti_reset}
Clouds:                 ${ti_hi0}%d%%${ti_reset}
Barometric pressure:    %bhPa
Precipitation:          %pmm
Relative humidity:      ${ti_hi0}%P%%${ti_reset}
Temperature:            Low: ${ti_hi1}%h°C${ti_reset} / High: ${ti_hi2}%H°C${ti_reset} / Current: ${ti_hi3}%t°C${ti_reset}
Wind:                   %X (%x°), %wmps, %Wmps
Sun:                    %s / %S
"

get() {
    local opts=(-m -l "$1")
    local opts_digest=$(md5sum <<<"${opts[*]}" | awk '{print $1}')
    local cache="$HOME/.cache/shaman-${opts_digest: -7}.json"
    touch "$cache"
    shaman "${opts[@]}" -f "$format" -c "$cache"
}

echo
get 'Prague,CZ'
get 'Berlin,DE'
get 'London,GB'

Last edited by mkoskar (2015-02-24 09:13:21)


HomeBlogGitHubAUR

Offline

#88 2015-02-24 12:37:18

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,488
Website

Re: shaman - A small C program to fetch weather

Mmm, colored printing… I wonder how I'd never thought of that. Additionally, supporting multiple queries at once is a great idea.

Shaman has been left on the shelf for a bit too long I think. Perhaps it is about time I revive it again.

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

Board footer

Powered by FluxBB