Support for the 3rd version of the i3bar-onclick-patch

This commit is contained in:
enkore 2013-03-10 01:27:23 +01:00
parent 657bdb826a
commit 375ba3af7b
5 changed files with 19 additions and 6 deletions

View File

@ -41,7 +41,7 @@ class Status:
if j["command"] == "block_clicked":
module = self.modules.get_by_id(j["instance"])
if module:
module.on_click()
module.on_click(j["button"])
def run(self):
for j in io.JSONIO(self.io).read():

View File

@ -21,7 +21,16 @@ class Module(SettingsBase):
self.output["instance"] = str(id(self))
json.insert(0, self.output)
def on_click(self):
def on_click(self, button):
if button == 1: # Left mouse button
self.on_leftclick()
elif button == 3: # Right mouse button
self.on_rightclick()
def on_leftclick(self):
pass
def on_rightclick(self):
pass
def __repr__(self):

View File

@ -87,5 +87,5 @@ class ModsDeChecker(IntervalModule):
self.opener.addheaders.append(("Cookie", "{}={}".format(cookie.name, cookie.value)))
return True
def on_click(self):
webbrowser.open_new_tab("http://forum.mods.de/bb/")
def on_leftclick(self):
webbrowser.open_new_tab("http://forum.mods.de/bb/")

View File

@ -1,5 +1,6 @@
from itertools import zip_longest
import subprocess
# PyPI: netifaces-py3
import netifaces
@ -61,7 +62,7 @@ class Network(IntervalModule):
("interface", "Interface to obtain information for, i.e. eth0"),
"format_up", "color_up",
"format_down", "color_down",
"name"
"name",
)
name = interface = "eth0"
@ -113,3 +114,6 @@ class Network(IntervalModule):
"color": color,
"instance": self.interface
}
def on_leftclick(self):
subprocess.Popen(["nm-connection-editor"])

View File

@ -64,5 +64,5 @@ class ParcelTracker(IntervalModule):
"instance": self.name,
}
def on_click(self):
def on_leftclick(self):
webbrowser.open_new_tab(self.instance.get_url())