LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-11-2018, 11:37 PM   #1
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Rep: Reputation: Disabled
Display VPN location in Conky desktop


I can click pia icon in notification tray and a dialog will display external ip, location, and other options. Displaying ip is not a problem, but I have no idea how to capture the location so I can display it in Conky. Image below shows dialog. Its the location, in this case, Seattle, Im after. Anyone have ideas?

http://i63.tinypic.com/35d56bb.png

Last edited by jj1; 11-12-2018 at 09:24 PM.
 
Old 11-13-2018, 01:55 AM   #2
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Original Poster
Rep: Reputation: Disabled
Hmm...My question disappeared.
 
Old 11-13-2018, 01:59 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 10,212
Blog Entries: 7

Rep: Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523
Quote:
Originally Posted by jj1 View Post
Hmm...My question disappeared.
would you like to ask it again?

from the title, i would say:
this consists of 2 steps:
  1. get the desired information with a short shell script or oneliner
  2. add that information to conky
i can help with the 2nd step.
 
1 members found this post helpful.
Old 11-13-2018, 03:27 AM   #4
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Original Poster
Rep: Reputation: Disabled
The included screenshot shows the dialog. What I want to place in conky, in this case is the location, US Seattle, or the whole string if that would be easier. Though I hope for it to be dynamic, and show what ever location that its connected to. My thoughts are that if it's in a menu then the info's in a table, or array somewhere. It;s just a matter of knowing how to get to it. Anyway, hear's the screenshot:

http://i68.tinypic.com/fks6jm.jpg
 
Old 11-13-2018, 04:51 AM   #5
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Original Poster
Rep: Reputation: Disabled
Im Linux newby. The extent of my script/programming skills start and end with TI Basic calculator.
I turned on logging, and I see that the string is there. Conky starts about 10 seconds after boot, so PIA is already connected, and entry would be in log. Here is last few lines of log file:

"notifications":{},"openvpn_status":{"single":"started"},"need_upgrade":{"value":false,"latest_versi on":81},"forwarded_port":{"single":null},"external_ip":{"single":"173.244.44.45"},"region":{"single" :"us_seattle"},"debug_log_result":{}}
[2018-11-13T06:30:26.456Z] <debug> |main| Updating model with regions
[2018-11-13T06:30:26.456Z] <info> |main| Regions are "US California", "US East", "US Chicago", "US Texas", "US Florida", "US Seattle", "US West", "US Silicon Valley", "US New York City", "US Washington DC", "US Atlanta", "US Las Vegas", "US Houston", "US Denver", "UK London", "UK Southampton", "UK Manchester", "CA Toronto", "CA Montreal", "CA Vancouver", "AU Sydney", "AU Melbourne", "DE Berlin", "DE Frankfurt", "New Zealand", "Netherlands", "Sweden", "Norway", "Denmark", "Finland", "Switzerland", "France", "Belgium", "Austria", "Czech Republic", "Luxembourg", "Ireland", "Italy", "Spain", "Romania", "Hungary", "Poland", "Turkey", "UAE", "Hong Kong", "Singapore", "Japan", "Israel", "Mexico", "Brazil", "India", "South Africa"
[2018-11-13T06:30:26.456Z] <debug> |main| Updating model with external ip
[2018-11-13T06:30:26.457Z] <info> |main| External ip is 173.244.44.45
[2018-11-13T06:30:26.458Z] <debug> |tray| External ip changed
[2018-11-13T06:30:26.458Z] <debug> |tray| Regions changed
[2018-11-13T06:30:26.458Z] <debug> |tray| Refreshing menu
[2018-11-13T06:30:26.458Z] <debug> |tray| Translated status is "You are connected (US Seattle)"

The last string in log is what I need.
 
Old 11-14-2018, 08:14 AM   #6
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: VirtualBox win 10 guest | OpenBSD 6.3 bridge | Fedora 29 | Windows 10 pro
Posts: 365

Rep: Reputation: 142Reputation: 142
if you want conky to show your current ip address, this is what i have used :
Code:
External IP: ${execi 600 curl ifconfig.co 2>/dev/null | tail }
 
Old 11-14-2018, 01:22 PM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 10,212
Blog Entries: 7

Rep: Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523Reputation: 2523
^ yes that is simple and maybe sufficient.

the dialog from your screenshot looks like part of the networkmanager applet in your systray.
networkmanager has a full command line interface; read
Code:
man nmcli
to see what's possible. probably it can be asked to spit out the info you want.
then all you need inside your conky is sth like
Code:
${execi <interval_in_seconds> nmcli --options}
 
1 members found this post helpful.
Old 11-14-2018, 06:14 PM   #8
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Original Poster
Rep: Reputation: Disabled
@ //////-Thx, but'm already displaying external ip with this command: "External IP:$alignr${execi 3600 curl ifconfig.me | tail }". It seems to work OK, and it's not too different from your command. At-any-rate, it's the location of the ip I want to display.
 
Old 11-14-2018, 06:25 PM   #9
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Original Poster
Rep: Reputation: Disabled
@ ondoho- Thx for that!
 
Old 11-14-2018, 09:45 PM   #10
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Original Poster
Rep: Reputation: Disabled
Its like nmcli doesn't even see pia. Ive tried several commands. I can see devices, connections, and get loads of info, but no mention of pia or its connection location. The command, "nmcli --show-secrets connection show "connection id""is interesting, and even shows my wifi password, but no command I try has any mention of pia. I ran commands with and without vpn connected and none of the info changed.

Last edited by jj1; 11-14-2018 at 09:48 PM.
 
Old 11-14-2018, 11:35 PM   #11
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Original Poster
Rep: Reputation: Disabled
Although nmcli may be a more glamorous solution I think using log file will suffice for my goals. I already know that at any given time the last line of pia log provide me the location as a string. The log always ends with a line like this:

[2018-11-15T02:38:41.807Z] <debug> |tray| Translated status is "You are connected (Canada Vancouver)"

The only thing being different is the date and location. I was able to print this line in conky by using this:

${exec cat /home/jj1/.pia_manager/log/pia_nw.log | tail -n 1}

Im not sure if cat is appropriate function to use, but considering Ive been a Windows monkey for so long Im actaully happy I was able to make that work What I really need is to display only the string part of the line. Part of the string changes from, "You are connected", to, "Connecting...", when I switch to another location, and considering that the charictor count of the location name is different for each location, I can't use something like a substring length, or position. The function needs to search for the quotes, and print whats within them in a dynamic fasion.
 
Old 11-15-2018, 03:40 AM   #12
jj1
LQ Newbie
 
Registered: Nov 2018
Location: Pacific northwest
Distribution: MX Linux 17.1
Posts: 14

Original Poster
Rep: Reputation: Disabled
I have a solution.
End of log file.
Quote:
..."region":{"single":"ca_vancouver"},"debug_log_result":{}}
[2018-11-15T03:34:07.157Z] <debug> |main| Updating model with regions
[2018-11-15T03:34:07.157Z] <info> |main| Regions are "US California", "US East", "US Chicago", "US Texas", "US Florida", "US Seattle", "US West", "US Silicon Valley", "US New York City", "US Washington DC", "US Atlanta", "US Las Vegas", "US Houston", "US Denver", "UK London", "UK Southampton", "UK Manchester", "CA Toronto", "CA Montreal", "CA Vancouver", "AU Sydney", "AU Melbourne", "DE Berlin", "DE Frankfurt", "New Zealand", "Netherlands", "Sweden", "Norway", "Denmark", "Finland", "Switzerland", "France", "Belgium", "Austria", "Czech Republic", "Luxembourg", "Ireland", "Italy", "Spain", "Romania", "Hungary", "Poland", "Turkey", "UAE", "Hong Kong", "Singapore", "Japan", "Israel", "Mexico", "Brazil", "India", "South Africa"
[2018-11-15T03:34:07.158Z] <debug> |main| Updating model with forwarded port
[2018-11-15T03:34:07.158Z] <info> |main| Forwarded port is 48235
[2018-11-15T03:34:07.158Z] <debug> |tray| Forwarded port changed
[2018-11-15T03:34:07.159Z] <debug> |tray| Regions changed
[2018-11-15T03:34:07.159Z] <debug> |tray| Refreshing menu
[2018-11-15T03:34:07.160Z] <debug> |tray| Translated status is "You are connected (Canada Vancouver)"
I used this to extract desired substring:
Quote:
awk -F"[()]" 'END {print $2}' /directory/of/file
I came across other solutions, but this one seems optimum to me.

Resulting output:
Canada Vancouver
https://i.stack.imgur.com/SRNlP.png

Last edited by jj1; 11-16-2018 at 12:08 AM. Reason: Adding image of resulting output:
 
  


Reply

Tags
awk, conky


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
LXer: Google I/O Android News: Location, Location, Location (Plus Cloud Messaging and Bluetooth) LXer Syndicated Linux News 0 06-05-2013 02:00 PM
conky question: passing conky-variable to shell-script zlin50 Linux - Software 2 12-29-2012 07:47 PM
LXer: Conky Ubuntu Lucid Theme - Among The Easiest to Install Conky Theme in Ubuntu LXer Syndicated Linux News 0 07-05-2010 05:11 PM
Conky on Suse 10.0 - *** buffer overflow detected *** conky terminated Slidex Linux - Software 1 03-17-2006 12:50 PM
location, location, location! mermxx LQ Suggestions & Feedback 9 09-25-2004 04:08 AM

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

All times are GMT -5. The time now is 07:47 AM.

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