diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2024-02-05 15:54:52 -0800 | 
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2024-02-05 15:54:52 -0800 | 
| commit | a027b999e71532be9562fe733b745c09a8640868 (patch) | |
| tree | 9e62fe8592cec804c23bd368127e563bfa4164fb | |
| parent | bb17ba974fad2af5a0288385fae07c8fd3d640a7 (diff) | |
| download | panel-a027b999e71532be9562fe733b745c09a8640868.tar.gz panel-a027b999e71532be9562fe733b745c09a8640868.tar.xz | |
allow multiple clickable modules of same type
| -rwxr-xr-x | panel.py | 19 | 
1 files changed, 10 insertions, 9 deletions
| @@ -58,9 +58,9 @@ class ModDate(Mod):              dt = datetime.now().astimezone(ZoneInfo(tz_id) if tz_id else None)              label = tz_label or dt.strftime('%Z') -            buf = ('%{A4:ModDate tz +1:}%{A5:ModDate tz -1:}' -                f'%{{A:ModDate tz:}}{fmt_label(label)}%{{A}}{spacing()}' -                f'%{{A:ModDate fmt:}}{dt.strftime(fmt)}%{{A}}' +            buf = (f'%{{A4:{id(self)} tz +1:}}%{{A5:{id(self)} tz -1:}}' +                f'%{{A:{id(self)} tz:}}{fmt_label(label)}%{{A}}{spacing()}' +                f'%{{A:{id(self)} fmt:}}{dt.strftime(fmt)}%{{A}}'                  '%{A}%{A}')              with self.cv: @@ -88,7 +88,7 @@ class ModHLWM(Mod):          self.out = f'{self.out_tags}{spacing()}{self.out_title}'      def fmt_tag(self, sym, tag, tagstr): -        buf = f'%{{A:ModHLWM use {tag}:}}' +        buf = f'%{{A:{id(self)} use {tag}:}}'          match sym:              case '.':                  buf += f'%{{F#777777}}%{{O7}}{tag}%{{O7}}%{{F-}}' @@ -113,7 +113,8 @@ class ModHLWM(Mod):              stdout=subprocess.PIPE, text=True)          tagstr = res.stdout.strip()          tags = tagstr.split('\t') -        buf = '%{A4:ModHLWM use_index +1:}%{A5:ModHLWM use_index -1:}' +        buf = (f'%{{A4:{id(self)} use_index +1:}}' +            f'%{{A5:{id(self)} use_index -1:}}')          for tag in tags:              buf += self.fmt_tag(tag[0], tag[1:], tagstr)          buf += '%{A}%{A}' @@ -176,16 +177,16 @@ class Bar:          self.mods = mods          for m in self.mods:              m.cv = self.cv +        self.mod_by_id = {id(m): m for m in self.mods}      def process_cmds(self, pipe):          while True:              line = pipe.readline()              if not line:                  break -            cmd_mod, cmd = line.rstrip().split(' ', 1) -            for mod in self.mods: -                if mod.__class__.__name__ == cmd_mod: -                    mod.process_cmd(cmd) +            mod_id, cmd = line.rstrip().split(' ', 1) +            if mod := self.mod_by_id.get(int(mod_id)): +                mod.process_cmd(cmd)      def run(self):          for mod in self.mods: | 
