Add the ability to change the position of a module in the i3bar
Create a method `move' in modules.py to insert the module's json in a different position than the default 0.
This commit is contained in:
parent
0ff17f4242
commit
ecb6c54052
@ -23,7 +23,9 @@ class Status:
|
||||
"""Register a new module."""
|
||||
|
||||
if module:
|
||||
self.modules.append(module, *args, **kwargs)
|
||||
return self.modules.append(module, *args, **kwargs)
|
||||
else:
|
||||
return None
|
||||
|
||||
def run_command_endpoint(self):
|
||||
for command in io.JSONIO(io=io.IOHandler(sys.stdin, open(os.devnull,"w")), skiplines=1).read():
|
||||
|
@ -10,6 +10,7 @@ __all__ = [
|
||||
|
||||
class Module(SettingsBase):
|
||||
output = None
|
||||
position = 0
|
||||
|
||||
def registered(self, status_handler):
|
||||
"""Called when this module is registered with a status handler"""
|
||||
@ -19,7 +20,7 @@ class Module(SettingsBase):
|
||||
if "name" not in self.output:
|
||||
self.output["name"] = self.__name__
|
||||
self.output["instance"] = str(id(self))
|
||||
json.insert(0, self.output)
|
||||
json.insert(self.position, self.output)
|
||||
|
||||
def on_click(self, button):
|
||||
if button == 1: # Left mouse button
|
||||
@ -27,6 +28,9 @@ class Module(SettingsBase):
|
||||
elif button == 3: # Right mouse button
|
||||
self.on_rightclick()
|
||||
|
||||
def move(self, position):
|
||||
self.position = position
|
||||
|
||||
def on_leftclick(self):
|
||||
pass
|
||||
|
||||
|
@ -46,6 +46,7 @@ class ModuleList(collections.UserList):
|
||||
module = self.finder.instanciate_class_from_module(module, *args, **kwargs)
|
||||
module.registered(self.status_handler)
|
||||
super().append(module)
|
||||
return module
|
||||
|
||||
def get_by_id(self, find_id):
|
||||
find_id = int(find_id)
|
||||
|
Loading…
Reference in New Issue
Block a user