mako icon indicating copy to clipboard operation
mako copied to clipboard

Get current configuration via IPC

Open emersion opened this issue 5 years ago • 9 comments

Not sure this is a good idea, but posting it as a separate issue:

Getting the status would also be very useful to create a statusbar block representing whether notifications are invisible or not. And probably useful for other config options too.

Originally posted by @RX14 in https://github.com/emersion/mako/issues/157#issuecomment-497885595

emersion avatar Jun 01 '19 14:06 emersion

I can't help but feel that actually parsing the config to figure out what happens to any given notification would be a massive pain.

Perhaps instead we could provide an endpoint like makoctl test which takes some notification fields like app-name, etc and returns a json representation of the computed style for that fake notification? Then the calling script wouldn't have to do logic to figure out how the criteria stack.

vilhalmer avatar Jun 01 '19 14:06 vilhalmer

This seems a little too complicated to me. I'd say for this use-case we should leave it to the script changing the notification option. Something like this would do:

makoctl set invisible $value
echo $value >$XDG_RUNTIME_DIR/mako-invisible

And then read this file from the statusbar.

emersion avatar Jun 01 '19 15:06 emersion

This only has to apply to global configuration options, or even just to invisible. Which I would think would be fairly simple to implement.

RX14 avatar Jun 02 '19 20:06 RX14

Just wanted to say that I could really use this feature for my waybar setup. Thank you for creating and maintaining mako! It's just what I needed.

ian-s-mcb avatar Jul 07 '21 14:07 ian-s-mcb

Can you explain why you need this for your waybar setup?

Now that we have modes, maybe adding a way to query the current mode would be useful. Might want to be careful about the possible future extension of allowing multiple modes to be active at the same time.

emersion avatar Jul 07 '21 14:07 emersion

maybe adding a way to query the current mode would be useful

Yup, that's it. I want to make a custom waybar module[1] that toggles the mako do-not-disturb mode, but to do that I need the current mode.

[1] https://github.com/Alexays/Waybar/wiki/Module:-Custom

ian-s-mcb avatar Jul 07 '21 14:07 ian-s-mcb

maybe adding a way to query the current mode would be useful

Yup, that's it. I want to make a custom waybar module[1] that toggles the mako do-not-disturb mode, but to do that I need the current mode.

[1] https://github.com/Alexays/Waybar/wiki/Module:-Custom

+1 for a way to query the current mode. I just set up a DND toggle for Waybar, but it sets the mode to default every time waybar starts up, which is a workaround way of knowing makos current state. Script is below if helpful @ian-s-mcb

#!/usr/bin/env python3

import signal
import time
import subprocess

subprocess.run(["makoctl", "set-mode", "default"])
status = "on"

def toggle(signum, stack):
  global status
  if status == "on":
    subprocess.run(["makoctl", "set-mode", "dnd"])
    subprocess.run(["echo", "{\"text\":\"Off\",\"class\":\"off\",\"percentage\":0}"])
    status = "off"
  else:
    subprocess.run(["makoctl", "set-mode", "default"])
    subprocess.run(["echo", "{\"text\":\"On\",\"class\":\"on\",\"percentage\":100}"])
    status = "on"

signal.signal(signal.SIGUSR1, toggle)

while True:
  if status == "on":
    subprocess.run(["echo", "{\"text\":\"On\",\"class\":\"on\",\"percentage\":100}"])
  else:
    subprocess.run(["echo", "{\"text\":\"Off\",\"class\":\"off\",\"percentage\":0}"])
  time.sleep(5)

stvsu avatar Jul 07 '21 19:07 stvsu

Thanks for the script, @stvsu. I prefer to wait for an integrated solution.

ian-s-mcb avatar Jul 07 '21 21:07 ian-s-mcb

Let's track the issue about querying the current mode in https://github.com/emersion/mako/issues/367, and keep this issue for querying the current config file options (still not sure the latter is a good idea).

emersion avatar Jul 13 '21 08:07 emersion