Merge pull request #92 from RobertSacks/master
[modules/publicip] Add module to show current public IP address
This commit is contained in:
commit
0e5ff2956b
2 changed files with 33 additions and 0 deletions
30
bumblebee/modules/publicip.py
Normal file
30
bumblebee/modules/publicip.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
"""Displays public IP address
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
from urllib2 import urlopen
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
import bumblebee.output
|
||||||
|
import bumblebee.engine
|
||||||
|
|
||||||
|
class Module(bumblebee.engine.Module):
|
||||||
|
def __init__(self, engine, config):
|
||||||
|
super(Module, self).__init__(engine, config,
|
||||||
|
bumblebee.output.Widget(full_text=self.public_ip)
|
||||||
|
)
|
||||||
|
|
||||||
|
self._ip = ""
|
||||||
|
|
||||||
|
|
||||||
|
def public_ip(self, widget):
|
||||||
|
return self._ip
|
||||||
|
|
||||||
|
def update(self, widgets):
|
||||||
|
try:
|
||||||
|
self._ip = urlopen("http://ip.42.pl/raw").read()
|
||||||
|
except Exception:
|
||||||
|
self._ip = "Not Connected"
|
||||||
|
|
|
@ -99,5 +99,8 @@
|
||||||
},
|
},
|
||||||
"spotify": {
|
"spotify": {
|
||||||
"prefix": " "
|
"prefix": " "
|
||||||
|
},
|
||||||
|
"publicip": {
|
||||||
|
"prefix": " "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue