LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 05-25-2020, 10:04 AM   #1
esteeven
Senior Member
 
Registered: Oct 2001
Location: Bristol UK
Distribution: Arch Slackware Ubuntu
Posts: 1,078

Rep: Reputation: 47
i3bar i3block refresh


I have a short script that returns the country of my IP to display in my i3bar using i3blocks. The script uses curl to get the country code.


Click image for larger version

Name:	Screenshot_2020-05-25_15-57-03.png
Views:	12
Size:	4.4 KB
ID:	33267


When the script refreshes, part of i3bar is blanked out for a few seconds.


Click image for larger version

Name:	Screenshot_2020-05-25_15-59-57.png
Views:	15
Size:	4.9 KB
ID:	33268


I have no idea why this is so. The script is simply:


Code:
#!bin/bash

curl 'ifconfig.co/country-iso'
 
Old 05-28-2020, 01:29 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,599
Blog Entries: 9

Rep: Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093
Does it blank always, or only sometimes ("random")?
My guess is that this happens because the website takes a while to respond and i3bar decides to leave the field blank for that time. You could work around that in several ways.

That said I have no clue how i3blocks (not part of i3wm) interacts with i3bar. Is it possible to pipe a script directly to i3bar?
 
Old 05-28-2020, 07:06 AM   #3
esteeven
Senior Member
 
Registered: Oct 2001
Location: Bristol UK
Distribution: Arch Slackware Ubuntu
Posts: 1,078

Original Poster
Rep: Reputation: 47
Quote:
Originally Posted by ondoho View Post
Does it blank always, or only sometimes ("random")?
My guess is that this happens because the website takes a while to respond and i3bar decides to leave the field blank for that time. You could work around that in several ways.
An interesting thought. I'll try a different url source
 
Old 05-28-2020, 07:18 AM   #4
esteeven
Senior Member
 
Registered: Oct 2001
Location: Bristol UK
Distribution: Arch Slackware Ubuntu
Posts: 1,078

Original Poster
Rep: Reputation: 47
Quote:
Originally Posted by ondoho View Post
Does it blank always, or only sometimes ("random")?
My guess is that this happens because the website takes a while to respond and i3bar decides to leave the field blank for that time. You could work around that in several ways.
That seems to have done the job. No more blanking. Oddly, a site "failure" didn't even cross my mind.

It's amazing how these tiny tiny issues can prey on your mind. I feel free again

For the record, I was using http://ifconfig.co/country-iso I have now switched to https://ipinfo.io/country

The reason I want this information in my i3bar is so that I know when I am connected to my VPN.

Last edited by esteeven; 05-28-2020 at 07:19 AM.
 
Old 05-29-2020, 08:48 AM   #5
esteeven
Senior Member
 
Registered: Oct 2001
Location: Bristol UK
Distribution: Arch Slackware Ubuntu
Posts: 1,078

Original Poster
Rep: Reputation: 47
Irony of ironies. ipinfo.io works really well but there is a limit on free use of the API. It worked until it didn't.

I think I may abandon my obsession with having the country of my VPN IP displayed by i3blocks. I'll simply check using CLI when I feel it's necessary to be certain that I'm connected "in" a specific country.

Have a good weekend everybody
 
Old 05-30-2020, 02:49 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,599
Blog Entries: 9

Rep: Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093
Actually, I didn't suggest to change the site at all.

You could try to rewrite the script in a way that "empty waiting" doesn't happen.

Also this:
Quote:
Originally Posted by ondoho View Post
That said I have no clue how i3blocks (not part of i3wm) interacts with i3bar. Is it possible to pipe a script directly to i3bar?

Last edited by ondoho; 05-30-2020 at 02:50 AM.
 
Old 05-30-2020, 05:45 AM   #7
esteeven
Senior Member
 
Registered: Oct 2001
Location: Bristol UK
Distribution: Arch Slackware Ubuntu
Posts: 1,078

Original Poster
Rep: Reputation: 47
Quote:
Originally Posted by ondoho View Post
Actually, I didn't suggest to change the site at all.

You could try to rewrite the script in a way that "empty waiting" doesn't happen.

No. You didn't suggest this. I simply hadn't considered that the site might be causing the issue. The issue went away once I changed the site. It created a new issue though


I will investigate rewriting my curl request so that the "empty waiting" doesn't occur.



Cheers
 
Old 05-30-2020, 05:47 AM   #8
esteeven
Senior Member
 
Registered: Oct 2001
Location: Bristol UK
Distribution: Arch Slackware Ubuntu
Posts: 1,078

Original Poster
Rep: Reputation: 47
Quote:
Originally Posted by ondoho https://www.linuxquestions.org/quest...s/viewpost.gif
That said I have no clue how i3blocks (not part of i3wm) interacts with i3bar. Is it possible to pipe a script directly to i3bar?

No idea. Yet.
Cheers
 
Old 05-31-2020, 02:01 AM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,599
Blog Entries: 9

Rep: Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093
Quote:
Originally Posted by esteeven View Post
I will investigate rewriting my curl request so that the "empty waiting" doesn't occur.
I didn't say that either.
Please be precise when quoting people.
I said you could try to rewrite the script.
You cannot tell the website to go faster, it's not in your or your computer's power.
But you can, e.g.: save the value you get from the site to a file, and update the file only when the value changes, and make i3blocks look at the file and not curl's output at all. Just an idea off the top of my head.

But there should be a simpler solution; I suspect soemthing is amiss in the interaction between
your script <=> i3blocks <=> i3bar
You have not given much information on that.
 
Old 05-31-2020, 05:13 AM   #10
esteeven
Senior Member
 
Registered: Oct 2001
Location: Bristol UK
Distribution: Arch Slackware Ubuntu
Posts: 1,078

Original Poster
Rep: Reputation: 47
Quote:
Please be precise when quoting people.
I'm lost. You are quoting me above. Is it that I used your words -- "empty waiting" -- that causes confusion?

Quote:
Originally Posted by esteeven View Post
I will investigate rewriting my curl request so that the "empty waiting" doesn't occur.
This is how I phrased what I intend to do. It exposes my limited experience with scripting but this is how I described my plan of action.

Quote:
But there should be a simpler solution; I suspect soemthing is amiss in the interaction between
your script <=> i3blocks <=> i3bar
You have not given much information on that.
Let me quote myself:

Quote:
No idea. Yet.
Cheers
You are undoubtedly correct when you say that there is something amiss.

Quote:
I suspect soemthing is amiss in the interaction between
your script <=> i3blocks <=> i3bar
You have not given much information on that.
That's what I have no idea about. I have never delved into this because I have never needed to.

I'm going to mark this thread as solved.

Thanks for your help.
 
Old 06-03-2020, 02:18 PM   #11
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 14,599
Blog Entries: 9

Rep: Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093Reputation: 4093
Well, in a way you're right; it's possible that curl has some option that would avoid long waits.
But more important is how i3blocks & i3bar work together and how you integrated that script in the first place.
You aren't really sharing any details here, that makes it kinda impossible to find a solution together.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
JSON Error in i3wm with Conky (i3bar) itscience Linux - Desktop 1 09-09-2015 03:20 PM
i3status and i3bar mreff555 Linux - Software 21 08-19-2013 08:44 PM
Folder refresh. Where can I change how often the refresh occurs? glore2002 Slackware 2 08-12-2008 12:37 AM
refresh toma Linux - General 17 08-08-2001 10:15 AM
NIC Not grabbing IP after DHCP refresh... bfloeagle Linux - Networking 2 07-26-2001 03:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 05:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration