diff options
-rw-r--r-- | awesompd.lua | 33 | ||||
-rw-r--r-- | jamendo.lua | 2 | ||||
-rw-r--r-- | rcsample.lua | 14 |
3 files changed, 41 insertions, 8 deletions
diff --git a/awesompd.lua b/awesompd.lua index 97c3722..d88f8d1 100644 --- a/awesompd.lua +++ b/awesompd.lua @@ -1,7 +1,7 @@ --------------------------------------------------------------------------- -- @author Alexander Yakushev <yakushev.alex@gmail.com> -- @copyright 2010-2011 Alexander Yakushev --- @release v1.1.1 +-- @release v1.1.2 --------------------------------------------------------------------------- awesompd = {} @@ -34,7 +34,7 @@ local keygrabber = keygrabber -- Debug stuff -local enable_dbg = false +local enable_dbg = true local function dbg (...) if enable_dbg then print(...) @@ -248,18 +248,43 @@ end -- Function that registers buttons on the widget. function awesompd:register_buttons(buttons) widget_buttons = {} + self.global_bindings = {} for b=1,table.getn(buttons) do if type(buttons[b][1]) == "string" then mods = { buttons[b][1] } else mods = buttons[b][1] end - table.insert(widget_buttons, - awful.button(mods, buttons[b][2], buttons[b][3])) + if type(buttons[b][2]) == "number" then + -- This is a mousebinding, bind it to the widget + table.insert(widget_buttons, + awful.button(mods, buttons[b][2], buttons[b][3])) + else + -- This is a global keybinding, remember it for later usage in append_global_keys + table.insert(self.global_bindings, awful.key(mods, buttons[b][2], buttons[b][3])) + end end self.widget:buttons(self.ajoin(widget_buttons)) end +-- Takes the current table with keybindings and adds widget's own +-- global keybindings that were specified in register_buttons. +-- If keytable is not specified, then adds bindings to default +-- globalkeys table. If specified, then adds bindings to keytable and +-- returns it. +function awesompd:append_global_keys(keytable) + if keytable then + for i = 1, table.getn(self.global_bindings) do + keytable = awful.util.table.join(keytable, self.global_bindings[i]) + end + return keytable + else + for i = 1, table.getn(self.global_bindings) do + globalkeys = awful.util.table.join(globalkeys, self.global_bindings[i]) + end + end +end + -- /// Group of mpc command functions /// -- Takes a command to mpc and a hook that is provided with awesompd diff --git a/jamendo.lua b/jamendo.lua index 5a01975..9308dc2 100644 --- a/jamendo.lua +++ b/jamendo.lua @@ -1,7 +1,7 @@ --------------------------------------------------------------------------- -- @author Alexander Yakushev <yakushev.alex@gmail.com> -- @copyright 2011 Alexander Yakushev --- @release v1.1.1 +-- @release v1.1.2 --------------------------------------------------------------------------- -- Grab environment diff --git a/rcsample.lua b/rcsample.lua index 30acbb9..c5e0364 100644 --- a/rcsample.lua +++ b/rcsample.lua @@ -127,17 +127,22 @@ mysystray = widget({ type = "systray" }) port = 6600 } } - -- Set the buttons of the widget + -- Set the buttons of the widget. Keyboard keys are working in the + -- entire Awesome environment. Also look at the line 352. musicwidget:register_buttons({ { "", awesompd.MOUSE_LEFT, musicwidget:command_playpause() }, { "Control", awesompd.MOUSE_SCROLL_UP, musicwidget:command_prev_track() }, { "Control", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_next_track() }, { "", awesompd.MOUSE_SCROLL_UP, musicwidget:command_volume_up() }, { "", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_volume_down() }, - { "", awesompd.MOUSE_RIGHT, musicwidget:command_show_menu() } }) + { "", awesompd.MOUSE_RIGHT, musicwidget:command_show_menu() }, + { "", "XF86AudioLowerVolume", musicwidget:command_volume_down() }, + { "", "XF86AudioRaiseVolume", musicwidget:command_volume_up() }, + { modkey, "Pause", musicwidget:command_playpause() } }) + musicwidget:run() -- After all configuration is done, run the widget -- END OF AWESOMPD WIDGET DECLARATION --- Don't forget to add the widget to the wibox. It is done on the line 207. +-- Don't forget to add the widget to the wibox. It is done on the line 216. mywibox = {} mypromptbox = {} @@ -343,6 +348,9 @@ clientbuttons = awful.util.table.join( awful.button({ modkey }, 3, awful.mouse.client.resize)) -- Set keys +-- Add this line before root.keys(globalkeys). +musicwidget:append_global_keys() + root.keys(globalkeys) -- }}} |