awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.37k stars 598 forks source link

Custom naughty.action and signals #3017

Open SethBarberee opened 4 years ago

SethBarberee commented 4 years ago

How to reproduce the issue:

Currently trying to add buttons (actions) with the new notif rules to skip, play/pause, replay. I've added the following:

    ruled.notification.append_rule {
        rule       = { app_name = 'Spotify' },
        properties = { 
            append_actions = {
                naughty.action {
                    name = "Back",
                    selected = false
                },
                naughty.action {
                    name = "Play/Pause",
                    selected = false
                },
                naughty.action {
                    name = "Next",
                    selected = false
                },
            }
        }
    }

This adds the actions correctly but from here, I get a little lost. I figured that I need to implement a handler for each of the actions based on whether they are selected or not. So here's how I attempted to work on it...

Actual result:

When I click an action, I understand that the invoked signal is emitted but nothing else happens. I tried to listen for the property::selected signal since this could tell me which action is selected but it is never emitted. This is based on naughty/action.lua and naughty/list/actions.lua

Expected result:

Should the action.selected be toggled in the invoke method? I can PR but I wanted to make sure.

This should hopefully allow me to just match which action was updated and spawn the correct command.

Elv13 commented 4 years ago

First of all, selected isn't currently implemented well. It was meant to be used with awful.keygrabber, but I have no example.

As far as how to use action, I knew this issue would be reported sooner or later. There is a planned pull request series in the "API standardization" to address the inability of directly connecting things with the declarative syntax. It looks like this:

local my_object = gears.object {
     ...
     gears.object.connection {
          --target = other_object --defaults to parent
          signal = "something",
          callback = function(self, arg1, arg2)
              ...
          end
      },
      gears.object.connection {
          --target = other_object --defaults to parent
          property = "myproperty",
          callback = function(self, new_value, old_value)
              ...
          end
      },
      gears.object.connection {
          --target = other_object --defaults to parent
          id = "some_objects_id",
          callback = function(self, new_value, old_value)
              ... --called on all instances with this id
          end
      },
}

However I am not done with that PR yet. I am still trying to get the screen rules out (and that's a lot of work).

edit: and yes, I stole that directly from Qt/QML