You are not logged in.

#21 2018-01-28 16:04:54

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,645

Re: conky for Helium

^ Yes, I have another path.

The script doesn't work for me. I haven't found the mistake yet. In your image, does it work for you?

Also, I can't run both syntaxes (conky1.9 and conky1.10) in one system. I always have to change Distribution.  tongue

Offline

#22 2018-01-28 16:55:15

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

^Yes, that script did work for me for a short time. This script is still working (I just noticed there alignr but no alignl and it writes the city name one syntax to the right). I'll have a closer look at damo's script, maybe I missed some setting.

Offline

#23 2018-01-28 17:40:46

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,066
Website

Re: conky for Helium

martix wrote:

It's actually Sector 11's work with minor changes. Writing here feel likes wandering around in Sector 11's department

Yes indeed: the only reason that BunsenLabs sees so far and reaches so high is because we stand on the shoulders of giants cool

unklar wrote:

do you really want Conky1.10?

BunsenLabs is currently commited to the upstream Debian stable version and I really can't see this changing for Helium.

As such, the stock conky version for Helium will be v1.10 and anybody wanting to use the old version will have to either install an old .deb or use my package:

https://forums.bunsenlabs.org/viewtopic.php?id=3804

martix wrote:

Window title is "BunsenLabs Default Conky" now - I'm not sure it should match some githubs names or is it ok like that?

That name sounds fine to me, at least it is obvious.

Offline

#24 2018-01-28 18:46:49

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,645

Re: conky for Helium

Head_on_a_Stick wrote:
unklar wrote:

do you really want Conky1.10?

BunsenLabs is currently commited to the upstream Debian stable version and I really can't see this changing for Helium.

As such, the stock conky version for Helium will be v1.10 and anybody wanting to use the old version will have to either install an old .deb or use my package:

Thank you for the crystal clear announcement!   wink   big_smile

Offline

#25 2018-01-28 21:11:37

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

I just tried damo's script with arrays and it's working after all. It looks different than the other version:
conkyweatherdamoarray.th.png

Actually just using one api number seems to work fine. Any testing of those 3 lines and damo's script from post #14 is appreciated.

Just to sum up at this point of time:
- Disk usage implemented, Root usage and Home usage commented out. Old syntax and new syntax scripts are the same.

- Damo's bunsenweather.sh script is working, output might need formatting, (commented out) bunsenweather.sh line not added yet

- Shipping with api number in bunsenweather.sh - consider or not? In this case removing "#" would get bunsenweather working (as it uses ipinfo.io and gets location according to that)

- sans-serif - making slightly bigger as new syntax uses smaller letters?

- Menu open at Super - Will be commented out or maybe implemented?

Offline

#26 2018-01-28 22:42:50

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,645

Re: conky for Helium

The script from #14 doesn't work for me.
However, this one fine

bl-orig-default9.th.jpg

# conky1.9 configuration   
	own_window yes
	own_window_type normal
	own_window_transparent yes
	own_window_hints undecorated,below,skip_taskbar,skip_pager  #sticky
#own_window_colour 000000
	own_window_class Conky
	own_window_title BunsenLabs Default Conky
	own_window_argb_visual yes

	minimum_size 200 0 
	maximum_width 200

	gap_x 40  #left | right
	gap_y 45  #up | down

	alignment top_left

	use_xft yes
#font Liberation Mono:bold:size=10
#font Liberation Sans:size=10
	font Sans-serif:size=10
	xftalpha 1
	override_utf8_locale yes

	uppercase no
  
	draw_shades no
	default_shade_color 000000

	draw_outline no
	default_outline_color 000000
        default_color 678b8b  #Beam green
#default_color 656667  #Waldorf original colour
#default_color 7a7a7a  #Flame  & BunsenLabs Grey
#default_color 929292  #BunsenLabs Grey
#default_color C0C0C0  #BunsenLabs Silver
	color0 B0E0E6  #PowderBlue
	color1 778899  #LightSlateGray
	color2 D8BFD8  #Thistle
	color3 9ACD32  #YellowGreen
	color4 FFA07A  #LightSalmon
	color5 FFDEAD  #NavajoWhite
	color6 00BFFF  #DeepSkyBlue
	color7 5F9EA0  #CadetBlue
	color8 BDB76B  #DarkKhaki
	color9 C0C0C0  #Silver	
  
	draw_borders no
	stippled_borders 5
	border_inner_margin 5
	border_outer_margin 0
	border_width 2

	draw_graph_borders no
	background yes
	use_spacer none
	no_buffers yes
	short_units yes
	imlib_cache_size 0
	double_buffer yes
	update_interval 1


TEXT
S Y S T E M    I N F O
${hr}
Host:${alignr}${nodename}
Uptime:${alignr}${uptime}
RAM:$alignr${mem} / ${memmax}
Swap usage:${alignr}${swap} / ${swapmax}
Root usage:$alignr${fs_used /} / ${fs_size /}
Home usage:$alignr${fs_used /home} / ${fs_size /home}
CPU Average:${alignr}${cpu cpu0}%

B U N S E N   W E A T H E R
${hr}
${execpi 600 $HOME/.conky/bl-conky/orig_bunsenweather.sh}

S H O R T C U T    K E Y S
${hr}
Alt + F2${alignr}Run Dialog
Alt + F3${alignr}Alt Menu
Super + Space${alignr}Main Menu
Super + Tab${alignr}Client Menu
Super + t${alignr}Terminal
Super + f${alignr}File Manager
Super + e${alignr}Editor
Super + m${alignr}Media Player
Super + w${alignr}Web Browser
Super + h${alignr}Task Manager
Super + l${alignr}Lock Screen
Super + v${alignr}Volume Control
Super + x${alignr}Logout
PrtSc${alignr}Screenshot
#!/bin/bash
#
## bunsenweather.sh by <damo> June 2016
## based on ideas from weatherbang.sh version 1.0, 2013 by Ryan Fantus
##
## Requires:
##          'jq' (sudo apt-get install jq);
##          API Key from http://openweathermap.org/api
##
## USAGE: Call this script from Conky with ( replace "<t>" with the update interval)
##          ${execpi <t> $HOME/.config/conky/scripts/bunsenweather.sh [location]}


#### User configurables:  ##############################################

# Get API KEY by registering for one at http://openweathermap.org/api
api="cbcdd9a40999d5d68afc55145f756764"

# Either set the location manually here, or by passing it as a script parameter in the Conky
place="$1"
place="Dresden"

# Choose fahrenheit/Imperial or Celcius/metric:
#metric='imperial' && unit='F'
metric='metric' && unit='C'

########################################################################
# If latlong is preferred then don't set a value for $place
if [[ -z $place ]];then
    # Geolocate IP:
    ipinfo=$(curl -s ipinfo.io)
    latlong=$(echo $ipinfo | jq -r '.loc')
    # Parse the latitude and longitude
    lat=${latlong%,*}
    long=${latlong#*,}
    location="lat=$lat&lon=$long"
else
    location="q=$place"
fi

weather=$(curl -s http://api.openweathermap.org/data/2.5/weather\?APPID\=$api\&$location\&units\=${metric})
### TODO: better to try and put the output into a jq array, to reduce the processes :/ ###
city=$(echo $weather | jq -r '.name')
temperature=$(printf '%.0f' $(echo $weather | jq '.main.temp'))
condition=$(echo $weather | jq -r '.weather[0].main')
wind=$(echo $weather | jq '.wind.speed')
winddir=$(echo $weather | jq '.wind.deg')
humidity=$(echo $weather | jq '.main.humidity')
pressure=$(echo $weather | jq '.main.pressure') 

# Format the output with printf
printf "%s: %s\n\${goto 5}Wind: %d m/s, from %.3d°\n\${goto 5}Temp: %d°C\n\${goto 5}Humidity: %d%%\n\${goto 5}Pressure: %d hPa" "$city" "$condition" "$wind" "$winddir" "$temperature" "$humidity%" "$pressure" 2>/dev/null

exit

(provisional with conky1.9)  big_smile

Offline

#27 2018-01-29 02:52:44

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,556
Website

Re: conky for Helium

martix wrote:

Question: Use Disk (and Swap) usage as default and commented-out Root usage and Home usage?

Disk + Swap sounds good, with alternatives commented out.

Sidenote: Just noticed that "conky.config = {" and "conky.text = [[" are differnt in the script. In the conky.text section "--" won't work.

Right: https://github.com/brndnmtthws/conky/wi … .10-syntax

Edit: In the script it's now 10 without bold.

OK

martix wrote:

Try both conky scripts, the first one in the OP (old syntax) or the new syntax here (they are the same now).
Both scripts have "sans-serif:size=10".
BUT: Using the old syntax, the actual text looks much bigger than the text according the new syntax with the same font size.

The new conky (1.10) will try to interpret old style conky files, but as you see, it won't always be exactly right. Let's move on to the 1.10 syntax, at least for default BunsenLabs files.

- sans-serif - making slightly bigger as new syntax uses smaller letters?

I thought 'Sans-serif:size=10' looked OK in new syntax. I like the rather low-key conky, but... other opinions?

Will be Menu open on pressing the Super key implemented or only as a commented out line?

This is on the todo list, so might well be implemented, but let's comment it out until it actually arrives.

martix wrote:

- Disk usage implemented, Root usage and Home usage commented out.

Add Swap too?

- Damo's bunsenweather.sh script is working, output might need formatting, (commented out) bunsenweather.sh line not added yet
- Shipping with api number in bunsenweather.sh - consider or not? In this case removing "#" would get bunsenweather working (as it uses ipinfo.io and gets location according to that)

How reliable is bunsenweather.sh, and which is now the definitive version? Damo made a number of improvements to his script - is it OK, or still needs work? Anyway it looks as if the currently shipped script ( https://github.com/BunsenLabs/bunsen-co … weather.sh ) no longer works.

I think we have three options for weather in default Helium:

1) If it now works OK (more testing?) then replace the old script, add the entry in the default conky, and display a small weather item by default.
2) If it has to be tweaked by the user to work properly, then add the new script, but comment out the entry in the conky.text section, and add a comment to the file as to what to do to make it work.
3) Remove everything, and just add a comment in the conky file with a link to the forum topic.

I'm personally OK with any of the above, but other opinions...?


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#28 2018-01-29 07:50:22

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

unklar wrote:

The script from #14 doesn't work for me.
(provisional with conky1.9)  big_smile

Thank you @unklar for the feedback.

Slowly I'm starting to understand this bunsenweather script. This working script you mentioned was basically damo's first version with api key.

Originally in the shipped bunsenweather script there was no need for an api key, but openweathermap.org changed its service. It was required that users register and get an api key to use with service.  The original - shipped - script needed some tweaking and it is what I called above damo's first version with api key.

In this version there is a remark: "### TODO: better to try and put the output into a jq array, to reduce the processes hmm ###"

The script from #14 is damo's improved version with arrays and internet connection checking.

This script tries to connect to http://ftp.debian.org/debian/README. If there is a connection, it shows the weather data, otherwise a message: "No internet connection" "Weather information unavailable" (I changed it to info because the text was too wide for the conky).

It also checks if there is a required api key. If not, the message is: "No API key" "Weather info unavailable".

Formatting of the output: This line in the improved code

printf "Location:%s\nTemp: %s\nWind %s from %s\n" "$city" "$temperature" "$windspeed" "$winddir"

produces this output:
conkyimprovedweatherconky1.th.png

And this:

printf "%s: %s\n\${voffset 10}Wind: %d m/s, from %.3d°\nTemp:\${color red} %d°c\${color}" "$city" "$condition" "$windspeed" "$winddir" "$temperature" 2>/dev/null

looks like this:
conkyimprovedweatherconky2.th.png


As mentioned above, this improved version of the script works for me. Feedback appreciated (it looks like it slows down starting conky a bit if there is no internet connection). Edit: Just a clarifications for new users: It's about simply pasting this script into ~/.config/conky/scripts/bunsenweather.sh and replace the original script there.

#!/bin/bash
#
## bunsenweather.sh by <damo> June 2016
## Adapted from bunsenweather.sh, which was based on ideas from 
## weatherbang.sh version 1.0, 2013 by Ryan Fantus
##
## Requires:
##          'jq' (sudo apt-get install jq);
##          API Key from http://openweathermap.org/api
##
## USAGE: Call this script from Conky with ( replace "<t>" with the update interval)
##          ${execpi <t> /path/to/bunsenweather.sh [location]}


#### User configurables:  ##############################################

# Get API KEY by registering for one at http://openweathermap.org/api
#api="your very long api number"
api="cbcdd9a40999d5d68afc55145f756764"
# Either set the location manually here, or by passing it as a script parameter in the Conky.
# "yourlocation" must be a name (which doesn't have spaces), or a numeric id.
#
# id's can be obtained from http://bulk.openweathermap.org/sample/city.list.json.gz
# Download and extract the json file, then simply search for an id with grep. 
#   For example:   grep "New York" city.list.json
#
# If $place is not set, then the script attempts to get a geolocation from the IP address.

place="$1"              # Get $place from script parameter.
#place="yourlocation"   # Uncomment and add name or id. NB If the name has spaces, then you must use the id.

# Choose fahrenheit/Imperial or Celcius/metric:
#metric='imperial'
metric='metric'

#########################################################################
connectiontest() {
    local -i i attempts=${1-0}
    for (( i=0; i < attempts || attempts == 0; i++ )); do
        if wget -O - 'http://ftp.debian.org/debian/README' &> /dev/null; then
            return 0
        fi
        if (( i == attempts - 1 )); then # if last attempt
            return 1
        fi
    done
}

placeholder() {
    if (( $1 == 1 )) &>/dev/null;then
        echo "No internet connection"
        echo "Weather info unavailable"
    else
        echo "No API key"
        echo "Weather info unavailable"
    fi
}

if [[ $metric == metric ]] &>/dev/null;then
    scaleT="°C"
    scaleV="m/s"
else
    scaleT="°F"
    scaleV="mph"
fi

if [[ -z "$api" ]] &>/dev/null;then
    placeholder 0 && exit 1
else
    connectiontest 10
    
    # If latlong is preferred then don't set a value for $place
    if (( $? == 0 )) &>/dev/null;then
        if [[ -z $place ]] &>/dev/null;then
            # Geolocate IP:
            ipinfo=$(curl -s ipinfo.io)
            latlong=$(echo "$ipinfo" | jq -r '.loc')
            # Parse the latitude and longitude
            lat=${latlong%,*}
            long=${latlong#*,}
            location="lat=$lat&lon=$long"
        else
            # check if numeric id, or placename is being used
            [[ ${place##*[!0-9]*} ]] &>/dev/null && location="id=$place" || location="q=$place"
        fi

        # get json data from openweathermap:
        weather=$(curl -s http://api.openweathermap.org/data/2.5/weather\?APPID=$api\&"$location"\&units=$metric)
        city=$(echo "$weather" | jq -r '.name') # In case location has spaces in the name
        weather_desc=$(echo "$weather" | jq -r '.weather[0].description')   # In case description has spaces in the name

        # load values into array:
        all=($(echo "$weather" | jq -r '.coord.lon,.coord.lat,.weather[0].main,.main.temp,.main.pressure,.main.temp_min,.main.temp_max,.wind.speed,.wind.deg,.clouds.all,.sys.sunrise,.sys.sunset'))
        #                   ARRAY INDEX  0          1          2                3          4              5              6              7           8         9           10           11

        longitude=$(printf '%06.1f' ${all[0]})
        latitude=$(printf '%+.1f' ${all[1]})
        condition="${all[2]}"
        temperature=$(printf '%+.1f%s' ${all[3]} $scaleT)
        pressure=$(printf '%.f %s' ${all[4]} mb)
        temperature_min=$(printf '%+.1f%s' ${all[5]} $scaleT)
        temperature_max=$(printf '%+.1f%s' ${all[6]} $scaleT)
        windspeed=$(printf '%.1f %s' ${all[7]} $scaleV)
        winddir=$(printf '%3.f%s' ${all[8]} °)
        cloud_cover=$(printf '%d%s' ${all[9]} %)
        sunrise=$(date -d @${all[10]} +"%R")
        sunset=$(date -d @${all[11]} +"%R")
        description="$weather_desc"
        
        #Example format for output:
        printf "Location: %s\nTemp: %s\nWind %s from %s\n" "$city" "$temperature" "$windspeed" "$winddir"

    else
        placeholder 1
    fi
fi

exit

This goes into conkyrc under conky.text (600 means update interval 600 seconds) to call the script:

W E A T H E R
${hr}
${execpi 600 $HOME/.config/conky/scripts/bunsenweather.sh}

Last edited by martix (2018-01-29 15:26:24)

Offline

#29 2018-01-29 08:28:35

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

johnraff wrote:

Disk + Swap sounds good, with alternatives commented out.

Done.

johnraff wrote:

Let's move on to the 1.10 syntax, at least for default BunsenLabs files.
I thought 'Sans-serif:size=10' looked OK in new syntax. I like the rather low-key conky, but... other opinions?

Yeah, that's fine by me with 1.10 syntax. What I meant is that the old conky using font size 9 was bigger than the new syntax conky with font size 10, because of the font size issue mentioned.

Now it is sans-serif 10, which looks ok, but the font size is considerably smaller than it used to be. This is why I mentioned making it a bit bigger using size 10.5, but I'm not sure how it looks on other screens. On my notebook 10.5 is better to read than 10.

johnraff wrote:

Add Swap too?

Yep, swap is there on default.

johnraff wrote:

How reliable is bunsenweather.sh, and which is now the definitive version? Damo made a number of improvements to his script - is it OK, or still needs work? Anyway it looks as if the currently shipped script ( https://github.com/BunsenLabs/bunsen-co … weather.sh ) no longer works.

Indeed, it was a version without api key.

I think there is no definitive version, but at least the script at the end of this post was damo's last - updated - version. It looks like this bunsenweather script did not draw much attention so far.

The script works for me, but there is more feedback needed.

johnraff wrote:

I think we have three options for weather in default Helium:
2) If it has to be tweaked by the user to work properly, then add the new script, but comment out the entry in the conky.text section, and add a comment to the file as to what to do to make it work.

I'd say go for this option. Make a commented out entry in conky.text with a short description. bunsenweather.sh works out-of-the-box,IF it is shipped together with an api key (which requires a registration on openweathermap.org; the api key above in the post goes back to bra10n's post).

Basically it looks good, script is working, code is ready for conky.text, if the user will remove the # from those three bunsenweather lines, there will be a weather conky.

Offline

#30 2018-01-29 08:59:16

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

What about having this Weather format on default in the bunsenweather script?

conkyweatherformat.th.png

Sorry about those screenshot posts above, should've cut off the shortcuts.

Edit: I can confirm that with the activated Weather conky it starts slowly without internet connection. It takes some seconds till the conky appeares. Otherwise it works fine so far, update interval works, it's getting correct data.

As a sidenote: For weather don't forget the good old terminal

curl -4 wttr.in/bunsen

Edit II: There is one more cool feature of bunsenweather.sh. There is no need to edit bunsenweather.sh (the script above in post #28), in order to get the weather for whatever city the user wants. Using simply this line with "yourlocation" in the conky.text section works fine (let's try an example as a tribute for the creator of the script):

${execpi 600 $HOME/.config/conky/scripts/bunsenweather.sh "damo"}

conkyweather4.th.png

Last edited by martix (2018-01-29 12:12:02)

Offline

#31 2018-01-29 13:04:21

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,645

Re: conky for Helium

#28

Now it works. Nevertheless, there are mistakes.

-IP-Localisation deviates from 150 - 200 km

[unklar@archhost ~]$ conky: desktop window (2000012) is subwindow of root window (4d5)
conky: window type - normal
conky: drawing to created window (0x3800002)
conky: drawing to double buffer
conky: forked to background, pid is 3781

/home/unklar/conky/bunsenweather.sh: Zeile 96: printf: 13.74: Ungültige Zahl.
/home/unklar/conky/bunsenweather.sh: Zeile 97: printf: 51.05: Ungültige Zahl.
/home/unklar/conky/bunsenweather.sh: Zeile 103: printf: 7.2: Ungültige Zahl.

-windspeed is not displayed
-no change even if the city is specified

bl-NEUdefault10.th.jpg

martix wrote:

Edit: I can confirm that with the activated Weather conky it starts slowly without internet connection. It takes some seconds till the conky appeares.

Of course the script has to collect the data first.
So that's normal.

Offline

#32 2018-01-29 15:07:53

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

^That's strange. I just tried

${execpi 600 $HOME/.config/conky/scripts/bunsenweather.sh "dresden"}

and it looks good here:
conkyweatherd.th.png

I have the script from #28.

Offline

#33 2018-01-30 05:38:42

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,556
Website

Re: conky for Helium

Confirmed, Damo's script works for me, either passing "Nagoya" (or other cities) in the execpi line, or letting it figure it out from the IP.
I also added "humidity" by extending the array by one element. The info is there anyway.

Still, users will have to edit the script to paste in an API KEY. I "borrowed" the one posted by bra10n, but we can't exactly enable that by default - all the new BL Helium users would be hitting that account and it would soon be closed, so let's leave weather commented out in the conky we ship.

Here's my script with humidity:

#!/bin/bash
#
## bunsenweather.sh by <damo> June 2016
## Adapted from bunsenweather.sh, which was based on ideas from 
## weatherbang.sh version 1.0, 2013 by Ryan Fantus
##
## Requires:
##          'jq' (sudo apt-get install jq);
##          API Key from http://openweathermap.org/api
##
## USAGE: Call this script from Conky with ( replace "<t>" with the update interval)
##          ${execpi <t> /path/to/bunsenweather.sh [location]}


#### User configurables:  ##############################################

# Get API KEY by registering for one at http://openweathermap.org/api
#api="your very long api number"
api="cbcdd9a40999d5d68afc55145f756764"

# Either set the location manually here, or by passing it as a script parameter in the Conky.
# "yourlocation" must be a name (which doesn't have spaces), or a numeric id.
#
# id's can be obtained from http://bulk.openweathermap.org/sample/city.list.json.gz
# Download and extract the json file, then simply search for an id with grep. 
#   For example:   grep "New York" city.list.json
#
# If $place is not set, then the script attempts to get a geolocation from the IP address.

place="$1"              # Get $place from script parameter.
#place="yourlocation"   # Uncomment and add name or id. NB If the name has spaces, then you must use the id.

# Choose fahrenheit/Imperial or Celcius/metric:
#metric='imperial'
metric='metric'

#########################################################################
connectiontest() {
    local -i i attempts=${1-0}
    for (( i=0; i < attempts || attempts == 0; i++ )); do
        if wget -O - 'http://ftp.debian.org/debian/README' &> /dev/null; then
            return 0
        fi
        if (( i == attempts - 1 )); then # if last attempt
            return 1
        fi
    done
}

placeholder() {
    if (( $1 == 1 )) &>/dev/null;then
        echo "No internet connection"
        echo "Weather information unavailable"
    else
        echo "No API key"
        echo "Weather information unavailable"
    fi
}

if [[ $metric == metric ]] &>/dev/null;then
    scaleT="°C"
    scaleV="m/s"
else
    scaleT="°F"
    scaleV="mph"
fi

if [[ -z "$api" ]] &>/dev/null;then
    placeholder 0 && exit 1
else
    connectiontest 10
    
    # If latlong is preferred then don't set a value for $place
    if (( $? == 0 )) &>/dev/null;then
        if [[ -z $place ]] &>/dev/null;then
            # Geolocate IP:
            ipinfo=$(curl -s ipinfo.io)
            latlong=$(echo "$ipinfo" | jq -r '.loc')
            # Parse the latitude and longitude
            lat=${latlong%,*}
            long=${latlong#*,}
            location="lat=$lat&lon=$long"
        else
            # check if numeric id, or placename is being used
            [[ ${place##*[!0-9]*} ]] &>/dev/null && location="id=$place" || location="q=$place"
        fi

        # get json data from openweathermap:
        weather=$(curl -s http://api.openweathermap.org/data/2.5/weather\?APPID=$api\&"$location"\&units=$metric)
        city=$(echo "$weather" | jq -r '.name') # In case location has spaces in the name
        weather_desc=$(echo "$weather" | jq -r '.weather[0].description')   # In case description has spaces in the name

        # load values into array:
        all=($(echo "$weather" | jq -r '.coord.lon,.coord.lat,.weather[0].main,.main.temp,.main.pressure,.main.temp_min,.main.temp_max,.wind.speed,.wind.deg,.clouds.all,.sys.sunrise,.sys.sunset,.main.humidity'))
        #                   ARRAY INDEX  0          1          2                3          4              5              6              7           8         9           10           11          12

        longitude=$(printf '%06.1f' ${all[0]})
        latitude=$(printf '%+.1f' ${all[1]})
        condition="${all[2]}"
        temperature=$(printf '%+.1f%s' ${all[3]} $scaleT)
        pressure=$(printf '%.f %s' ${all[4]} mb)
        temperature_min=$(printf '%+.1f%s' ${all[5]} $scaleT)
        temperature_max=$(printf '%+.1f%s' ${all[6]} $scaleT)
        windspeed=$(printf '%.1f %s' ${all[7]} $scaleV)
        winddir=$(printf '%3.f%s' ${all[8]} °)
        cloud_cover=$(printf '%d%s' ${all[9]} %)
        sunrise=$(date -d @${all[10]} +"%R")
        sunset=$(date -d @${all[11]} +"%R")
        humidity="${all[12]}"
        description="$weather_desc"
        
        #Example format for output:
        #printf "%s; %s; %s %s" "$city" "$temperature" "$windspeed" "$winddir"
        printf "%s: %s\nTemp: %s\nHumidity: %s%%\nWind %s from %s\n" "$city" "$description" "$temperature" "$humidity" "$windspeed" "$winddir"

    else
        placeholder 1
    fi
fi

exit

And screenshot (not passing city name): bKGgAbnm.png


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#34 2018-01-30 08:49:02

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

^It's been working fine here too. Sometimes I got null:null for city when it stopped working for some reason, but it happened just once in a while. 

@johnraff Did you use the new syntax for the conky on the screenshot? On a 12" machine this conky covers for me a smaller area, less than 2/3 of the screen heigth with font size 10 (but it's still good readable). With size 10 "Weather information unavailable" fits the width. The default conky supposed to have one line less (as /home was commented out).

Humidity is a good idea. Actually I looked for it in the script but did not check the api description. Btw "Wind" could be removed on default as for the average user the data may not mean much.

So what about adding the following to conky.text between the System info and the Shortcuts:

# Weather information from openweathermap.org can be displayed in conky by
# using the script $HOME/.config/conky/scripts/bunsenweather.sh. The openweathermap
# service requires registration in order to receive an API Key, which has to be
# added to bunsenweather.sh. For further info see this script and the following thread:
# https://forums.bunsenlabs.org/viewtopic.php?id=2060

# Calling bunsenweather.sh from conky works by using
# ${execpi <t> /path/to/bunsenweather.sh "yourlocation"} 
# where <t> is the update interval. If "yourlocation" is not defined, the script
# sets geolocation based on your IP adress using the website ipinfo.io.

#W E A T H E R
#${hr}
#${execpi 600 $HOME/.config/conky/scripts/bunsenweather.sh}

Offline

#35 2018-01-30 08:58:27

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,556
Website

Re: conky for Helium

martix wrote:

@johnraff Did you use the new syntax for the conky on the screenshot?

Pretty much what you posted, yes the 1.10 version, but I may have missed the last couple of changes.

Btw "Wind" could be removed on default as for the average user the data may not mean much.

Agreed.


So what about adding the following to conky.text between the System info and the Shortcuts:

# Weather information from openweathermap.org can be displayed in conky by
# using the script $HOME/.config/conky/scripts/bunsenweather.sh. The openweathermap
# service requires registration in order to receive an API Key, which has to be
# added to bunsenweather.sh. For further info see this script and the following thread:
# https://forums.bunsenlabs.org/viewtopic.php?id=2060

# Calling bunsenweather.sh from conky works by using
# ${execpi <t> /path/to/bunsenweather.sh "yourlocation"} 
# where <t> is the update interval. If "yourlocation" is not defined, the script
# sets geolocation based on your IP adress using the website ipinfo.io.

#W E A T H E R
#${hr}
#${execpi 600 $HOME/.config/conky/scripts/bunsenweather.sh}

Looks good.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#36 2018-01-30 09:21:14

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

Ok, new syntax script is in #11, Weather conky added. It is also added to the old syntax script in the OP.

Double check:
- Spacing between the System Info and the Shortcut Keys sections (currently it's one empty line)
- Spacing above System Info (currently no empty line)
- If Menu-open-on-super will be implemented, this should be in the Shortcut Keys too.
- Remove API Key from bunsenweather.sh, remove Wind.

It looks good then. I may add that Sector 11 and damo made awesome work here as there were only a few minor changes to their scripts, otherwise everything has been working fine.

Edit: One minor thing that came to my mind: What is the way the default conky starts? Is it "conky -c ~/.conkyrc" (from conky-sessionfile)? Just because there is now  pkill -xf "conky -q -c $HOME/.config/conky/BL-Default.conkyrc"  but it'd be good to have a version which actually kills the default conky (that might be pkill -xf "conky -c $HOME/.conkyrc". I guess the "-q" is only relevant for starting the conky as it won't have output in the terminal (as unklar mentioned "quiet").

Last edited by martix (2018-01-30 09:36:07)

Offline

#37 2018-01-30 16:45:08

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,645

Re: conky for Helium

martix wrote:

Edit: One minor thing that came to my mind: What is the way the default conky starts? Is it "conky -c ~/.conkyrc" (from conky-sessionfile)? Just because there is now  pkill -xf "conky -q -c $HOME/.config/conky/BL-Default.conkyrc"  but it'd be good to have a version which actually kills the default conky (that might be pkill -xf "conky -c $HOME/.conkyrc". I guess the "-q" is only relevant for starting the conky as it won't have output in the terminal (as unklar mentioned "quiet").

Since usually the start with

conky -c ~/path/too/conkyrc &

has taken place, is

pkill -xf "conky -c /home/user/path/too/conkyrc" &

right.   wink

Offline

#38 2018-01-30 17:06:03

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

@unklar Johnraff mentioned that using the ampersand & is not necessary, it's removed from the script too.

Otherwise that's correct, just like it says in the script "IF you used what is between the quotes to start the conky", i.e. there must be the exact same switches (and "-q" is also relevant for closing, not like I mentioned above!). Just tried it: Starting with -c -q won't get closed using only conky -c in the pkill command.

Offline

#39 2018-01-31 02:58:08

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,556
Website

Re: conky for Helium

martix wrote:

Double check:
- Spacing between the System Info and the Shortcut Keys sections (currently it's one empty line)

Looks good.

- Spacing above System Info (currently no empty line)

Fine. There's no need for an empty space at the top of the conky. Positioning on the screen can be set by gap_y and gap_x.

- If Menu-open-on-super will be implemented, this should be in the Shortcut Keys too.
- Remove API Key from bunsenweather.sh, remove Wind.

I'll do those.

What is the way the default conky starts?

You can check all the currently running conkys with

pgrep -a conky

It looks as if the -q option is not being used at the moment.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#40 2018-01-31 04:00:25

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: conky for Helium

^Indeed, -q for killing a conky is only relevant, if someone used it before like

conky -c -q ~/.config/conky/BL-Left.conkyrc

pkill -xf " " won't work in this case, if there is no -q in the quotes (ie between the " " has to be the same as the conky start command). Hence killing the default conky works for me via

pkill -xf "conky -c $HOME/.conkyrc"

What I just realized is that the part recently added to the script

# BunsenLabs conky scripts help
# Openbox Menu/Preferences/Conky/Conky Manager Help

is - as it says - a help with "Conky Manager", which is actually "Openbox Menu/Preferences/Conky/Conky Chooser".

This Conky Chooser is an awesome little tool (created by damo) and it is the script /usr/bin/bl-conkyzen.

Conky Manager=Conky Chooser=bl-conkyzen - this might be a bit confusing for new users (especially as in the help it's about a Conky Manager and no word about "Conky Chooser". Btw it can be started also via terminal

bl-conkyzen

Last edited by martix (2018-01-31 04:01:33)

Offline

Board footer

Powered by FluxBB