[modules/dunst] Fix toggling

At least Void Linux doesn't like kill -SIGUSR<N>

Also, added some debugging to inspect state changes for modules/widgets.

Also also, fix problem with min width, if no minwidth is set
This commit is contained in:
tobi-wan-kenobi 2020-03-29 14:13:21 +02:00
parent da14ad3f36
commit b66b13211e
3 changed files with 15 additions and 5 deletions

View file

@ -18,8 +18,10 @@ class Config(util.store.Store):
parser.add_argument('-t', '--theme', default='default', help=THEME_HELP) parser.add_argument('-t', '--theme', default='default', help=THEME_HELP)
parser.add_argument('-i', '--iconset', default='auto', parser.add_argument('-i', '--iconset', default='auto',
help='Specify the name of an iconset to use (overrides theme default)') help='Specify the name of an iconset to use (overrides theme default)')
parser.add_argument("-a", "--autohide", nargs="+", default=[], parser.add_argument('-a', '--autohide', nargs='+', default=[],
help="Specify a list of modules to hide when not in warning/error state") help='Specify a list of modules to hide when not in warning/error state')
parser.add_argument('--debug', action='store_true',
help='Add debug fields to i3 output')
self._args = parser.parse_args(args) self._args = parser.parse_args(args)
parameters = [ item for sub in self._args.parameters for item in sub ] parameters = [ item for sub in self._args.parameters for item in sub ]
@ -33,6 +35,9 @@ class Config(util.store.Store):
def interval(self): def interval(self):
return float(self.get('interval', 1)) return float(self.get('interval', 1))
def debug(self):
return self._args.debug
def theme(self): def theme(self):
return self._args.theme return self._args.theme

View file

@ -50,6 +50,7 @@ class i3(object):
return '{}{}{}'.format(padding, full_text, padding) return '{}{}{}'.format(padding, full_text, padding)
def __decorate(self, module, widget, full_text): def __decorate(self, module, widget, full_text):
if full_text is None: return None
return '{}{}{}'.format( return '{}{}{}'.format(
self.__pad(module, widget, self._theme.prefix(widget)), self.__pad(module, widget, self._theme.prefix(widget)),
full_text, full_text,
@ -88,6 +89,10 @@ class i3(object):
'background': self._theme.bg(widget), 'background': self._theme.bg(widget),
'min_width': self.__decorate(module, widget, widget.get('theme.minwidth')), 'min_width': self.__decorate(module, widget, widget.get('theme.minwidth')),
}) })
if (self._config.debug()):
attr.update({
'__state': ", ".join(module.state(widget))
})
return [attr] return [attr]
def widgets(self, module): def widgets(self, module):

View file

@ -13,7 +13,7 @@ class Module(core.module.Module):
super().__init__(config, core.widget.Widget('')) super().__init__(config, core.widget.Widget(''))
self._paused = False self._paused = False
# Make sure that dunst is currently not paused # Make sure that dunst is currently not paused
util.cli.execute('killall -SIGUSR2 dunst', ignore_errors=True) util.cli.execute('killall -s SIGUSR2 dunst', ignore_errors=True)
core.input.register(self, button=core.input.LEFT_MOUSE, core.input.register(self, button=core.input.LEFT_MOUSE,
cmd=self.toggle_status cmd=self.toggle_status
) )
@ -23,9 +23,9 @@ class Module(core.module.Module):
try: try:
if self._paused: if self._paused:
util.cli.execute('killall -SIGUSR1 dunst') util.cli.execute('killall -s SIGUSR1 dunst')
else: else:
util.cli.execute('killall -SIGUSR2 dunst') util.cli.execute('killall -s SIGUSR2 dunst')
except: except:
self._paused = not self._paused # toggling failed self._paused = not self._paused # toggling failed