Parsing data from inxi -xxxW to Conky ? (For weather)

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
punkbiscuit
Level 3
Level 3
Posts: 122
Joined: Wed Feb 08, 2017 3:06 pm

Parsing data from inxi -xxxW to Conky ? (For weather)

Post by punkbiscuit »

Hi all.

I just found out that the inxi command returns some weather data !

Using inxi -xxxW returns local observations, although I haven't a clue what the source is.

Example -

~ $ inxi -xxxW london,UK

Weather: Conditions: 41 F (5 C) - Scattered Clouds Wind: From the NNE at 15 MPH Humidity: 70%
Pressure: 30.27 in (1025 mb) Wind Chill: 33 F (1 C)
Location: London GLA (UK) Altitude: 17 ft
Time: February 4, 2:52 PM GMT Observation Time: February 4, 2:20 PM GMT



I just tried to see if I could find a way of using that data to be sent to my Conky script, but it doesn't seem to work.

Anyone know how I could get Conky to display that data ?

I think the weather stuff on Conky must be it's holy grail, since everyone seems to want it but the solutions or data sources are no longer
available.

My Conky flle is this -
  • background yes
    use_xft yes
    xftfont 123:size=9
    xftalpha 0.1
    update_interval 1.0
    total_run_times 0
    # Create own window instead of using desktop (required in nautilus)
    own_window yes
    own_window_transparent yes
    own_window_type dock
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    #These values set true transparancy
    own_window_argb_visual yes
    own_window_argb_value 0
    double_buffer yes
    minimum_size 250 5
    maximum_width 220
    draw_shades no
    draw_outline no
    draw_borders no
    draw_graph_borders no
    default_color gray
    default_shade_color red
    default_outline_color green
    alignment top_right
    gap_x 35
    gap_y 12
    no_buffers yes
    uppercase no
    cpu_avg_samples 2
    net_avg_samples 1
    override_utf8_locale yes
    use_spacer left
    text_buffer_size 256
    temperature_unit celsius


    own_window_colour 000000
    TEXT
    #SYSTEM
    ${voffset -30}
    ${color Gray}
    ${font Soul Papa:bold:size=10}${color Tan1}SYSTEM ${color DarkSlateGray} ${hr 2}

    ${color Gray}${font Inconsolata:size=9}$sysname $kernel $alignr $machine
    CPU $alignr ${freq_g cpu0}Ghz
    Uptime $alignr${uptime}

    ${color Gray}Local IP $alignr ${addr wlp2s0}
    ${color Gray}Public IP $alignr ${execi 3600 wget -q -O /dev/stdout http://checkip.dyndns.org/ | cut -d : -f 2- | cut -d \< -f -1}

    #DRIVES
    ${font Soul Papa:bold:size=10}${color Tan1}DRIVES ${color DarkSlateGray}${hr 2}
    ${font Inconsolata:size=9}${color Gray}
    / $alignc ${fs_used /} / ${fs_size /} $alignr ${fs_used_perc /}%
    ${color Gray}${fs_bar /}
    ${color Gray}/home $alignc ${fs_used /home} / ${fs_size /home} $alignr ${fs_used_perc /home}%
    ${color Gray}${fs_bar /home}

    #MEMORY
    ${font Soul Papa:bold:size=10}${color Tan1}MEMORY ${color DarkSlateGray}${hr 2}
    ${font Inconsolata:size=9}${color Gray}
    DDR3 $alignc $mem / $memmax $alignr $memperc%
    ${color green}${if_match ${memperc}<=40}${color olivedrab}${membar 5,} ${else}${if_match ${memperc}<=60}${color greenyellow}${membar 5,} ${else}${if_match ${memperc}<=80}${color darkorange}${membar 5,} ${else}${if_match ${memperc}>80}${color darkred}${membar 5,}${endif}${endif}${endif}${endif}${color}
    SWAP $alignc $swap / $swapmax $alignr $swapperc%
    ${color green}${if_match ${swapperc}<=40}${color olivedrab}${swapbar 5,} ${else}${if_match ${swapperc}<=60}${color greenyellow}${swapbar 5,} ${else}${if_match ${swapperc}<=80}${color darkorange}${swapbar 5,} ${else}${if_match ${swapperc}>80}${color darkred}${swapbar 5,}${endif}${endif}${endif}${endif}${color}


    #CPU
    ${font Soul Papa:bold:size=10}${color Tan1}CPU ${color DarkSlateGray}${hr 2}
    ${color Gray}${font Inconsolata:size=9}${alignr}${cpu cpu0}%
    ${color green}${if_match ${cpu cpu0}<=40}${color olivedrab}${cpubar cpu0 5,} ${else}${if_match ${cpu cpu0}<=60}${color greenyellow}${cpubar cpu0 5,} ${else}${if_match ${cpu cpu0}<=80}${color darkorange}${cpubar cpu0 5,} ${else}${if_match ${cpu cpu0}>80}${color darkred}${cpubar cpu0 5,}${endif}${endif}${endif}${endif}${color}


    #NETWORK
    ${font Soul Papa:bold:size=10}${color Tan2}WIFI - ${wireless_essid wlp2s0} ${color DarkSlateGray}${hr 2}
    ${font Inconsolata:size=9}${color Gray}
    ${color Gray}Wireless signal: $alignr $color${wireless_link_qual wlp2s0}%

    Up $alignr${upspeedf wlp2s0} KiB/s
    Uploaded: $alignr${totalup wlp2s0}
    ${upspeedgraph wlp2s0 White 80,}
    Down $alignr${downspeedf wlp2s0} KiB/s
    Downloaded: $alignr${totaldown wlp2s0}
    ${downspeedgraph wlp2s0 White 80,}

    ${font Soul Papa:bold:size=10}${color Tan1}ETHERNET CONNECTION ${color DarkSlateGray}${hr 2}
    ${font Inconsolata:size=9}${color Gray}
    ${color Gray}Ethernet Downloaded: $alignr${totaldown enp3s0f2}
    ${color Gray}Ethernet Uploaded: $alignr${totalup enp3s0f2}
Regards,

Andy
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Flemur
Level 20
Level 20
Posts: 10097
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Parsing data from inxi -xxxW to Conky ? (For weather)

Post by Flemur »

punkbiscuit wrote:I just found out that the inxi command returns some weather data !
~ $ inxi -xxxW london,UK

This

Code: Select all

${execi 2 inxi -xxxW london,UK }
or

Code: Select all

${exec inxi -xxxW london,UK } 
returned this:
conky_weather.jpg
So you probably have to 'cut', like this:

Code: Select all

${color green}${exec dmesg | cut -c15-50 | tail -n4} ${color white}
Edit: that's all in the "old format" ...

Edit2: remove the color codes: (the "[1;34m" kinda stuff)

Code: Select all

${exec inxi -c 0 -xxxW london,UK }
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
punkbiscuit
Level 3
Level 3
Posts: 122
Joined: Wed Feb 08, 2017 3:06 pm

Re: Parsing data from inxi -xxxW to Conky ? (For weather)

Post by punkbiscuit »

Brilliant Flemur, almost there ;-)

I'm missing some of the text on the output, anyway of fitting it in ?
conky.png
As a test file I just used this ,


${font Inconsolata:size=9}${color Gray}
${color Gray}
${exec inxi -c 0 -xxxW london,UK
${exec dmesg | cut -c15-50 | tail -n4} ${color white}

Kind regards,

Andy
User avatar
Flemur
Level 20
Level 20
Posts: 10097
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Parsing data from inxi -xxxW to Conky ? (For weather)

Post by Flemur »

punkbiscuit wrote:I'm missing some of the text on the output, anyway of fitting it in ?
Stick a "\n" in it?
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
AndyMH
Level 21
Level 21
Posts: 13580
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Parsing data from inxi -xxxW to Conky ? (For weather)

Post by AndyMH »

I've got two conkies running, one does the normal stuff, system info, the other the weather. The weather conky is a mix of conky and python, the python bit downloading and parsing info from the UK met office. Took a lot of effort, and it would probably require significant hacking for another PC and location, but happy to provide more detail. You also need an account (free) with the met office.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
pcwolf

Re: Parsing data from inxi -xxxW to Conky ? (For weather)

Post by pcwolf »

This line displays what and how I want in terminal:

inxi -xxxw | cut -c16- |sed -re ':a;N;$!ba;s/\n//g;s/(Conditions:)/\nCurrent:/;s/(Wind:)/\n&/;s/(Humidity:)/\n&/;s/(Pressure:)/\n&/;s/(Wind Chill:)/\n&/;s/Location:.*$//'

Now trying to learn myself how to have it update on interval X

-Phil
pcwolf

Re: Parsing data from inxi -xxxW to Conky ? (For weather)

Post by pcwolf »

Works now, thank you both!

Code: Select all

${execi 600 inxi -c 0 -xxxw | cut -c12- |sed -re ':a;N;$!ba;s/\n//g;s/(Conditions:)/\nCurrent:/;s/(Wind:)/\n&/;s/(Humidity:)/\n&/;s/(Pressure:)/\n&/;s/(Wind Chill:)/\n&/;s/Location:.*$//'}
Punkbiscuit, lowercase w supplies local conditions, uppercase W can select any city, AFAIK

-Phil
punkbiscuit
Level 3
Level 3
Posts: 122
Joined: Wed Feb 08, 2017 3:06 pm

Re: Parsing data from inxi -xxxW to Conky ? (For weather)

Post by punkbiscuit »

Yay !
Well done chaps.
Works very well now.

OK so it misses a bit of text on the Conditions line, but 90% of the data shows superbly !

This little exercise was fun for a few days, especially trying to find a source of useful info to diaply.

I can't believe how difficult it is to get some basic data out the Met Office etc without all this API stuff or getting an account set up
or even trying to make an RSS feed work.

I'm most grateful for everyone's input - thanks.

Off at a light tangent, I see that the altitude of the locations changes, so it must also be taking it's data from some OS mapping
source or similar. I tried changing the locations to towns within a mile or two away and they seemed to change.

I might take the gps coords and try that along with the altitdue that it gives me (I have 3 24/7 GPS monitors here for some RF gear
that I use) so I can easily grab the data. It would be interesting then to see if it matches.

Lots of interesting uses I think.
Locked

Return to “Compiz, Conky, Docks & Widgets”